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

Adding a Kinect to my Gazebo simulation

asked 2019-07-19 00:15:56 -0600

logan.ydid gravatar image

updated 2019-07-24 22:47:51 -0600

Hello All,

I have a URDF model that is working in gazebo that i copied from the book Programming Robots with ROS. I would like to add a Kinect sensor to this model so i can simulate my robot but i cant for the life of me figure out how do this. Most resources that i found are like this example. which says that i should use the model found in the turtlebot_description folder but i am unsure what files i need and how exactly to import them into my URDF. I found this tutorial which edits the kinect model found in the gazebo models folder, and this worked perfectly so i know its possible. I think what i need is for someone to really spell it out for me what i need to add to my urdf and my launch file to add a kinect.

Here is my URDF I would like to replace the hokuyo_link with a Kinect:

<?xml version="1.0"?>
<robot name="tortoisebot">
    <link name="base_link">
        <visual>
            <geometry>
                <box size="0.6 0.3 0.3"/>
            </geometry>
            <material name="silver">
                <color rgba="0.75 0.75 0.75 1"/>
            </material>
        </visual>
        <collision>
            <geometry>
                <box size="0.6 0.3 0.3"/>
            </geometry>
        </collision>
        <inertial>
            <mass value="1.0"/>
            <inertia ixx="0.015" iyy="0.0375" izz="0.0375" ixy="0" ixz="0" iyz="0"/>
        </inertial>
    </link>

    <link name="front_caster">
        <visual>
            <geometry>
                <box size="0.1 0.1 0.3"/>
            </geometry>
            <material name="silver"/>
        </visual>
        <collision>
            <geometry>
                <box size="0.1 0.1 0.3"/>
            </geometry>
        </collision>
        <inertial>
            <mass value="0.1"/>
            <inertia ixx="0.00083" iyy="0.00083" izz="0.000167" ixy="0" ixz="0" iyz="0"/>
        </inertial>
    </link>
    <joint name="front_caster_joint" type="continuous">
        <axis xyz="0 0 1"/>
        <parent link="base_link"/>
        <child link="front_caster" />
        <origin rpy="0 0 0" xyz="0.3 0 0" />
    </joint>

    <link name="front_wheel">
        <visual>
            <geometry>
                <cylinder length="0.05" radius="0.035"/>
            </geometry>
            <material name="black" />
        </visual>
        <collision>
            <geometry>
                <cylinder length="0.05" radius="0.035"/>
            </geometry>
        </collision>
        <inertial>
            <mass value="0.1"/>
            <inertia ixx="5.1458e-5" iyy="5.1458e-5" izz="6.125e-5" ixy="0" ixz="0" iyz="0"/>
        </inertial>
    </link>


    <joint name="front_wheel_joint" type="continuous">
        <axis xyz="0 0 1"/>
        <parent link="front_caster"/>
        <child link="front_wheel"/>
        <origin rpy="-1.5708 0 0" xyz="0.05 0 -0.15"/>
    </joint>

        <link name="right_wheel">
                <visual>
                        <geometry>
                                <cylinder length="0.05" radius="0.035"/>
                        </geometry>
                        <material name="black" />
                </visual>
        <collision>
            <geometry>
                                <cylinder length="0.05" radius="0.035"/>
            </geometry>
        </collision>
        <inertial>
            <mass value="0.1"/>
            <inertia ixx="5.1458e-5" iyy="5.1458e-5" izz="6.125e-5" ixy="0" ixz="0" iyz ...
(more)
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2019-07-19 07:12:16 -0600

Solrac3589 gravatar image

I am not quite sure if I am missing something, but seeing for the moment nobody is responding i will try to help.

I think you should add the sensor more or less like that:

