Add DualDriveDeltaMotor and DualDriveDeltaArm modules#210
Draft
JensOgorek wants to merge 2 commits into
Draft
Conversation
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Add Lizard support for the CAN-based dual-drive delta arm (two-motor positioning arm with hall feedback and per-side endstops) so it can be used through the standard Lizard module interface.
This PR is the second slice of #194 and stacks on top of #209: it ships the delta-arm parts (delta motor + arm kinematics/calibration). The shared
DualDriveMotorBaseis duplicated here againstmainso the branch can be reviewed independently — once #209 merges, mergingmainback into this branch resolves the base class to a no-op.Implementation
Three new modules under
main/modules/:DualDriveMotorBase— shared base, identical to the one in Add DualDriveMotor and DualDriveWheels modules #209. Handles common state (voltage, temperature, error codes, switch state, firmware version), enable/disable, and theConfigure(0x0B) /SwitchState(0x0A) /stopCAN commands.DualDriveDeltaMotor— delta-mode specialization. Auto-switches the controller into the operating mode for the configured motor variant (Configure 0x02) on construction. Variants currently supported:windmeile— first delta arm, 300 ticks/rev, mode0xB5B5g350— drive motor used as delta, 600 ticks/rev, mode0xD5D5g250r-t— new delta arm 14.2:1 gear, 678 ticks/rev, mode0xB5B5(later0xC5C5)Exposes:
motor.rel_angle(angle, vel_limit?, acc_limit?, jerk_limit_exp?)— relative angle move viaRelAngleCmd 0x02motor.delta_angle(motor_select, pos1, spd1?, pos2?, spd2?)— per-motor or combined position command viaAngleCmd 0x03(0x10=left,0x20=right,0x30=both)motor.reference_drive_start(motor, clockwise?)/motor.reference_drive_stop(motor)— trigger and brake the firmware's reference drive viaSingleMotorControl 0x0Cmotor.single_motor_control(cmd_motor1, cmd_motor2)— raw0x0Cfor combined framesreversed, per-motorangle_m{1,2}(hall ticks), per-motorcurrent_m{1,2}(A),ref_result_m{1,2}DualDriveDeltaArm— combines aDualDriveDeltaMotorwith twoInputendstops. Owns the calibration state machine and the high-level positioning interface:arm.position(left_deg, right_deg, speed_left?, speed_right?)— move both arms in degrees, blocked unless calibrated and target insidedeg_limitarm.reference("left" | "right" | "both")— start a reference drive; if the relevant endstop is already active the arm first nudges the motor away inBACKOFF_STEP_TICKSincrements, then issues the reference command. For"both"the calibration is sent as a single combined0x0Cframe because some firmware revisions only honor "both" that way.arm.stop()— abort calibration and brake both motors;arm.stop(1|2)brakes a single motorarm.on()/arm.off()/arm.enable()/arm.disable()— power and module-level enableenabled,calibrating,calibrated_left,calibrated_right,active,stalled,angle_left,angle_right,deg_limit,cal_timeout,stall_currentDetection logic in
step():activeclears once both arms stay withinPOSITION_TOL_DEG(1.2°) forSTABLE_MS(100 ms).active, overcurrent (|i| > stall_current) AND no position change beyondSTALL_POS_TOL_DEG(2.4°) withinSTALL_MS(200 ms) marks the armstalled, invalidates calibration, and disables the motor.cal_timeout(default 10 s) brakes both motors and clears calibration if the firmware never reports aReferenceFeedback.Notes on the firmware contract:
ReferenceFeedback 0x14(REF_OK/REF_OVERCURRENT/REF_END); the endstop only triggers the brake, not the "done" transition.0x14arrives per-motor in separate frames (each only setting its own nibble), so the arm latches the highest non-zero value seen per motor across the calibration window.can_move()and physically by the motor firmware.Module registration follows the same pattern as
DualDriveMotor/DualDriveWheels.Progress