35 Dynamic parameter server for control loop parameters for the Revel robotic arm 38 Each motor can have its individual 39 Positional P, I, D, feedforward_velocity, feedforward_acceleration 40 velocity_profile (and speed) 41 acceleration_profile (and acceleration) 43 where the velocity and acceleration profiles are determined by a comparison of values 44 between the two profiles. The values themselves set the target motor speed and acceleration 45 while the profile determines the motor speed and acceleration over time. 47 See Dynamixel 2.0 Firmware Manual, sections Profile Velocity and Profile Acceleration for more details. 50 NOTE: Setting control parameters manually can cause the control loop to become unstable, 51 potentially harming the environment and the robot. 53 To change control parameters, you must first check the 'enable control parameters' checkbox in the 54 rqt_reconfigure window. You then proceed AT YOUR OWN RISK. 56 Author: Maxwell Svetlik 62 from dynamic_reconfigure.server
import Server
63 from std_srvs.srv
import Empty
64 from svenzva_drivers.cfg
import RevelFirmwareDynamicConfig
69 def __init__(self, controller_namespace, mx_io):
74 self.
gr = [4,7,7,3,4,1,1]
80 self.
set_position_PID(1, config.joint_1_P, config.joint_1_I, config.joint_1_D, config.joint_1_Feedforward1_velocity, config.joint_1_Feedforward2_acceleration, config.joint_1_velocity_P, config.joint_1_velocity_I)
81 self.
set_position_PID(2, config.joint_2_P, config.joint_2_I, config.joint_2_D, config.joint_2_Feedforward1_velocity, config.joint_2_Feedforward2_acceleration, config.joint_2_velocity_P, config.joint_2_velocity_I)
82 self.
set_position_PID(3, config.joint_3_P, config.joint_3_I, config.joint_3_D, config.joint_3_Feedforward1_velocity, config.joint_3_Feedforward2_acceleration, config.joint_3_velocity_P, config.joint_3_velocity_I)
83 self.
set_position_PID(4, config.joint_4_P, config.joint_4_I, config.joint_4_D, config.joint_4_Feedforward1_velocity, config.joint_4_Feedforward2_acceleration, config.joint_4_velocity_P, config.joint_4_velocity_I)
84 self.
set_position_PID(5, config.joint_5_P, config.joint_5_I, config.joint_5_D, config.joint_5_Feedforward1_velocity, config.joint_5_Feedforward2_acceleration, config.joint_5_velocity_P, config.joint_5_velocity_I)
85 self.
set_position_PID(6, config.joint_6_P, config.joint_6_I, config.joint_6_D, config.joint_6_Feedforward1_velocity, config.joint_6_Feedforward2_acceleration, config.joint_6_velocity_P, config.joint_6_velocity_I)
86 self.
set_position_PID(7, config.joint_7_P, config.joint_7_I, config.joint_7_D, config.joint_7_Feedforward1_velocity, config.joint_7_Feedforward2_acceleration, config.joint_7_velocity_P, config.joint_7_velocity_I)
102 if not config.enable_parameter_control:
107 if config.joint_acc_limit != self.last_configuration.joint_acc_limit:
111 if config.joint_vel_limit != self.last_configuration.joint_vel_limit:
115 self.
set_position_PID(1, config.joint_1_P, config.joint_1_I, config.joint_1_D, config.joint_1_Feedforward1_velocity, config.joint_1_Feedforward2_acceleration, config.joint_1_velocity_P, config.joint_1_velocity_I)
117 self.
set_position_PID(2, config.joint_2_P, config.joint_2_I, config.joint_2_D, config.joint_2_Feedforward1_velocity, config.joint_2_Feedforward2_acceleration, config.joint_2_velocity_P, config.joint_2_velocity_I)
119 self.
set_position_PID(3, config.joint_3_P, config.joint_3_I, config.joint_3_D, config.joint_3_Feedforward1_velocity, config.joint_3_Feedforward2_acceleration, config.joint_3_velocity_P, config.joint_3_velocity_I)
121 self.
set_position_PID(4, config.joint_4_P, config.joint_4_I, config.joint_4_D, config.joint_4_Feedforward1_velocity, config.joint_4_Feedforward2_acceleration, config.joint_4_velocity_P, config.joint_4_velocity_I)
123 self.
set_position_PID(5, config.joint_5_P, config.joint_5_I, config.joint_5_D, config.joint_5_Feedforward1_velocity, config.joint_5_Feedforward2_acceleration, config.joint_5_velocity_P, config.joint_5_velocity_I)
125 self.
set_position_PID(6, config.joint_6_P, config.joint_6_I, config.joint_6_D, config.joint_6_Feedforward1_velocity, config.joint_6_Feedforward2_acceleration, config.joint_6_velocity_P, config.joint_6_velocity_I)
127 self.
set_position_PID(7, config.joint_7_P, config.joint_7_I, config.joint_7_D, config.joint_7_Feedforward1_velocity, config.joint_7_Feedforward2_acceleration, config.joint_7_velocity_P, config.joint_7_velocity_I)
132 def set_position_PID(self, motor_id, p_gain_val, i_gain_val, d_gain_val, ff1_gain, ff2_gain, vel_p, vel_i):
133 self.mx_io.set_position_p_gain(motor_id, p_gain_val)
134 self.mx_io.set_position_i_gain(motor_id, i_gain_val)
135 self.mx_io.set_position_d_gain(motor_id, d_gain_val)
136 self.mx_io.set_position_feedfwd1_gain(motor_id, ff1_gain)
137 self.mx_io.set_position_feedfwd2_gain(motor_id, ff2_gain)
138 self.mx_io.set_velocity_p_gain(motor_id, vel_p)
139 self.mx_io.set_velocity_i_gain(motor_id, vel_i)
143 self.mx_io.set_acceleration_profile(1, gain*self.
gr[0])
144 self.mx_io.set_acceleration_profile(2, gain*self.
gr[1])
145 self.mx_io.set_acceleration_profile(3, gain*self.
gr[2])
146 self.mx_io.set_acceleration_profile(4, gain*self.
gr[3])
147 self.mx_io.set_acceleration_profile(5, gain*self.
gr[4])
148 self.mx_io.set_acceleration_profile(6, gain*self.
gr[5])
149 self.mx_io.set_acceleration_profile(7, gain*self.
gr[6])
153 self.mx_io.set_velocity_profile(1, gain*self.
gr[0])
154 self.mx_io.set_velocity_profile(2, gain*self.
gr[1])
155 self.mx_io.set_velocity_profile(3, gain*self.
gr[2])
156 self.mx_io.set_velocity_profile(4, gain*self.
gr[3])
157 self.mx_io.set_velocity_profile(5, gain*self.
gr[4])
158 self.mx_io.set_velocity_profile(6, gain*self.
gr[5])
159 self.mx_io.set_velocity_profile(7, gain*self.
gr[6])
162 srv = Server(RevelFirmwareDynamicConfig, self.
callback)
163 last_config_srv = rospy.Service(
'revel/reload_firmware_parameters', Empty, self.
set_current_config)
166 if __name__ ==
"__main__":
167 rospy.init_node(
"svenzva_drivers_reconfigure", anonymous =
False)