Commit 396d5d20 authored by Florent Lamiraux's avatar Florent Lamiraux Committed by Florent Lamiraux florent@laas.fr
Browse files

In urdf parser, handle failure to insert an already existing frame.

  - in function addJointAndBody, when add frame with name joint_name, if the
    joint already exists, method Model::addJointFrame returns -1. This event was
    not detected leading to undefined behavior.
  - this commit detects this error and throws an exception.
parent 6ac2f57c
......@@ -104,7 +104,19 @@ namespace se3
joint_name,
max_effort,max_velocity,min_config,max_config
);
FrameIndex jointFrameId = (FrameIndex) model.addJointFrame(idx, (int)parentFrameId); // C-style cast to remove polluting compilation warning. This is Bad practice. See issue #323 (rework indexes)
int res (model.addJointFrame(idx, (int)parentFrameId));
if (res == -1) {
std::ostringstream oss;
oss << joint_name << " already inserted as a frame. Current frames "
"are [";
for (container::aligned_vector<Frame>::const_iterator it =
model.frames.begin (); it != model.frames.end (); ++it) {
oss << "\"" << it->name << "\",";
}
oss << "]";
throw std::runtime_error (oss.str ().c_str ());
}
FrameIndex jointFrameId = (FrameIndex) res; // C-style cast to remove polluting compilation warning. This is Bad practice. See issue #323 (rework indexes)
appendBodyToJoint(model, jointFrameId, Y, SE3::Identity(), body_name);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment