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

Mapping with kinect instead of Hokuyo laser

asked 2014-05-06 06:18:57 -0500

Eman gravatar image

updated 2014-05-06 17:24:12 -0500

  • I had a 6 wheeled robot.
  • I made mapping using Hokuyo laser and it worked successfully on rviz as shownimage description
  • Unfortunately I don't have the Hokuyo laser. I have a kinect. so,I want to make mapping using kinect sensor instead of the Hokuyo laser.
  • The most powerful advantage of ros is that being able to reuse code.
  • There are famous robots that uses kinect like turtlebot,corobot,pioneer and pi robot.

So,my question is:-

How to add kinect to my model to appear in rviz and gazebo?? What should I modify in my urdf model and .xacro file?? How can I reuse the code of a famous robot for adding kinect to my model and make mapping with kinect ?? Any suggestions ,please??

  • This is my_robot.xacro file

<?xml version="1.0"?>

<robot xmlns:xacro="http://www.ros.org/wiki/xacro" 
    xmlns:sensor="http://playerstage.sourceforge.net/gazebo/xmlschema/#sensor"
        xmlns:controller="http://playerstage.sourceforge.net/gazebo/xmlschema/#controller"
        xmlns:interface="http://playerstage.sourceforge.net/gazebo/xmlschema/#interface"
    name="robot1_xacro">


    <include filename="$(find erratic_description)/urdf/erratic_hokuyo_laser.xacro" />

        <!-- BASE LASER ATTACHMENT -->
        <erratic_hokuyo_laser parent="base_link">
                <origin xyz="0.18 0 0.11" rpy="0 0 0" />
        </erratic_hokuyo_laser>

    <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>
        <xacro:default_inertial mass="0.0001"/>
    </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.22 0.380 0.085"/>
                </geometry>
            <origin rpy="0 0 1.5707" xyz="0 0 0.05"/>
            <material name="blue">
                <color rgba="0 0 .8 1"/>
            </material>
        </visual>
        <collision>
            <geometry>
                    <box size="0.22 0.380 0.085"/>
            </geometry>
        </collision>
        <xacro:default_inertial mass="10"/>
    </link>

    <link name="right_wheel_1">
        <visual>
                <geometry>
                    <cylinder length="${length_wheel}" radius="${radius_wheel}"/>
                </geometry>
            <!-- <origin rpy="0 1.57075 0" xyz="-0.085 0.15 -0.25"/> -->
            <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="right_wheel_2">
        <visual>
                <geometry>
                    <cylinder length="${length_wheel}" radius="${radius_wheel}"/>
                </geometry>
            <!-- <origin rpy="0 1.57075 0" xyz="-0.085 0 -0.25"/> -->
            <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="right_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 ...
(more)
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2014-05-06 13:09:06 -0500

updated 2014-05-06 13:12:39 -0500

Hey, I dont have your robot's urdf model file so i could't test the solution, I can guide you with basic hack (hope it ll help), any ways Here's the trick,

In your urdf model file, remove <sensor> //hokuyu stuff </sensor> (now here we should put kinnect stuff,and that can be taken from turtlebot urdf) ( b4 that note down the transformations of hokuyu, i.e., xyr rpy of sensor position)

Locate turtlebot_description folder in your system (easiest way is : $ roscd turtelbot_description), in folder 'urdf/sensor' you will find kinect.urdf.xacro file. copy it to package folder. also locate these files 1) turtlebot_gazebo.urdf.xacro 2) turtlebot_properties.urdf.xacro(mostly in parent directory) and copy it to same package folder (as we dont want to mess up original files).

Changes: in "kinnect" file first change first two <include> files. :

<xacro:include filename="$(find your_package)/turtlebot_gazebo.urdf.xacro"/> <xacro:include filename="$(find your_package)/turtlebot_properties.urdf.xacro"/>

in turtlebot_properties.urdf.xacro file : <property name="cam_px" value="-0.087"/> <property name="cam_py" value="-0.0125"/> <property name="cam_pz" value="0.2870"/> <property name="cam_or" value="0"/> <property name="cam_op" value="0"/> <property name="cam_oy" value="0"/> (sensor position)
Here write corresponding x,y,z value from hokuyu part.

now in your URDF file,

write these lines (instead of older <sensor> part) include our "kinnect" file:

<xacro:include filename="$(find your_package)/kinect.urdf.xacro"/>

<sensor_kinect parent="your_base_link"/>

"Most probably" this should work, as I havent tested it, I cant be sure that this will be compiled without any error. But if you receive any error then, (you know the basic trick so). just track down missing file or parameter in these file and compare it with turtlebot urdf model.

For your second question, your code will work without making any changes(hopefully) if not then list down all the topics published, see where the scan or base_scan has been published and make appropriate changes in your launch file. (you can use remap function to remap one topic to another one).

Hope this will help. Sudeep

edit flag offensive delete link more

Comments

Thanks a lot for your help. I will attach my_robot file.xacro to the original question to make it more obvious. I will try to follow these steps and I hope that it will work successfully.

Eman gravatar image Eman  ( 2014-05-06 16:56:02 -0500 )edit

@Sudeep Fadadu Excuse me,When I tried that,it doesn't work. So,I tried to follow the same concept of adding laser and look at the files of my package which indicate any thing that related to the hokuyo laser to replace it with things that related to kinect. In the source file of my package there is laser.cpp which represented a f laser node in the bin file of the package after building it. So,How can I make a kinect.cpp file or how can I modify the laser.cpp file to make it work with kinect. I searched the turtlebot package for this kinect.cpp in its src file,but there is nothing.

Eman gravatar image Eman  ( 2014-05-10 10:23:40 -0500 )edit
1

@Eman , Can you please provide more information about the error. If you are getting topic /image/depth/raw or something like that then, open a new terminal and write rosrun depthimage_to_laserscan depthimage_to_laserscan image:=/camera/depth/image_raw ..(it will convert kinnect cloud data to laser) and also remove hokuyu laser node from launch file !

Sudeep gravatar image Sudeep  ( 2014-05-10 11:07:03 -0500 )edit

After modifying the package ,When I typed the command that used to run mapping at rviz I had the following error Invalid tag: Cannot load command parameter [robot_description]: command [/opt/ros/fuerte/stacks/xacro/xacro.py /home/eman/mashro3/wild_thumper60/urdf/robot1_base_04.xacro] returned with code [1]. Param xml is

Eman gravatar image Eman  ( 2014-05-11 05:25:31 -0500 )edit
3

I believe, this error is due to some missing files or mismatched parameter. can you please check few lines above this error. some description about error like missing file or invalid parameter must be there!

Sudeep gravatar image Sudeep  ( 2014-05-11 08:10:35 -0500 )edit

Thanks for your help.There was written above the error that ( invalid parameter "parent" while expanding macro "turtlebot_kinect") . When I changed the name of macro " turtlebot_kinect ", rviz and gazebo have been opened.But in Gazebo, the 6 wheeled robot appeared without the kinect. In rviz,there is no mapping .

Eman gravatar image Eman  ( 2014-05-11 09:08:07 -0500 )edit
1

Ohh Okay! Have you tried other solutions (I just mailed you some!)? Please check published topics : /image/depth or something like that. are you getting these topics ?

Sudeep gravatar image Sudeep  ( 2014-05-11 09:37:13 -0500 )edit
1

Kinect gives point cloud data, so mapping wont work till you convert it into laser scan

Sudeep gravatar image Sudeep  ( 2014-05-11 10:04:10 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2014-05-06 06:18:57 -0500

Seen: 1,874 times

Last updated: May 06 '14