Ask Your Question
0

URDF on parameter server parsing error when calling urdf::Model initParam method

asked 2019-02-21 05:22:31 -0500

bvaningen gravatar image

updated 2019-02-21 06:51:12 -0500

I am using ROS kinetic and Ubuntu 16.04. I am trying to use a URDF from my parameter server in a node using the following code, with this launch file:

launch file

<launch>

<param name="robot_description"
       command="$(find xacro)/xacro --inorder '$(find march_description)/urdf/single-joint.xacro'" />
<node name="CTC_tools" pkg="march_control" type="CTC_tools" output="screen"/>

</launch>

URDF

<?xml version="1.0"?>
<!-- Revolute-Revolute Manipulator -->
<robot name="march" xmlns:xacro="http://www.ros.org/wiki/xacro">

<!-- Constants for robot dimensions -->
<xacro:property name="bar_mass" value="1.1372"/>
<xacro:property name="bar_length" value="0.78"/>
<xacro:property name="bar_width" value="0.012"/>
<xacro:property name="bar_height" value="0.045"/>

<xacro:property name="velocity_limit" value="1"/>
<xacro:property name="lower_limit" value="${-2*pi/180}"/>
<xacro:property name="upper_limit" value="${100*pi/180}"/>
<xacro:property name="effort_limit" value="1"/>

<xacro:property name="camera_link" value="0.05"/> <!-- Size of square 'camera' box -->

<plugin name="gazebo_ros_control" filename="libgazebo_ros_control.so">
    <robotNamespace>/march</robotNamespace>
</plugin>


<!-- Used for fixing robot to Gazebo 'base_link' -->
<link name="world"/>

<joint name="fixed_joint" type="fixed">
    <parent link="world"/>
    <child link="base"/>
    <origin xyz="0 0 0" rpy="0 0 0"/>

    <limit velocity="${velocity_limit}" effort="${effort_limit}" lower="${lower_limit}" upper="${upper_limit}"/>
</joint>

<!-- Base -->
<link name="base">
    <visual>
        <origin xyz="0 0 0" rpy="0 0 0"/>
        <geometry>
            <box size="0.1 0.1 0.1"/>
        </geometry>
    </visual>
    <inertial>
        <origin xyz="${bar_length/2} ${bar_height/2} ${bar_width/2}" rpy="0 0 0"/>
        <mass value="${bar_mass}"/>
        <inertia
                ixx="${bar_mass / 12.0 * (bar_width*bar_width + bar_height*bar_height)}" ixy="0.0" ixz="0.0"
                iyy="${bar_mass / 12.0 * (bar_height*bar_height + bar_width*bar_width)}" iyz="0.0"
                izz="${bar_mass / 12.0 * (bar_width*bar_width + bar_width*bar_width)}"/>
    </inertial>
</link>

<joint name="test_joint" type="revolute">
    <parent link="base"/>
    <child link="bar"/>
    <origin xyz="0 0 0" rpy="0 0 0"/>
    <axis xyz="0 -1 0"/>

    <limit velocity="${velocity_limit}" effort="${effort_limit}" lower="${lower_limit}" upper="${upper_limit}"/>
</joint>


<!-- Bar -->
<link name="bar">
    <visual>
        <origin xyz="${bar_length/2} 0 0" rpy="0 0 0"/>
        <geometry>
            <box size="${bar_length} ${bar_width} ${bar_height}"/>
        </geometry>
    </visual>

    <inertial>
        <origin xyz="${bar_length/2} ${bar_height/2} ${bar_width/2}" rpy="0 0 0"/>
        <mass value="${bar_mass}"/>
        <inertia
                ixx="${bar_mass / 12.0 * (bar_width*bar_width + bar_height*bar_height)}" ixy="0.0" ixz="0.0"
                iyy="${bar_mass / 12.0 * (bar_height*bar_height + bar_width*bar_width)}" iyz="0.0"
                izz="${bar_mass / 12.0 * (bar_width*bar_width + bar_width*bar_width)}"/>
    </inertial>
</link>


<!-- ROS Control plugin for Gazebo -->

<transmission name="test_joint">
    <type>transmission_interface/SimpleTransmission</type>
    <joint name="test_joint">
        <hardwareInterface>hardware_interface/PositionJointInterface</hardwareInterface>
    </joint>
    <actuator name="test_joint_motor">
        <hardwareInterface>hardware_interface/PositionJointInterface</hardwareInterface>
        <mechanicalReduction>1</mechanicalReduction>
    </actuator>
</transmission>


</robot>

Node with the following c++ code for the node

#include "ros/ros.h"
#include "std_msgs/String.h"
#include <iostream>
#include <urdf/model.h>
#include <rbdl/rbdl.h>
#include <rbdl/rbdl_utils.h>
#include <sstream>
#include <urdf/model.h>
#include <rbdl/addons/urdfreader/urdfreader.h>

using namespace RigidBodyDynamics;
using namespace RigidBodyDynamics::Math;


int main(int argc, char** argv)
{
  // intializing and linking the ROS node to the core
  ros::init(argc, argv, "CTC_tools");
  ros::NodeHandle n;
  ros::Rate loop_rate(10);

  urdf::Model urdfModel;

  urdfModel.initParam("robot_description ...
(more)
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2019-02-21 05:42:47 -0500

gvdhoorn gravatar image
int main(int argc, char** argv)
{
  [..]

  std::string urdfName;

  urdf::Model urdfModel;
  urdfModel.initParam(urdfName)

  [..]
}

The problem here is this line: urdfModel.initParam(urdfName) (note also the missing semi-colon).

From the documentation:

Load Model given the name of a parameter on the parameter server.

The "name of a parameter" is passed into this function with the param argument, which you are passing urdfName.

But you don't initialise urdfName with an actual name, so it's just an empty string.

I would've expected urdf::Model::initParam(..) to complain about that, but it doesn't seem to do that.

You probably want to do something like this:

urdfModel.initParam("robot_description");

You don't need urdfName, you can just pass in a string directly.

edit flag offensive delete link more

Comments

My apologies for the faulty code! I have changed the code in the original question, however I still get the same error when running the executable that is generated

bvaningen gravatar imagebvaningen ( 2019-02-21 06:52:39 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2019-02-21 05:22:31 -0500

Seen: 120 times

Last updated: Feb 21