Ask Your Question
0

Gmapping - just the last scan mapped

asked 2014-08-21 10:48:18 -0500

anamcarvalho gravatar image

updated 2014-08-24 08:22:29 -0500

130s gravatar image

Hi everyone,

I am writing a code to do obstacle motion detection... To do so I need the current map of the environment, save it in time t, and compare this map with the one obtained in the next iteration...

Gmapping provides a global map, a map that contains every information scanned by the laser! I want a map that just represents the last scan! I need it to update the map, but to only show the last scan!

How can I solve this? Is possible to change something in the Gmapping parameters? Is there any package that does something similar?

Thank you!

edit retag flag offensive close merge delete

Comments

1

From the title I removed "urgent", which can raise an attention to maintainers for the need of immediate work -- this ticket looks like not the case.

130s gravatar image 130s  ( 2014-08-24 08:24:03 -0500 )edit

Hi! I said it is urgent because it actually is urgent! I have my thesis to be delivered very soon and I need a correct answer ASAP!

anamcarvalho gravatar image anamcarvalho  ( 2014-08-24 10:27:49 -0500 )edit
1

Please review the http://wiki.ros.org/Support guidelines. People here usually help as soon as they can on their own time.

dornhege gravatar image dornhege  ( 2014-08-25 06:38:11 -0500 )edit

3 Answers

Sort by ยป oldest newest most voted
2

answered 2014-08-22 09:25:51 -0500

MarkyMark2012 gravatar image

I would use a 2D costmap http://wiki.ros.org/costmap_2d

Is that the info you need.

Rgs

Mark

edit flag offensive delete link more

Comments

I want a map that just represents the last scan. Gmapping provides a full map with all the scans ever perceived registered into one big map, I just need the map of the last scan! I need it to update the map, but to only show the last scan!

anamcarvalho gravatar image anamcarvalho  ( 2014-08-23 13:34:41 -0500 )edit
1

answered 2014-08-21 10:56:19 -0500

dornhege gravatar image

Just subscribe the map topic and save incoming maps. Data might be huge though.

edit flag offensive delete link more

Comments

1

I think he meant that he wants a map just built from the last scan callback. Gmapping provides a full map with all the scans ever percieved registered into one big map. I don't know how to solve this problem, too.

Malefitz gravatar image Malefitz  ( 2014-08-22 09:08:13 -0500 )edit

@Malefitz yes, that is exactly what I need!

anamcarvalho gravatar image anamcarvalho  ( 2014-08-22 13:27:45 -0500 )edit

map built from last scan is nothing but last laser scan with position corrected from scan matching.

bvbdort gravatar image bvbdort  ( 2014-08-24 08:05:34 -0500 )edit

Hi @bvbdort! I know that, I just don't know how to do that! That's my question :)

anamcarvalho gravatar image anamcarvalho  ( 2014-08-24 10:29:13 -0500 )edit
1

it is not possible from gmapping package by changing parameters, you need to modify code. ScanMatcher::registerScan method takes laser scan and corrected position .

bvbdort gravatar image bvbdort  ( 2014-08-24 11:36:58 -0500 )edit
1

answered 2014-08-28 05:48:55 -0500

Malefitz gravatar image

updated 2014-08-28 06:34:16 -0500

Ok, I think I figured it out. In the slam_gmapping.cpp file of the ROS wrapper go to line 592ff. There you see this code:

    ROS_DEBUG("Trajectory tree:");
    for(GMapping::GridSlamProcessor::TNode* n = best.node;
        n;
        n = n->parent)
    {
        ROS_DEBUG(" %.3f %.3f %.3f",
                  n->pose.x,
                  n->pose.y,
                  n->pose.theta);
        if(!n->reading)
        {
            ROS_DEBUG("Reading is NULL");
            continue;
        }
        matcher.invalidateActiveArea();
        matcher.computeActiveArea(smap, n->pose, &((*n->reading)[0]));
        matcher.registerScan(smap, n->pose, &((*n->reading)[0]));
    }

Just after the line matcher.registerScan(smap, n->pose, &((*n->reading)[0])); add a single break;. That way only the last node in the trajectory tree that tracks your robots position is considered when building the map and not the whole trajectory. That should do the trick.

You could also add a counter and do the break after n loops, that way only the last n readings build the map.

Let me know if it worked or if you stumbled into any problem with this approach!

edit flag offensive delete link more

Comments

Thank you so much Malefitz, i'll try your approach and give you feedback! One thing: registerScan isn't a function? Shouldn't I put the break inside that function or something?

anamcarvalho gravatar image anamcarvalho  ( 2014-08-28 07:36:30 -0500 )edit
1

No, just put it after the call on the line I showed you. The registerScan method is called on multiple spots in the gmapping package (not just in the ros wrapper) and is needed to keep track of your robot pose. So you shouldn't mess with it too much ;) You are welcome.

Malefitz gravatar image Malefitz  ( 2014-08-28 09:03:00 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2014-08-21 10:48:18 -0500

Seen: 363 times

Last updated: Aug 28 '14