Ask Your Question

Create new topic that copies odometry topic

asked 2018-12-20 04:01:44 -0500

johnbryant gravatar image

Hi all, I want to create a new topic that copies the odometry topic data in order to be able to reset the new topic.

#! /usr/bin/env python
import rospy
from sensor_msgs.msg import LaserScan
from geometry_msgs.msg import Twist
from nav_msgs.msg import Odometry

class reset_odometry:
    def __init__(self):

    rospy.init_node('reset_odometry', anonymous=False)
    self.sub = rospy.Subscriber ('/marvin/diff_drive_controller/odom', Odometry, self.get_odom)
    rospy.sleep(0) = rospy.Publisher('new_pose', Odometry, queue_size=1)
    self.odom = ()
def get_odom (self,msg):
        pose = Odometry()
    self.odom = pose
    print ("pose in callback",self.odom)

def main():
""" main function
node = reset_odometry()

if __name__ == '__main__':
while not rospy.is_shutdown() :

The way I have written my code the values returned in the new topic are always zero. Any thoughts?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2018-12-20 04:20:29 -0500

Delb gravatar image

You never actually get the odometry value here :

def get_odom (self,msg):
    pose = Odometry()
    self.odom = pose
    print ("pose in callback",self.odom)

You only initialize the variable pose with the default constructor Odometry(). You would just have to do :

self.odom = msg
edit flag offensive delete link more


Oh yes you are right. Sorry for asking such a trivial question. Thank you again.

johnbryant gravatar image johnbryant  ( 2018-12-20 04:30:54 -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

1 follower


Asked: 2018-12-20 04:01:44 -0500

Seen: 324 times

Last updated: Dec 20 '18