Skip to content

Instantly share code, notes, and snippets.

@mikaelarguedas
Created January 10, 2020 10:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikaelarguedas/ebe6fdd30c8bc9ebf40ae6710f4fb1f6 to your computer and use it in GitHub Desktop.
Save mikaelarguedas/ebe6fdd30c8bc9ebf40ae6710f4fb1f6 to your computer and use it in GitHub Desktop.
Xacro test
<launch>
<param name="robot_description" command="$(find xacro)/xacro --inorder '$(find foobar)/launch/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"/>
</launch>
<robot xmlns:xacro="http://www.ros.org/wiki/xacro">
<xacro:arg name="laser_topic" default="scan"/>
<xacro:property name="lidar_topic" value="$(arg laser_topic)"/>
<link name="base_link"/>
<xacro:macro name="sick_tim551" params="name ros_topic">
<plugin name="gazebo_ros_${name}_controller" filename="libgazebo_ros_laser.so">
<alwaysOn>true</alwaysOn>
<topicName>${ros_topic}</topicName>
</plugin>
</xacro:macro>
<xacro:macro name="laser_scanner" params="parent topic">
<xacro:sick_tim551 name="laser1" ros_topic="${topic}"/>
<joint name="laser1_mount_joint" type="fixed">
<parent link="${parent}"/>
<child link="laser1_mount_link"/>
<origin xyz="0 0 1" rpy="0 0 0"/>
</joint>
</xacro:macro>
<laser_scanner parent="base_link" topic="${lidar_topic}"/>
</robot>
# /opt/ros/kinetic/lib/xacro/xacro --inorder '/opt/ros/foobar/src/foobar/launch/myrobot.xacro' laser_topic:=scan_topic
<?xml version="1.0" ?>
<!-- =================================================================================== -->
<!-- | This document was autogenerated by xacro from /opt/ros/foobar/src/foobar/launch/myrobot.xacro | -->
<!-- | EDITING THIS FILE BY HAND IS NOT RECOMMENDED | -->
<!-- =================================================================================== -->
<robot xmlns:xacro="http://www.ros.org/wiki/xacro">
<link name="base_link"/>
<plugin filename="libgazebo_ros_laser.so" name="gazebo_ros_laser1_controller">
<alwaysOn>true</alwaysOn>
<topicName>scan_topic</topicName>
</plugin>
<joint name="laser1_mount_joint" type="fixed">
<parent link="base_link"/>
<child link="laser1_mount_link"/>
<origin rpy="0 0 0" xyz="0 0 1"/>
</joint>
</robot>
# rosparam get /robot_description
"<?xml version=\"1.0\" ?>\n<!-- ===================================================================================\
\ -->\n<!-- | This document was autogenerated by xacro from /opt/ros/foobar/src/foobar/launch/myrobot.xacro\
\ | -->\n<!-- | EDITING THIS FILE BY HAND IS NOT RECOMMENDED \
\ | -->\n<!-- ===================================================================================\
\ -->\n<robot xmlns:xacro=\"http://www.ros.org/wiki/xacro\">\n <link name=\"base_link\"\
/>\n <plugin filename=\"libgazebo_ros_laser.so\" name=\"gazebo_ros_laser1_controller\"\
>\n <alwaysOn>true</alwaysOn>\n <topicName>scan_topic</topicName>\n </plugin>\n\
\ <joint name=\"laser1_mount_joint\" type=\"fixed\">\n <parent link=\"base_link\"\
/>\n <child link=\"laser1_mount_link\"/>\n <origin rpy=\"0 0 0\" xyz=\"0 0\
\ 1\"/>\n </joint>\n</robot>\n\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment