Odometry for gmapping


I’m using ardupilot in combination with ros (mavros) for my holonomic boat.
I want to make a map of a pool using gmapping, so I need some kind of odometry (and a laser which I have).
In the mavros topics, there is a topic mavros/local_position/odom, but this output is pretty random.
Is this odom based on the fusion of imu and gps, or is it just noise?

So my question is: how do I get reliable odometry with an imu and gps?

Thanks in advance!


Yes it is fused position from imu and GPS, but it shouldn’t be random unless you got positionning problem as it is the main source of position for all navigation on ArduPilot

Thanks for the answer!

If I walk 100 meters in a straight line, my mavros/local_position/odom has a pose around 0 and a twist of ~1 m/s.
The frame_ID of the odom is map and the child_frame_id is base_link.
I have a working GPS and working IMU.
Do you have any idea what the cause of this is? And how I can solve this?

May I suggest you to try hector_slam?
I have succefully mapping with my boat using hector slam with just lidar.
Then I moved to google cartographer with lidar and imu.

@khancyr are you sure odom msg is coming from GPS and IMU? I’ve tested it and it shows no change when I move my test bed…

Thanks for the suggestion!
Maybe I’ll try this!
I still need the odometry for other packages like amcl and navigation though.
But now at least I can get a map.

@khancyr, I can confirm that. Also no change in mavros/local_position/pose if I move the sensors. Maybe something is wrong with some parameters?

We are working on somthing similar.
I need to navigate my boat with ROS. And there are a lot of package that use odometry. So build a pseudo odometry msg from IMU and GPS would be very interesting. It will not have the same noise figure as wheel encoders, but at least we will have something to work with.

Yes, maybe, we can help eachother!
I’ve thought about using robot_localization to convert imu data to odometry data and then use gmapping to build a map en simultaniously localize in it. That didn’t workout though :frowning:
Now my plan is to get a map using gmapping (or hector_slam), then use the map, odometry and the lidar data to localize with amcl. Then if I’m incredibly lucky so I have some time left, I can use some packages for navigation.

I will check again but this topic should have the output from the ekf aka the fused data from imu +gps + other position system (wheel odometry, beacon)

Yeah, that sounds logical and I hope you’re right.
Maybe the ekf is looking for information of the wheel odometry and if it can’t find it, it gives wrong values.
So maybe there is a parameter to turn of wheel odometry.


I just check that data from local_position/odom are correct . Just check that you get GPS lock and that you have a non-zero STREAM_POSITION rate ! (just set the rate in the paramter or use something like rosrun mavros mavsys rate --all 20)

Ok, I will check it next this weekend.
BTW, what is the default value of STREAM_POSITION rate?

Hey Khancyr,

Can you describe where I can find this parameter?
I’m starting to think that my mavros package isn’t complete.
If I try to run your suggestion, I get the error below.

It is in main MAVROS package

Check that you source you ROS environement

I have sourced my ROS environment, but it looks like I have no scripts folder in my mavros package (see ls mavros of my previous answer).
Am I doing something wrong? or is my mavros package incomplete?

check in /opt/ros/kinetic/lib/mavros/ it should be here

Did you apt-get mavros or install from source ? In both case you shouldn’t have to be in /opt/ros to launch command , it should works from anywhere

I run roslaunch mavros apm.launch on a console and get communication with pixhawk running ardurover.
In another console I run rosrun mavros mavsys rate --all 20
and then I run: rostopic echo /mavros/local_position/odom

I get odom message, but it does not change pose:pose:position part of the message according to the movement of the pixhawk. I walk with it in my backyard and position seems to be just noise around 0.

Does anybody try it on a real vehicle or just in sitl?

/mavros/global_position/local do show the change of position while I move the pix. But I don’t know if it is a GPS msg or an EKF result.

could it be an ardurover firmware problem?
I just made the same test with my quadrotor (pixhawk + copter 3.5.5) and I get odom message changes when I move my quad on my backyard.
But I don’t get this on my boat…

We may have an issue in rover even if I doubt it as that paet should be commun.
What is your ARMING_REQUIRE param? 0 or 1?

It’s probably not related but there is a small issue with mavros not recognising boats (issue here). It’s been fixed by voon but needs testing and hasn’t been released with mavros I think.

The way to test if this is important is to change the FRAME_CLASS so the vehicle is a car and reboot the flight controller.

Ok, that is!!!
I have ARMING_REQUIRE set to 1 and I was testing without arming the rover.
I, now, test it with ARMING_REQUIERE set to 0 and it is working ok.
Is there some information about local coordinate frame? what does x and y mean?

Thank a lot!