diff --git a/field_friend/hardware/safety.py b/field_friend/hardware/safety.py index af7a6c97..eab5ee84 100644 --- a/field_friend/hardware/safety.py +++ b/field_friend/hardware/safety.py @@ -82,15 +82,13 @@ def __init__(self, robot_brain: rosys.hardware.RobotBrain, *, elif isinstance(flashlight, FlashlightHardwareV2): lizard_code += f' {flashlight.name}_front.off(); {flashlight.name}_back.off();' if mower is not None: - lizard_code += f' m0.off();' + lizard_code += ' m0.off();' lizard_code += 'end\n' # implement stop call for estops and bumpers for name in estop.pins: lizard_code += f'when estop_{name}.level == 0 then stop(); end\n' if isinstance(bumper, rosys.hardware.BumperHardware): for name in bumper.pins: - # TODO: remove level = 0 when lizard issue 66 is fixed. https://github.com/zauberzeug/lizard/issues/66 - lizard_code += f'bumper_{name}.level = 0\n' lizard_code += f'when bumper_{name}.level == 1 then stop(); end\n' # implement stop call for "ground check" reference sensors @@ -98,7 +96,8 @@ def __init__(self, robot_brain: rosys.hardware.RobotBrain, *, lizard_code += f'when {y_axis.name}_ref_t.level == 1 then {wheels.name}.speed(0, 0); end\n' if isinstance(z_axis, TornadoHardware): if isinstance(y_axis, YAxisStepperHardware) or isinstance(y_axis, YAxisCanOpenHardware): - lizard_code += f'when {z_axis.name}_ref_knife_ground.active == false then {wheels.name}.speed(0, 0); {y_axis.name}.stop(); end\n' + lizard_code += f'when {z_axis.name}_ref_knife_ground.active == false then \ + {wheels.name}.speed(0, 0); {y_axis.name}.stop(); end\n' # implement watchdog for rosys modules lizard_code += f'when core.last_message_age > 1000 then {wheels.name}.speed(0, 0); end\n' diff --git a/field_friend/hardware/status_control.py b/field_friend/hardware/status_control.py index f59b412c..45cb23a2 100644 --- a/field_friend/hardware/status_control.py +++ b/field_friend/hardware/status_control.py @@ -1,6 +1,7 @@ from rosys.hardware.expander import ExpanderHardware from rosys.hardware.module import ModuleHardware from rosys.hardware.robot_brain import RobotBrain +from rosys.helpers import remove_indentation class StatusControlHardware(ModuleHardware): @@ -13,8 +14,13 @@ def __init__(self, robot_brain: RobotBrain, *, self.rdyp_status: bool = False self.vdp_status: bool = False self.heap: int = 0 - lizard_code = f'rdyp_status = Input({rdyp_pin})\n' - lizard_code += f'vdp_status = {expander.name + "."}Input({vdp_pin})\n' + lizard_code = remove_indentation(f''' + rdyp_status = Input({rdyp_pin}) + vdp_status = {expander.name + "."}Input({vdp_pin}) + # TODO: remove when lizard issue 66 is fixed. + vdp_status.level = 0 + vdp_status.active = false + ''') core_message_fields = [ 'rdyp_status.level', 'vdp_status.level', diff --git a/field_friend/hardware/tornado.py b/field_friend/hardware/tornado.py index c5fd70f5..62bf9e70 100644 --- a/field_friend/hardware/tornado.py +++ b/field_friend/hardware/tornado.py @@ -138,8 +138,8 @@ def __init__(self, robot_brain: rosys.hardware.RobotBrain, *, self.motor_error = False lizard_code = remove_indentation(f''' - {name}_motor_z = {expander.name + "." if motors_on_expander and expander else ""}ODriveMotor({can.name}, {z_can_address}{', 6'if self.odrive_version == 6 else ''}) - {name}_motor_turn = {expander.name + "." if motors_on_expander and expander else ""}ODriveMotor({can.name}, {turn_can_address}{', 6'if self.odrive_version == 6 else ''}) + {name}_motor_z = {expander.name + "." if motors_on_expander and expander else ""}ODriveMotor({can.name}, {z_can_address}{', 6'if self.odrive_version == 6 else ''}) + {name}_motor_turn = {expander.name + "." if motors_on_expander and expander else ""}ODriveMotor({can.name}, {turn_can_address}{', 6'if self.odrive_version == 6 else ''}) {name}_motor_z.m_per_tick = {m_per_tick} {name}_motor_turn.m_per_tick = {1/12.52} {name}_motor_z.limits({self.speed_limit}, {self.current_limit}) @@ -158,15 +158,23 @@ def __init__(self, robot_brain: rosys.hardware.RobotBrain, *, {name}_ref_knife_stop.inverted = false {name}_ref_knife_ground = {expander.name + "." if end_stops_on_expander or ref_knife_ground_pin_expander and expander else ""}Input({ref_knife_ground_pin}) {name}_ref_knife_ground.inverted = true - {name}_z = {expander.name + "." if motors_on_expander and expander else ""}MotorAxis({name}_motor_z, {name + "_end_bottom" if is_z_reversed else name + "_end_top"}, {name + "_end_top" if is_z_reversed else name + "_end_bottom"}) - # TODO: remove when lizard issue 66 is fixed. https://github.com/zauberzeug/lizard/issues/66 + # TODO: remove when lizard issue 66 is fixed. + {name}_end_top.level = 0 + {name}_end_top.active = false + {name}_end_bottom.level = 0 + {name}_end_bottom.active = false {name}_ref_motor.level = 0 + {name}_ref_motor.active = false {name}_ref_gear.level = 0 + {name}_ref_gear.active = false {name}_ref_knife_stop.level = 0 + {name}_ref_knife_stop.active = false {name}_ref_knife_ground.level = 0 {name}_ref_knife_ground.active = false + {name}_z = {expander.name + "." if motors_on_expander and expander else ""}MotorAxis({name}_motor_z, {name + "_end_bottom" if is_z_reversed else name + "_end_top"}, {name + "_end_top" if is_z_reversed else name + "_end_bottom"}) + bool {name}_is_referencing = false bool {name}_ref_motor_enabled = false bool {name}_ref_gear_enabled = false diff --git a/field_friend/hardware/y_axis_canopen_hardware.py b/field_friend/hardware/y_axis_canopen_hardware.py index 4a835628..3533dca1 100644 --- a/field_friend/hardware/y_axis_canopen_hardware.py +++ b/field_friend/hardware/y_axis_canopen_hardware.py @@ -38,6 +38,11 @@ def __init__(self, robot_brain: rosys.hardware.RobotBrain, *, {name}_end_l.inverted = {str(end_stops_inverted).lower()} {name}_end_r = {expander.name + "." if end_stops_on_expander and expander else ""}Input({end_r_pin}) {name}_end_r.inverted = {str(end_stops_inverted).lower()} + # TODO: remove when lizard issue 66 is fixed. + {name}_end_l.level = 0 + {name}_end_l.active = false + {name}_end_r.level = 0 + {name}_end_r.active = false {name} = {expander.name + "." if motor_on_expander and expander else ""}MotorAxis({name}_motor, {name + "_end_l" if reversed_direction else name + "_end_r"}, {name + "_end_r" if reversed_direction else name + "_end_l"}) ''') core_message_fields = [ diff --git a/requirements.txt b/requirements.txt index a8620c20..eba37a33 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,5 +6,5 @@ geopy shapely fiona geopandas -rosys == v0.18.2 +rosys == v0.18.3 uvicorn == 0.28.1 \ No newline at end of file