Robotics StackExchange | Archived questions

Error in creating 2D global map of the Environment

Hi, I am going through the [slam_gmapping](http://wiki.ros.org/slam_gmapping/Tutorials/MappingFromLoggedData) I can move my P3AT in the environment through keyboard. I try to follow the steps mentioned in the tutorial but unable to generate the map.

step:1 terminal:1 rosparam set usesimtime true

step:2 terminal:2 rosrun gmapping slam_gmapping scan:=lms200 _odom frame:=odom

step:3 terminal:3 rosbag record -O mylaserdata.bag /lms200 /tf

INFO 1383223128.547387984: Subscribing to /lms200 INFO 1383223128.548429961: Subscribing to /tf INFO 1383223128.549742465: Recording to mylaserdata.bag.

WARN 1383223128.549933629: Less than 5GB of space free on disk with mylaserdata.bag.active.

After step 3 the mylaserdata.bag should be created.ATLAST BAG IS CREATED.

small success

step:4 terminal:4 rosbag play mylaserdata.bag

INFO 1383224702.381804366: Opening mylaserdata.bag

Waiting 0.2 seconds after advertising topics... done.

Hit space to toggle paused, or 's' to step. RUNNING Bag Time: 1383223567.472784 Duration: 438.600031 / 438.658882
Done.

command list

  1. Start-up roscore

  2. rosbag record -O mylaserdata.bag /lms200 /tf

INFO 1383223128.547387984: Subscribing to /lms200

INFO 1383223128.548429961: Subscribing to /tf

INFO 1383223128.549742465: Recording to mylaserdata.bag.

WARN 1383223128.549933629: Less than 5GB of space free on disk with mylaserdata.bag.active

  1. Start-up USARSim on the windows pc environment started in usarsim

  2. Start-up the ROS interface, roslaunch usarsim_inf usarsim.launch(robot placed in environment)

5.Run the tele-op keyboard which should allow you to drive the robot around.:

$ rosrun teleoptwistkeyboard teleoptwistkeyboard.py

6.$ rosrun gmapping slamgmapping scan:=lms200 _odomframe:=odom

  1. rosbag play mylaserdata.bag

successfully completed.

  1. rosrun mapserver mapsaver

o/p=MAP GENERATED BUT IT IS EMPTY:)

MAP.YAML FILE

image: map.pgm

resolution: 0.050000

origin: [-100.000000, -100.000000, 0.000000]

negate: 0

occupied_thresh: 0.65

free_thresh: 0.196

//////////END OF MAP.YAML///////////////////

  1. then I run

rosrun rviz rviz

image description

Now laser messages are properly published and the tf tree looks ok. But no transform from [/GrndTruth] to frame[/map] and no transform from [/base_GrndTruth to frame[/map].

Thanks in advance

Asked by RB on 2013-10-26 19:21:26 UTC

Comments

It seems that the problem is in opening bag file. First I would suggest you to just run rosbag play ..file.name and see if its running...Look here http://wiki.ros.org/rosbag/Commandline for more details. Try rosbag -fix parameter and see if theat changes or solves ur problem

Asked by sai on 2013-10-26 20:56:47 UTC

rosbag record -O mylaserdata.bag /lms200 /tf

It should generate the mylaserdata.bag and after moving the robot related information must be included here. Am I right?

Asked by RB on 2013-10-27 02:08:07 UTC

yes...still not solved?

Asked by sai on 2013-10-27 07:11:14 UTC

mylaserdata.bag has not been generated. Whats's the problem I can't figure out.

Asked by RB on 2013-10-27 18:43:46 UTC

rosbag record -a

Asked by sai on 2013-10-27 18:45:50 UTC

It will record all topics, I think. Will it help in creating the map?

Asked by RB on 2013-10-27 19:14:46 UTC

Yes, having all topics will be able to create map. you can map even without using the logged data, for that you must use the data from laser and wheel odom online.

Asked by sai on 2013-10-27 19:51:29 UTC

Hello Sai, can you mention the procedure what should be done after rosbag record -a. As you have said map can be obtained using online how it is possible. I have not found out any tutorial.

Asked by RB on 2013-10-27 22:02:08 UTC

Logging the data and creating a map are two different things. Better try one first and figure that out. The simplest should be to play the standard bagfile and check that gmapping works on that as a base line.

Asked by dornhege on 2013-10-28 06:40:03 UTC

dornhege, sir I have used a standard bag file downloaded from willow garage named as basic_localization_stage.bag. when I typed rosbag play basic_localization_stage.bag , then

[RUNNING] Bag Time: 168.554342 Duration: 133.954342 / 1239670987.745222 (snapshot) comes and it runs continuously in an increasing manner, I have kept my laptop on for almost 12 hours it reaches to 6 digit. That's why I stop there. So, can I conclude from this experiment that logging data should work in my experiment also? My rxgraph output includes the slam_gmapping node, so can I say that I am in correct path to get the global map.

Asked by RB on 2013-10-28 20:28:27 UTC

sai, I need a static 2d global map only. I will handle the remaining dynamic local map later. Can you help me regarding this?

Asked by RB on 2013-10-28 20:34:09 UTC

Were you getting a map in rviz? Then everything is fine. The logfile probably does only contain data for 1 or 2 minutes + some spurious time stamp that makes it appear longer.

Asked by dornhege on 2013-10-29 00:01:44 UTC

using slam_gmapping, you can generate static 2d map only. As told by dornhege, while running the logged data and gmapping node, open rviz and select /map frame and check if u can visualize a map.

Asked by sai on 2013-10-29 00:13:36 UTC

rosrun rviz rviz

/root/.rviz/display_config does not exist!

Global status error Fixed Frame Fixed Frame [/map] does not exist

INFO 1383153449.086235057: rviz revision number 1.8.17

INFO 1383153449.086334749: compiled against OGRE version 1.7.3 (Cthugha)

INFO 1383153450.434721571: Loading general config from /root/.rviz/config

INFO 1383153451.202554212: Texture for pass 0: creating with size 1 x 1

INFO 1383153451.202840286]: Texture for pass 1: creating with size 1 x 1

