3 from sensor_msgs.msg
import JointState
8 rospy.init_node(
'joint_0_publisher', anonymous=
True)
9 self.
sub = rospy.Subscriber(
"joint_states", JointState, self.
callback)
10 self.
pub = rospy.Publisher(
"joint_0s/joint_states", JointState, queue_size=1)
16 self.joint_state_msg.header.stamp = rospy.Time.now()
18 self.joint_state_msg.name = []
19 self.joint_state_msg.position = []
20 self.joint_state_msg.velocity = []
21 self.joint_state_msg.effort = []
24 for name, position, velocity, effort
in zip(data.name,
28 if "FJ1" in name
and len(name) == 4:
29 fj0 = [position, velocity, effort]
31 if "FJ2" in name
and len(name) == 4:
32 fj0 = [fj0[0] + position, fj0[1] + velocity, fj0[2] + effort]
33 self.joint_state_msg.name.append(name[0]+
"FJ0")
34 self.joint_state_msg.position.append(fj0[0])
35 self.joint_state_msg.velocity.append(fj0[1])
36 self.joint_state_msg.effort.append(fj0[2])
40 if __name__ ==
'__main__':