Skip to content

Commit

Permalink
Temporary fix for Lizard issue 66 (#213)
Browse files Browse the repository at this point in the history
We still notice issues with
zauberzeug/lizard#66 (`Unknown Property
"level"` and `Unknown Property "active"`) until then setting them to 0
and false on p0 helps.

Depends on zauberzeug/rosys#216
  • Loading branch information
pascalzauberzeug authored Oct 23, 2024
1 parent 3d296b2 commit beb3aa9
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 11 deletions.
7 changes: 3 additions & 4 deletions field_friend/hardware/safety.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,23 +82,22 @@ 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
if isinstance(y_axis, ChainAxisHardware):
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'
Expand Down
10 changes: 8 additions & 2 deletions field_friend/hardware/status_control.py
Original file line number Diff line number Diff line change
@@ -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):
Expand All @@ -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',
Expand Down
16 changes: 12 additions & 4 deletions field_friend/hardware/tornado.py
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand All @@ -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
Expand Down
5 changes: 5 additions & 0 deletions field_friend/hardware/y_axis_canopen_hardware.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ geopy
shapely
fiona
geopandas
rosys == v0.18.2
rosys == v0.18.3
uvicorn == 0.28.1

0 comments on commit beb3aa9

Please sign in to comment.