INFO 1383153577.610798599: Setting goal: Frame:/map, Position(2.493, -1.564, 0.000),

Orientation(0.000, 0.000, 0.829, 0.559) = Angle: 1.955

INFO 1383153587.704759103: Saving general config to /root/.rviz/config

Asked by RB on 2013-10-29 19:47:11 UTC

Please edit your original post and append to that. Those things are unreadable as comments. Always state exactly which commands you executed in total and what you observed/expected as a result.

Asked by dornhege on 2013-10-30 02:25:25 UTC

Sir I have changed question and put rviz output as well.

Asked by RB on 2013-10-30 03:35:02 UTC

Did you add a map display and set the map topic?

Asked by dornhege on 2013-10-30 03:44:23 UTC

try adding --clock parameter when running a bag: rosbag play --clock filename.bag . it will make row act as though it is running at the time bag was created.

Asked by grzebyk on 2013-10-30 03:57:42 UTC

dornhege, sir I try to add a ,map , then status warning no map received. I think I have not properly closed the bag file, so in the terminal it advised me to use rosbag reindex. How and from where rviz load the map? If we set the goal in the loaded map, then will it be reflected in the original map file?

Asked by RB on 2013-10-30 04:00:41 UTC

grzebyk, thanks for reply. first of all how to stop a bag file from storing logged transform data?. Why the filename come as mylaserdata.bag.active.

Asked by RB on 2013-10-30 04:04:44 UTC

Are you recording anything? You shouldn't be recording. Please state the complete and exact commands and actions that you do to start the system.

Asked by dornhege on 2013-10-30 04:12:44 UTC

just hit ctrl + c to stop recording.

Asked by grzebyk on 2013-10-30 04:21:37 UTC

dornhege, sir I have added command list in the question itself. rviz gives me .png file but it is totally black. grzebyk thanks, it works.

Asked by RB on 2013-10-30 04:33:03 UTC

After you started gmapping don't do any of the other steps, but verify with rviz that you are actually getting usable data. If there is no map, start checking input data, e.g. laser and tf. If that is there, check gmapping output.

Asked by dornhege on 2013-10-30 06:10:18 UTC

dornhege, sir. no map (status warning) when I try to add map. Then when I add TF, it looks ok, i.e tree is formed correctly. But when I add LaserScan, then (status warning) Topic: no messages recieved.

Asked by RB on 2013-10-30 08:00:18 UTC

dornhege, sir In rviz window, there is nothing called lms200. How to check gmapping output through rviz?

Asked by RB on 2013-10-31 00:50:10 UTC

Answers

Commands to build a map using slam_gmapping from logged bag $roscore

$rosparam set use_sim_time true

