Skip to content

Commit

Permalink
Fix joint to cartesian controller's robot chain
Browse files Browse the repository at this point in the history
The solver keeps an internal const ref.
We need to have the robot chain as member to avoid segfaults.
This is equivalent to [this fix](5e6e238).

Thanks to @matthias-mayr for spotting this.
  • Loading branch information
stefanscherzinger committed Oct 12, 2022
1 parent 14249f5 commit 046e3c0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ class JointToCartesianController

JointControllerAdapter m_controller_adapter;

KDL::Chain m_robot_chain;
std::vector<
hardware_interface::JointStateHandle> m_joint_handles;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ bool JointToCartesianController::init(hardware_interface::JointStateInterface* h
std::string robot_description;
urdf::Model robot_model;
KDL::Tree robot_tree;
KDL::Chain robot_chain;

// Get controller specific configuration
if (!nh.getParam("/robot_description",robot_description))
Expand Down Expand Up @@ -132,7 +131,7 @@ bool JointToCartesianController::init(hardware_interface::JointStateInterface* h
ROS_ERROR_STREAM(error);
throw std::runtime_error(error);
}
if (!robot_tree.getChain(m_robot_base_link,m_end_effector_link,robot_chain))
if (!robot_tree.getChain(m_robot_base_link,m_end_effector_link, m_robot_chain))
{
const std::string error = ""
"Failed to parse robot chain from urdf model. "
Expand Down Expand Up @@ -165,7 +164,7 @@ bool JointToCartesianController::init(hardware_interface::JointStateInterface* h
m_controller_manager.reset(new controller_manager::ControllerManager(&m_controller_adapter, nh));

// Initialize forward kinematics solver
m_fk_solver.reset(new KDL::ChainFkSolverPos_recursive(robot_chain));
m_fk_solver.reset(new KDL::ChainFkSolverPos_recursive(m_robot_chain));

return true;
}
Expand Down

0 comments on commit 046e3c0

Please sign in to comment.