def driverProg():
HOSTNAME = "%(driver_hostname)s"
PORT = %(driver_reverseport)d
MSG_OUT = 1
MSG_QUIT = 2
MSG_JOINT_STATES = 3
MSG_MOVEJ = 4
MSG_WAYPOINT_FINISHED = 5
MSG_STOPJ = 6
MSG_SERVOJ = 7
MSG_SET_PAYLOAD = 8
MSG_WRENCH = 9
MSG_SET_DIGITAL_OUT = 10
MSG_GET_IO = 11
MSG_SET_FLAG = 12
MSG_SET_TOOL_VOLTAGE = 13
MSG_SET_ANALOG_OUT = 14
MULT_wrench = 10000.0
MULT_payload = 1000.0
MULT_jointstate = 10000.0
MULT_time = 1000000.0
MULT_blend = 1000.0
MULT_analog = 1000000.0
pi = 3.14159265359
def send_out(msg):
enter_critical
socket_send_int(MSG_OUT)
socket_send_string(msg)
socket_send_string("~")
exit_critical
end
def send_waypoint_finished(waypoint_id):
enter_critical
socket_send_int(MSG_WAYPOINT_FINISHED)
socket_send_int(waypoint_id)
exit_critical
end
SERVO_IDLE = 0
SERVO_RUNNING = 1
cmd_servo_state = SERVO_IDLE
cmd_servo_id = 0 # 0 = idle, -1 = stop
cmd_servo_q = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
cmd_servo_dt = 0.0
def set_servo_setpoint(id, q, dt):
enter_critical
cmd_servo_state = SERVO_RUNNING
cmd_servo_id = id
cmd_servo_q = q
cmd_servo_dt = dt
exit_critical
end
thread servoThread():
state = SERVO_IDLE
whi