$rosrun tf static_transform_publisher 0 0 0 0 0 0 base_link laser 100

$rosbag play --clock

For slam_gmapping you need tf and laserScan. after above commands, open a new terminal then execute $rostopic list

then look whether tf and laserScan are being published. if you see /scan then run $rosrun gmapping slam_gmapping scan:=scan

if you see /base_scan then run $rosrun gmapping slam_gmapping scan:=base_scan

to see map in rviz run $rosrun rviz rviz

then add a map then put topic /map

to save a map run $rosrun map_server map_saver -f map1

it will save a map named map1.pgm in current directory.

Let me know whether it works or not.

Asked by cognitiveRobot on 2013-11-11 15:25:38 UTC

Comments

/scan or /base_scan should be visible in rostopic list? I don't understand laser 100? I have lms200 mounted on P3AT. @cognitiveRobot thanks for you reply. You can look here. http://answers.ros.org/question/96451/suspected-bug-in-usarsimros/. I have given details of the question with screenshot.

Asked by RB on 2013-11-11 18:48:01 UTC

I also used sick lms200. And above methods work for me. You also can check ur logged bag by using rqt. $rqt then run plugin bag then open your bag. then you will be able what you have in your bag. you also can send me your bag at cognitiverobot@gmail.com. i can have a look.

Asked by cognitiveRobot on 2013-11-11 21:45:19 UTC

I get an empty map, now. I will send my bag at your mail id @cognitiveRobot.

Asked by RB on 2013-11-13 18:25:12 UTC

Brian, I checked ur bag which contains /lms200 and /tf. but slam_gammping subscribes to /scan ( type sensor_msgs/LaserScan) and /tf. u can check http://wiki.ros.org/gmapping?distro=groovy What you have to do now is record ur bag by $rosbag record -o mylaserdata.bag /scan /tf. let me know ur progess.

Asked by cognitiveRobot on 2013-11-14 18:37:04 UTC

@cognitiveRobot after rosbag play, we should run map_server utility. Again one more thing my map size is almost 15.3 MB. Why we need to type static_transform_publisher? Thanks in advance.

Asked by RB on 2013-11-14 18:37:15 UTC

rosrun gmapping slam_gmapping scan:=lms200 _odom_frame:=odom; in this command also we need to change lms200 to scan ? @cognitiveRobot

Asked by RB on 2013-11-14 18:44:33 UTC

Yes. to save ur map u have to run map_server. I still don't know why static_transform_publisher. when i do without that i get warning as "Message from [/play_1384494508191805188] has a non-fully-qualified frame_id [laser]". I'm looking for that answer too. but it works as i answered above.

Asked by cognitiveRobot on 2013-11-14 18:46:29 UTC

yes. that's right. new slam_gmapping command will be $rosrun gmapping slam_gmapping scan:=scan

Asked by cognitiveRobot on 2013-11-14 18:52:42 UTC

now initial problem comes [ INFO] [1384582415.808053836]: Waiting for the map.

Asked by RB on 2013-11-14 19:21:09 UTC

I think scan can be base_scan or lms200 it depends on the robot, I think http://wiki.ros.org/slam_gmapping/Tutorials/MappingFromLoggedData, gives for PR2

Asked by RB on 2013-11-14 19:28:08 UTC

ok. can you send ur new bag. i will check again.

Asked by cognitiveRobot on 2013-11-14 20:02:06 UTC

I am using ROS Fuerte and USARSim simulator. Are you using Gazebo-ROS.

Asked by RB on 2013-11-15 00:05:07 UTC

No. I use groovy, tele-operate by rosAria and erratic-teleoperate package for p3dx real robot.

Asked by cognitiveRobot on 2013-11-17 20:53:19 UTC

Are you able to generate the map from my inial bag file?

Asked by RB on 2013-11-18 19:07:04 UTC

nope. because slam_gmapping can't subscribe /lms200.

Asked by cognitiveRobot on 2013-11-18 19:20:23 UTC

Thank you, @cognitiveRobot for helping me in. Now I get the map, it's because of simulator.

Asked by RB on 2013-11-21 06:20:34 UTC

That's great Brian. Keep up ur good work.

Asked by cognitiveRobot on 2013-11-21 15:18:17 UTC

Error lies in the USARSim simulator (Canvas.uc). Use UDK-2013-07 and USARSim-current, it will lead you to get the map of the environment.

Asked by RB on 2013-11-21 06:23:25 UTC

Comments