Convert pose data into twist message
I am working through a tutorial in which I have a series of pose positions for a robot saved to a file. Example below:
rostopic echo /amcl_pose
header:
seq: 0
stamp:
secs: 2846
nsecs: 567000000
frame_id: "map"
pose:
pose:
position:
x: -0.0395007291156
y: -0.0213931718838
z: 0.0
orientation:
x: 0.0
y: 0.0
z: -0.00131714215996
w: 0.999999132568
covariance: [0.20861109843009223, 0.003308687018433075, 0.0, 0.0, 0.0, 0.0, 0.003308687018433077, 0.22561699161902968, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.05838497295545044]
---
I have multiple pose.pose data sections, containing the position and orientation, saved to a file.
I want to send my robot to each of my saved poses but how can I convert the position and orientation amcl_pose data into linear and angular geometry_msgs/Twist messages ?
*UPDATE: *
I am following Mastering with ROS: Summit XL - Set Indoor Navigation Stack on theConstructSim.
My code for sending my goal to the move_base is as follows:
#! /usr/bin/env python
import rospy
import actionlib
from move_base_msgs.msg import MoveBaseAction, MoveBaseGoal
class SummitNavigationClient() :
def __init__(self) :
rospy.loginfo('... navigation-client starting')
move_base = actionlib.SimpleActionClient('move_base', MoveBaseAction)
move_base.wait_for_server()
goal = MoveBaseGoal()
goal.target_pose.pose.position.x = -2.76009410711
goal.target_pose.pose.position.y = -3.60989414856
goal.target_pose.pose.position.z = 0.0
goal.target_pose.pose.orientation.x = 0.0
goal.target_pose.pose.orientation.y = 0.0
goal.target_pose.pose.orientation.z = 0.000899836262279
goal.target_pose.pose.orientation.w = 0.999999595147
move_base.send_goal(goal)
if __name__ == '__main__' :
rospy.init_node('my_summit_navigation_client')
try :
navigator = SummitNavigationClient()
rospy.spin()
except rospy.ROSInterruptException as e :
rospy.logerr('Something went wrong: %s', e)
Please, add a link to the tutorial you're following.
I just realised there was a typo in my code the the point where I was executing
move_base.send_goal(...)
. It is now corrected.