6 from sensor_msgs.msg
import JointState
7 from std_msgs.msg
import Float64
22 error = target - current
25 delta_output += self.
_i_gain * (error)
37 pub_wrist_current.publish(0.0)
40 joint_state = JointState()
52 start_time = rospy.Time.now().secs
53 target_angle = math.radians(90)
54 while not rospy.is_shutdown():
55 if len(joint_state.position) < 7:
58 wrist_angle = joint_state.position[6]
61 present_time = rospy.Time.now().secs
62 if present_time - start_time > 5:
63 start_time = present_time
66 target_effort = pid_controller.update(wrist_angle, target_angle)
67 pub_wrist_current.publish(target_effort)
71 if __name__ ==
'__main__':
72 rospy.init_node(
"control_effort_wrist")
74 sub_joint_state = rospy.Subscriber(
75 "/sciurus17/controller2/joint_states",
80 pub_wrist_current = rospy.Publisher(
81 "/sciurus17/controller2/left_wrist_controller/command",
85 rospy.on_shutdown(stop)
88 if not rospy.is_shutdown():
90 except rospy.ROSInterruptException:
def update(self, current, target)
def __init__(self, p_gain, i_gain, d_gain)
def joint_state_callback(msg)