diff --git a/ToDo.md b/ToDo.md index 4ac2257..caebb17 100644 --- a/ToDo.md +++ b/ToDo.md @@ -20,4 +20,5 @@ - other? * [] Examples - ~~pick and place~~ + - path following (generated from G-code) with force control - more examples? \ No newline at end of file diff --git a/src/pyUR/realtime/realtime_statuses.py b/src/pyUR/realtime/realtime_statuses.py index 8900ced..e65675f 100644 --- a/src/pyUR/realtime/realtime_statuses.py +++ b/src/pyUR/realtime/realtime_statuses.py @@ -6,6 +6,7 @@ _program_state : float = None _robot_mode : float = None _digital_outputs: list = None +_digital_inputs : list = None _q_act_base:float = None _q_act_shoulder:float = None @@ -33,7 +34,7 @@ def __init__(): :param status: status to unpack ''' def unpack(data:bytes): - global _program_state, _robot_mode,_digital_outputs,\ + global _program_state, _robot_mode,_digital_outputs,_digital_inputs,\ _q_act_base,_q_act_shoulder,_q_act_elbow,_q_act_wrist1,_q_act_wrist2,_q_act_wrist3,\ _tool_act_x,_tool_act_y,_tool_act_z,_tool_act_rx,_tool_act_ry,_tool_act_rz @@ -47,6 +48,9 @@ def unpack(data:bytes): # robot mode _robot_mode = (struct.unpack('!d', data[94*8:95*8]))[0] + # digital inputs + _digital_inputs = _double_to_8bit_list(struct.unpack('!d', data[85*8:86*8])[0]) + # digital outputs _digital_outputs = _double_to_8bit_list((struct.unpack('!d', data[130*8:131*8]))[0]) @@ -67,6 +71,9 @@ def unpack(data:bytes): # robot mode _robot_mode = (struct.unpack('!d', data[94*8:95*8]))[0] + # digital inputs + _digital_inputs = _double_to_8bit_list(struct.unpack('!d', data[85*8:86*8])[0]) + # digital outputs _digital_outputs = _double_to_8bit_list(struct.unpack('!d', data[130*8:131*8])[0]) @@ -103,6 +110,10 @@ def get_digital_outputs(): global _digital_outputs return _digital_outputs +def get_digital_inputs(): + global _digital_inputs + return _digital_inputs + def get_robot_act_pose(): global _tool_act_x, _tool_act_y, _tool_act_z, _tool_act_rx, _tool_act_ry, _tool_act_rz return list[_tool_act_x, _tool_act_y, _tool_act_z, _tool_act_rx, _tool_act_ry, _tool_act_rz] diff --git a/src/pyURControl/ur_control.py b/src/pyURControl/ur_control.py index d63066a..25a260c 100644 --- a/src/pyURControl/ur_control.py +++ b/src/pyURControl/ur_control.py @@ -180,4 +180,32 @@ def _wait_digital_output_is_set(output: int=0, value: bool=False): digital_outputs = get_digital_outputs() if digital_outputs[output] == value: break - sleep(0.001) \ No newline at end of file + sleep(0.001) + +''' +get digital inputs +''' +def get_digital_inputs() -> list: + # Receive responce + responce = realtime.receive_status() + + # Unpack responce + realtime_statuses.unpack(responce) + + # Get program state + digital_inputs = realtime_statuses.get_digital_inputs() + return digital_inputs + +''' +get digital input +:param input: input number 0-7 +''' +def get_digital_input(input: int=0) -> bool: + # Receive responce + responce = realtime.receive_status() + + # Unpack responce + realtime_statuses.unpack(responce) + + digital_inputs = get_digital_inputs() + return digital_inputs[input] \ No newline at end of file