-
Notifications
You must be signed in to change notification settings - Fork 0
/
talker.py
32 lines (28 loc) · 890 Bytes
/
talker.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/env python
import rospy
from sensor_msgs.msg import JointState
from std_msgs.msg import Header
def talker():
pub = rospy.Publisher('/joint_command', JointState, queue_size=10)
rospy.init_node('joint_state_publisher')
rate = rospy.Rate(10) # 10hz
hello_str = JointState()
hello_str.header = Header()
hello_str.name = ['head_nx_joint', 'head_nx_joint', 'head_nx_joint', 'l_shy_joint']
hello_str.position = [0.3, 0.5418, -1.7297, -0.3017]
hello_str.velocity = []
hello_str.effort = []
i = -30
while not rospy.is_shutdown():
hello_str.header.stamp = rospy.Time.now()
hello_str.position = [i*0.01, i*0.01, i*0.01, i*0.01 ]
i += 5
if i >= 30:
i = -30
pub.publish(hello_str)
rate.sleep()
if __name__ == '__main__':
try:
talker()
except rospy.ROSInterruptException:
pass