Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3. import math
  4. import rospy
  5. from std_msgs.msg import Float64
  6.  
  7. def mover():
  8. pub_j1 = rospy.Publisher('/simple_arm/joint_1_position_controller/command',
  9. Float64, queue_size=10)
  10. pub_j2 = rospy.Publisher('/simple_arm/joint_2_position_controller/command',
  11. Float64, queue_size=10)
  12. rospy.init_node('arm_mover', anonymous=True)
  13. rate = rospy.Rate(10)
  14. start_time = 0
  15.  
  16. while not start_time:
  17. start_time = rospy.Time.now().to_sec()
  18.  
  19. while not rospy.is_shutdown():
  20. elapsed = rospy.Time.now().to_sec() - start_time
  21. pub_j1.publish(math.sin(2*math.pi*0.1*elapsed)*(math.pi/2))
  22. pub_j2.publish(math.sin(2*math.pi*0.1*elapsed)*(math.pi/2))
  23. rate.sleep()
  24.  
  25. if __name__ == '__main__':
  26. try:
  27. mover()
  28. except rospy.ROSInterruptException:
  29. pass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement