0
$\begingroup$

Rosanswers logo

Hello I am trying to get a map of the area with a differential drive mobile robot, for which the following are the steps followed.

  1. Open the kinect with openini using "roslaunch openni_launch openni.launch".
    
  2. Change the pointcloud to the laser scan using "rosrun depthimage_to_laserscan depthimage_to_laserscan image:=/camera/depth/image_raw", after step-2 I am able to see the "laser scan" in the RVIz properly.
    
  3. Running the gmapping with "rosrun gmapping slam_gmapping scan:=/scan tf:=/odom" , I am running the node which publishes the odom (the odometry data from the real robot).

  4. Then open rviz with "rosrun rviz rviz".

But in RVIZ I am unable to see any mapping.

Questions:

  1. The procedure which I follwed is correct or Is there something I am missing..?

  2. For publishing the odo data I am using the example from the following link: http://wiki.ros.org/navigation/Tutorials/RobotSetup/Odom with the following changes:

    • Added a callback, so as to subscribe to the incoming data from the robot.
    • Changed the velocities to suit for differential drive robot.
    • Small change in calculation of the robot position based on odo.

But the odom published from this has many fields:

    nav_msgs::Odometry odom;
    odom.header.stamp = current_time;
    odom.header.frame_id = "odom";

    //set the position
    odom.pose.pose.position.x = x;
    odom.pose.pose.position.y = y;
    odom.pose.pose.position.z = 0.0;
    odom.pose.pose.orientation = odom_quat;

    //set the velocity
    odom.child_frame_id = "base_link";
    odom.twist.twist.linear.x = vx;
    odom.twist.twist.linear.y = vy;
    odom.twist.twist.angular.z = vth;

which one I should give to the gmapping...?

Please find the rqt_graph here image description

Please find the frames.pdf here image description

Many thanks in advance


Originally posted by sumanth on ROS Answers with karma: 86 on 2014-08-13

Post score: 1


Original comments

Comment by bvbdort on 2014-08-13:
share your rqt_graph here in question

Comment by sumanth on 2014-08-13:
I am unable to attach the rqt_graph here because of lack of points!!

Comment by bvbdort on 2014-08-13:
i did upvote, try now if its possible. or use http://imgur.com/

Comment by sumanth on 2014-08-13:
I have modified the question

Comment by bvbdort on 2014-08-13:
you can see from image that odom is not published . publish Odom and start gmapping like "rosrun gmapping slam_gmapping scan:=scan _odom_frame:=/odom"

Comment by sumanth on 2014-08-13:
Its getting published, I have reuploaded the rqt_graph. but how to link the odom to the gmapping...?

Comment by bvbdort on 2014-08-13:
rosrun gmapping slam_gmapping scan:=scan odom_frame:=/odom

Comment by sumanth on 2014-08-13:
No its not geeting linked, you can check the rqt_graph

Comment by bvbdort on 2014-08-13:
try rosrun gmapping slam_gmapping scan:=scan odom_frame:=/odom (i removed underscrore _ )

Comment by sumanth on 2014-08-13:
Still NO luck.

Comment by sumanth on 2014-08-13:
In Rviz, what should I select in fixed frame and what should I add to see the mapping in Rviz.

Comment by sumanth on 2014-08-13:
But Gmapping documentation say

<

the frame attached to incoming scans> → base_link

    usually a fixed value, broadcast periodically by a robot_state_publisher, or a tf static_transform_publisher. 

base_link → odom

    usually provided by the odometry system (e.g., the driver for the mobile base)

Comment by sumanth on 2014-08-13:
how to give these tf's

Comment by bvbdort on 2014-08-13:
in RVIZ select map as frame in global option; check the laser frame id by "rostopic echo /scan " and add in launch file.

Comment by sumanth on 2014-08-13:
I can see data when I echo the topic /scan, even launched the file with static transform. But still I am unable to see anything on the RVIZ.

Comment by sumanth on 2014-08-13:
same old problem topic /odom is not getting linked to the gmapping.

Comment by bvbdort on 2014-08-13:
rosrun tf view_frames , share the frames.pdf picture. wht is the frame id ur getting for laser scan ?

Comment by sumanth on 2014-08-14:
@bvbdort: I have modified the question with frames.pdf.

Comment by bvbdort on 2014-08-14:
i cannt see the static publisher in frames.odf, what is ur laser scan frame id ? i guess it is camera_depth_optical_frame. so run

Comment by sumanth on 2014-08-14:
I have followed ahendrix answer and changed the scanner link name to camera_link in the URDF file, Then it staretd to map.

Comment by sumanth on 2014-08-14:
so now I need to change in the launch file as

<node pkg="tf" type="static_transform_publisher" name="base_to_laser" args="0 0 0 0 0 0 base_link camera_link 100"/>

Is this correct..???

Comment by bvbdort on 2014-08-14:
yes add above line in your launch file.

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

As per the gmapping wiki page, gmapping only subscribes to tf, not to /odom.

You should make sure that your odometry node is publishing tf correctly (from your tf tree, it looks like it is), and that the frame parameters to gmapping are correct (from the wiki page, it looks like the defaults are correct for your system).

I suspect the problem here is that your laser scans aren't published in the correct frame; you can confirm by looking at the frame_id in the header of your published laser scans.

Notice how there are two disconnected trees in your TF view - one for most of your frames (map, odom, base_link, etc), and a separate tree with camera_link and the other Kinect frames. I suspect you just need to rename the scanner frame to camera_link in your URDF to connect the two trees.


Originally posted by ahendrix with karma: 47576 on 2014-08-14

This answer was ACCEPTED on the original site

Post score: 2


Original comments

Comment by sumanth on 2014-08-14:
Oh super, Now its working, I can see the mapping in rviz, but some times I get

terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc
Aborted (core dumped)

Why this happens..?

how to give map created here to navigation stack..? or how to store map?

Comment by ahendrix on 2014-08-14:
I'm not sure what's crashing or why; that's probably a separate question. You should be able to save your map with:

rosrun map_server map_saver

Comment by sumanth on 2014-08-14:
Many Thanks.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.