Skip to content

Instantly share code, notes, and snippets.

@hackintoshrao
Created November 30, 2017 00:52
Show Gist options
  • Save hackintoshrao/615f0477ff27a3238ae764e3a9465473 to your computer and use it in GitHub Desktop.
Save hackintoshrao/615f0477ff27a3238ae764e3a9465473 to your computer and use it in GitHub Desktop.
ROS node using pyton ropspy package to send commands to topics in simple arm package to move the robotic joints.
import math
import rospy
from std_msgs.msg import Float64
def mover():
pub_j1 = rospy.Publisher('/simple_arm/joint_1_position_controller/command',
Float64, queue_size=10)
pub_j2 = rospy.Publisher('/simple_arm/joint_2_position_controller/command',
Float64, queue_size=10)
rospy.init_node('arm_mover')
rate = rospy.Rate(10)
start_time = 0
while not start_time:
start_time = rospy.Time.now().to_sec()
while not rospy.is_shutdown():
elapsed = rospy.Time.now().to_sec() - start_time
pub_j1.publish(math.sin(2*math.pi*0.1*elapsed)*(math.pi/2))
pub_j2.publish(math.sin(2*math.pi*0.1*elapsed)*(math.pi/2))
rate.sleep()
if __name__ == '__main__':
try:
mover()
except rospy.ROSInterruptException:
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment