Gazebo | Ignition | Community
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Easy approach for me was to use parameter server in a launch file

 <param name="robot_description" command="$(find xacro)/ $(find walking_excavator_urdf)/xacro_manzi/walking_excavator.urdf.xacro" />
 <node name="spawn_urdf" pkg="gazebo_ros" type="spawn_model" args="-param robot_description -urdf -x 0 -y 0 -z 1 -model robot" />

so from xacro/urdf you can directly load in ROS parameter, then use c++ code..

ros::NodeHandle node;
std::string robot_desc_string;
node.param("robot_description", robot_desc_string, std::string());
if (!kdl_parser::treeFromString(robot_desc_string, my_tree)){
  ROS_ERROR("Failed to construct kdl tree");
  return false;

This way you can get the tree, can verify with

   unsigned int nj = my_tree.getNrOfJoints();
   unsigned int js = my_tree.getNrOfSegments();
   ROS_INFO("NrOfJoints =%d   ||  NrOfSegments= %d \n", nj,js);