<gazebo reference="world">
    <sensor name="world" type="depth">
        <!-- openni plugin has the x pointing towards the scene, so rotate to have z -->
        <pose frame="world">0.0 0.0 1.0 0.0 -1.5708 1.5708</pose>
        <camera>
            <horizontal_fov>0.74839718</horizontal_fov>
            <image>
                <width>1280</width>
                <height>1024</height>
                <format>L_INT8</format>
            </image>
            <clip>
                <near>0.1</near>
                <far>10.0</far>
            </clip>
            <noise>
                <type>gaussian</type>
                <mean>0.5</mean>
                <stddev>1.0</stddev>
            </noise>
        </camera>
        <plugin name="kinect_plugin" filename="libgazebo_ros_openni_kinect.so">
            <baseline>0.1</baseline>
            <alwaysOn>true</alwaysOn>
            <!-- Keep this zero, update_rate in the parent <sensor> tag
            will control the frame rate. -->
            <updateRate>0.0</updateRate>
            <cameraName>kinect_test</cameraName>
            <imageTopicName>/3d_image/image_raw</imageTopicName>
            <cameraInfoTopicName>/3d_image/camera_info</cameraInfoTopicName>
            <depthImageTopicName>/3d_image/image_raw_depth</depthImageTopicName>
            <depthImageInfoTopicName>/3d_image/camera_info</depthImageInfoTopicName>
            <pointCloudTopicName>/3d_image/3d_cloud</pointCloudTopicName>
            <frameName>kinect_body</frameName>
            <pointCloudCutoff>0.5</pointCloudCutoff>
            <pointCloudCutoffMax>2.0</pointCloudCutoffMax>
        </plugin>
        <always_on>true</always_on>
        <update_rate>1.0</update_rate>
    </sensor>
</gazebo>

Hope at least gives you more clues from where to follow!

edit flag offensive delete link more

Comments

Yay! Thank you this works! Now I'm just having trouble with the orientation of the sensor. In gazebo if I place something in front of the robot it appears above the robot rotated 90 degrees about the z access. I've tried adjusting the pose tag after the first comment in your code but it didn't seem to make a difference. I've also tried changing the orientation in the joint definition but that just changes the orientation of the sensor in gazebo but not in rviz. Any suggestions?

logan.ydid gravatar image logan.ydid  ( 2019-07-22 20:34:37 -0600 )edit

Maybe my error adding as a main frame "world". Can you try to add as a main frame a link instead of a joint? I have checked my code and i have that.

Anyway I am not quite sure that this is the solution, but lets try xD

Solrac3589 gravatar image Solrac3589  ( 2019-07-23 04:42:37 -0600 )edit

Haha I thought that seemed weird ๐Ÿ˜†. So do you mean to do something like this?<pose frame="link_name">0.0 0.0 1.0 0.0 -1.5708 1.5708</pose>

logan.ydid gravatar image logan.ydid  ( 2019-07-24 02:05:33 -0600 )edit

Yes! That's what I wanted to say! Any news?

Solrac3589 gravatar image Solrac3589  ( 2019-07-24 09:25:29 -0600 )edit

Hmmm unfortunately i still have been unable to get it to work. i have tried changing the link name to hokuyo_link just like my laser scanner from before and to base_link but to no avail. i have also tried changing the name of the camera in the plugin to match the sensor name but that didnt change anything either. when i look at the camera view from rviz it looks like everything is in the correct orientation but the point cloud still shows up above the robot. If it helps i put the urdf i am currently using as an update to my post. thank you so much for your help!

logan.ydid gravatar image logan.ydid  ( 2019-07-24 22:45:48 -0600 )edit

@Solrac3589 Thank you for your help, you've been immensely helpful! I've decided to start another question about orientation in Rviz. it can be found here: https://answers.ros.org/question/329409/point-cloud-in-wrong-position-relative-to-robot/

logan.ydid gravatar image logan.ydid  ( 2019-07-27 02:21:37 -0600 )edit

Question Tools

3 followers

Stats

Asked: 2019-07-19 00:15:56 -0600

Seen: 4,122 times

Last updated: Jul 24 '19