Difference between revisions of "Motors go full.py"
From wikidb
Line 6: | Line 6: | ||
roscd floor_hugger/test/ | roscd floor_hugger/test/ | ||
python motors_go_full.py 0.20 0.1 | python motors_go_full.py 0.20 0.1 | ||
− | |||
<pre> | <pre> |
Revision as of 13:20, 20 September 2017
Take the place of the navigation stack by publishing a cmd_vel message of type Twist. Execution is of the form:
motors_go_full.py <linear.x> <angular.z>
It sets the linear.x value to 0.20 m/sec and the angular.z value to 0.1 radians/sec.
roscd floor_hugger/test/ python motors_go_full.py 0.20 0.1
#!/usr/bin/env python import sys import rospy from geometry_msgs.msg import Twist def motors_go(linear_speed, angular_speed): print (linear_speed, angular_speed) vel_pub = rospy.Publisher ('cmd_vel', Twist, queue_size=10) rate = rospy.Rate(10) twist = Twist() twist.linear.x = 0.0 twist.linear.y = 0.0 twist.linear.z = 0.0 twist.angular.x = 0.0 twist.angular.y = 0.0 twist.angular.z = 0.0 while not rospy.is_shutdown(): # print (twist.linear.x) twist.linear.x = float(linear_speed) twist.angular.z = float(angular_speed) vel_pub.publish(twist) rate.sleep() twist.linear.x = 0.0 vel_pub.publish(twist) if __name__ == '__main__': print ('Motors Go') rospy.init_node('motor_go', anonymous=True) motors_go(sys.argv[1], sys.argv[2]) rospy.spin()