xacro arg not working in lauch file
I'm using ros kinetic and I'm trying to get an argument via the launch file in my xacro file. I've done some reading and found that this can be done by adding the following lines to a xacro file
<xacro:arg name="laser_topic" default="scan"/>
<xacro:property name="lidar_topic" value="$(arg laser_topic)"/>
This would mean I could add the argument laser_topic when I launch. The strange part is, if I do:
rosrun xacro xacro --inorder myrobot.xacro laser_topic:=scan_topic
or
rosrun xacro xacro --inorder myrobot.xacro laser_topic:=scan_topic > myrobot.urdf
It will actually use the correct topic, namely scan_topic. However, if I try it via a launch file, using the following piece of code to create the urdf and spawn my robot in Gazebo:
<param name="robot_description" command="$(find xacro)/xacro --inorder '$(find project)/urdf/myrobot.xacro' laser_topic:=scan_topic"/>
<!-- Run a python script to the send a service call to gazebo_ros to spawn a URDF robot -->
<node name="urdf_spawner" pkg="gazebo_ros" type="spawn_model" respawn="false" output="screen"
args="-urdf -model myrobot -param robot_description"/>
It keeps the old topic scan, not the new one scan_topic. What am I doing wrong?
If you
rosparam get /robot_description
, do you have the result you expect (scan_topic
) or the old topic ?How is this property used in the xacro file?
The property is used like this:
which then calls a xacro:macro:
and the xacro:sick_tim551 has this part:
if I use
rosparam get /robot_description
I get<topicName>scan</topicName>
meaning that it used the default value assigned to the argument.I expect it to use (
scan_topic
) since I added the linelaser_topic:=scan_topic
to my robot description parameter.I tried this with a simple example but couldnt reproduce the error. Can you try to simplify the example on your side to pin down where things went wrong?
it turned out that I accidentally called the line
somewhere else too. This meant the parameter got overwritten. Once I renamed it, it worked flawlessly. It went wrong between me and the keyboard, as they say. Thank you very much for your help though, it allowed me to better pin down the issue