Ask Your Question

robot_localization package with custom sensor message

asked 2019-09-06 04:40:58 -0500

enthusiast.australia gravatar image

updated 2019-09-06 06:18:55 -0500

I want to know if i can use robot_localisation package with odometry messages and custom messages which i generate from my sensor. I am not using IMU, instead another sensor which gives me x and y. Now i want to use these coordinates and data from odometry to localise and navigate my robot. Any suggestions on how can i do that? I am using kinetic and ubuntu 16.04.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2019-09-06 22:31:43 -0500

Well 2 options from what I see.

Option 1 (I recommend): Create an intermediate node(let) which converts your custom message to one of the standard robot localization message types. Odometry given how much information you can embed into it is a good choice. In your sensor configuration matrix in robot_localization you can inform it to only take the X and Y information from the message to fuse. Bam, you're on your way with a 15 line script.

Option 2: You can fork robot_localization create a new sensor type using your message type to input the information from your sensor to the filter. Shouldn't be too much effort but certainly not as clean. You're on your way with a 50 line update and also now need to support your separate fork.

edit flag offensive delete link more


thanks for your answer. I thought of going with your first option. But i don't know how to convert message types. Can you suggest something on how to do that or is there some tutorial that i can follow to do so.

enthusiast.australia gravatar image enthusiast.australia  ( 2019-09-07 11:13:31 -0500 )edit

@enthusiast.australia: please stop deleting questions that have received answers.

It's rather rude to delete a question after another forum member has gone through the trouble of reading your question, thinking about it and providing you with a possible solution.

If an answer was satisfactory, please tick the checkmark to the left of the answer to mark it as accepted. If an answer didn't actually answer your question, then interact with the poster to keep figuring things out.

I've undeleted all of your questions that received answers.

Please don't do it again.

gvdhoorn gravatar image gvdhoorn  ( 2019-09-08 10:41:43 -0500 )edit

I am sorry, i didn't think that way. I will not delete any in future. Thanks for informing me

enthusiast.australia gravatar image enthusiast.australia  ( 2019-09-08 10:48:10 -0500 )edit

@enthusiast.australia you can easily convert messages in C++ or python. Its just an object like any other object. If you aren't familiar with ROS messages, just look at the basic tutorial pub/sub in your language of choice for reference.

stevemacenski gravatar image stevemacenski  ( 2019-09-08 21:32:05 -0500 )edit

Now what i am doing is, running the code to get the data from sensor, compute x and y, and then store this in .txt file. The data is like

1.25855856 1.25258946

1.25878878 1.47885488

and so on.

Now i want to publish this data in such a way that i could use it robot_localization package. My code is "

#!/usr/bin/env python

# license removed for brevity

import rospy

from std_msgs.msg import Float64

def talker():

   pub = rospy.Publisher('chatter', Float64, queue_size=10)

   rospy.init_node('talker', anonymous=True)

   rate = rospy.Rate(10) # 10hz

  while not rospy.is_shutdown():

       f= open("myfile.txt" ,"r")



if __name__ == '__main__':



   except rospy.ROSInterruptException:



How should i modify this to get it publishing the data and use this in robot_localization?

enthusiast.australia gravatar image enthusiast.australia  ( 2019-09-15 18:32:49 -0500 )edit

If you're uncertain how to use OOP, please file another ticket or see the ros tutorials

stevemacenski gravatar image stevemacenski  ( 2019-09-16 11:00:53 -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



Asked: 2019-09-06 04:40:58 -0500

Seen: 126 times

Last updated: Sep 06 '19