0
$\begingroup$

Rosanswers logo

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!


Originally posted by anamcarvalho on ROS Answers with karma: 123 on 2014-08-21

Post score: 0


Original comments

Comment by 130s on 2014-08-24:
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.

Comment by anamcarvalho on 2014-08-24:
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!

Comment by dornhege on 2014-08-25:
Please review the http://wiki.ros.org/Support guidelines. People here usually help as soon as they can on their own time.

$\endgroup$

3 Answers 3

0
$\begingroup$

Rosanswers logo

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

Is that the info you need.

Rgs

Mark


Originally posted by MarkyMark2012 with karma: 1834 on 2014-08-22

This answer was ACCEPTED on the original site

Post score: 2


Original comments

Comment by anamcarvalho on 2014-08-23:
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!

$\endgroup$
0
$\begingroup$

Rosanswers logo

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


Originally posted by dornhege with karma: 31395 on 2014-08-21

This answer was NOT ACCEPTED on the original site

Post score: 1


Original comments

Comment by Malefitz on 2014-08-22:
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.

Comment by anamcarvalho on 2014-08-22:
@Malefitz yes, that is exactly what I need!

Comment by bvbdort on 2014-08-24:
map built from last scan is nothing but last laser scan with position corrected from scan matching.

Comment by anamcarvalho on 2014-08-24:
Hi @bvbdort! I know that, I just don't know how to do that! That's my question :)

Comment by bvbdort on 2014-08-24:
it is not possible from gmapping package by changing parameters, you need to modify code. ScanMatcher::registerScan method takes laser scan and corrected position .

$\endgroup$
0
$\begingroup$

Rosanswers logo

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!


Originally posted by Malefitz with karma: 136 on 2014-08-28

This answer was NOT ACCEPTED on the original site

Post score: 1


Original comments

Comment by anamcarvalho on 2014-08-28:
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?

Comment by Malefitz on 2014-08-28:
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.

$\endgroup$

Your Answer

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