11 from geometry_msgs.msg
import Twist,Point
12 from nav_msgs.msg
import Odometry
14 rospy.init_node(
'slow_motion', anonymous=
True)
19 print (
"""------------------------------------------------------------- 20 Odometer consistency check 21 ------------------------------------------------------------- 30 now = rospy.Time.now().to_sec()
31 cur_pos = msg.pose.pose.position
34 pos_distance = ((cur_pos.x-last_pos.x)**2 + (cur_pos.y-last_pos.y)**2)**0.5
35 t_distance = VELOCITY*(now-last_t)
36 print "Velocity error: {}%".format(round(abs(msg.twist.twist.linear.x-VELOCITY)/VELOCITY*100,2)),\
37 " Position error: {}%".format(round(abs(pos_distance-t_distance)/t_distance*100,2))
46 pub = rospy.Publisher(
'cmd_vel', Twist, queue_size=10)
48 rospy.Subscriber(
'odom',Odometry,odometry_callback)
53 vel_msg.linear.x = VELOCITY
54 vel_msg.angular.z = ANGLE
56 while not rospy.is_shutdown():
62 vel_msg.angular.z = 0.0
69 if __name__ ==
'__main__':
70 if abs(VELOCITY)<0.000001:
71 print (
"VELOCITY must be different from zero")
76 except rospy.ROSInterruptException:
def odometry_callback(msg)