ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

create a laser in xacro

asked 2016-03-30 22:20:14 -0500

littlestar gravatar image

Who can give me a simple example my_robot.xacro file that creat a robot which has a laser. I donot knoe how to add a laser and I try to use the .gazebo/models/hoyuko(model),but it is sdf,it maybe cannot use in xacro. Thank you very much. This is the robot.xacro without a laser.

<robot xmlns:xacro="http://www.ros.org/wiki/xacro"
    name="robot1_xacro">


    <xacro:property name="length_wheel" value="0.05" />
    <xacro:property name="radius_wheel" value="0.05" />
    <xacro:macro name="default_inertial" params="mass">
               <inertial>
                       <mass value="${mass}" />
                       <inertia ixx="1.0" ixy="0.0" ixz="0.0"
                                iyy="1.0" iyz="0.0"
                                izz="1.0" />
               </inertial>
    </xacro:macro>

    <link name="base_footprint">
        <visual>
            <geometry>
                    <box size="0.001 0.001 0.001"/>
            </geometry>
            <origin rpy="0 0 0" xyz="0 0 0"/>
        </visual>
        <collision>
            <geometry>
                    <box size="0.001 0.001 0.001"/>
            </geometry>
        </collision>
    </link>

    <gazebo reference="base_footprint">
        <material>Gazebo/Green</material>
        <turnGravityOff>false</turnGravityOff>
    </gazebo>

    <joint name="base_footprint_joint" type="fixed">
        <origin xyz="0 0 0" />
        <parent link="base_footprint" />
        <child link="base_link" />
    </joint>


    <link name="base_link">
        <visual>
            <geometry>
                    <box size="0.2 .3 .1"/>
                </geometry>
            <origin rpy="0 0 1.54" xyz="0 0 0.05"/>
            <material name="white">
                <color rgba="1 1 1 1"/>
            </material>
        </visual>
        <collision>
            <geometry>
                    <box size="0.2 .3 0.1"/>
            </geometry>
        </collision>
        <xacro:default_inertial mass="10"/>
    </link>

    <link name="wheel_1">
        <visual>
                <geometry>
                    <cylinder length="${length_wheel}" radius="${radius_wheel}"/>
                </geometry>
            <origin rpy="0 0 0" xyz="0 0 0"/>
            <material name="black">
                <color rgba="0 0 0 1"/>
            </material>
        </visual>
        <collision>
            <geometry>
                    <cylinder length="${length_wheel}" radius="${radius_wheel}"/>
            </geometry>
        </collision>
        <xacro:default_inertial mass="1"/>
    </link>

    <link name="wheel_2">
        <visual>
                <geometry>
                    <cylinder length="${length_wheel}" radius="${radius_wheel}"/>
                </geometry>
            <origin rpy="0 0 0" xyz="0 0 0"/>
            <material name="black"/>
        </visual>
        <collision>
            <geometry>
                    <cylinder length="${length_wheel}" radius="${radius_wheel}"/>
            </geometry>
        </collision>
        <xacro:default_inertial mass="1"/>

    </link>

    <link name="wheel_3">
        <visual>
                <geometry>
                    <cylinder length="${length_wheel}" radius="${radius_wheel}"/>
                </geometry>

            <origin rpy="0 0 0" xyz="0 0 0"/>
            <material name="black"/>
        </visual>
        <collision>
            <geometry>
                    <cylinder length="${length_wheel}" radius="${radius_wheel}"/>
            </geometry>
        </collision>
        <xacro:default_inertial mass="1"/>
    </link>

    <link name="wheel_4">
        <visual>
                <geometry>
                    <cylinder length="${length_wheel}" radius="${radius_wheel}"/>
                </geometry>
            <origin rpy="0 0 0" xyz="0 0 0" />
            <material name="black"/>
        </visual>
        <collision>
            <geometry>
                    <cylinder length="${length_wheel}" radius="${radius_wheel}"/>
            </geometry>
        </collision>
        <xacro:default_inertial mass="1"/>

    </link>

     <joint name="base_to_wheel1" type="continuous">
       <parent link="base_link"/>
       <child link="wheel_1"/>
       <origin rpy="1.5707 0 0" xyz="0.1 0.15 0"/>
       <axis xyz="0 0 1" />
     </joint>

     <joint name="base_to_wheel2" type="continuous">
       <axis xyz="0 0 1" />
       <anchor xyz="0 0 0" />
       <limit effort="100" velocity="100" />
       <parent link="base_link"/>
       <child link="wheel_2"/>
       <origin rpy="1.5707 0 0" xyz="-0.1 0.15 0"/>
    </joint>

     <joint name="base_to_wheel3" type="continuous">
       <parent link="base_link"/>
       <axis xyz="0 0 1" />
       <child link="wheel_3"/>
       <origin rpy="1.5707 0 0" xyz="0.1 -0.15 0"/>
     </joint>

     <joint name="base_to_wheel4" type="continuous">
       <parent link="base_link"/>
       <axis xyz="0 0 1" />
       <child ...
(more)
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2016-03-31 15:31:59 -0500

lucasw gravatar image

updated 2016-04-02 06:59:06 -0500

Check out hokuyo.xacro

It may already be on your system in /opt/ros/jade/share/gazebo_plugins/test/multi_robot_scenario/xacro/laser/hokuyo.xacro if you have gazebo_ros_pkgs installed, and a launch file with example lasers worked on my jade system:

roslaunch gazebo_plugins multi_robot_scenario.launch

(I did get a few warnings about deprecated use of xacro)

edit flag offensive delete link more

Comments

thank you very much!

littlestar gravatar image littlestar  ( 2016-04-01 20:57:56 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2016-03-30 22:20:14 -0500

Seen: 1,124 times

Last updated: Apr 02 '16