From 7b2bf3039404e2cdbdd6c6da577bb594e363a1b7 Mon Sep 17 00:00:00 2001 From: fiona Date: Sun, 2 Aug 2026 19:50:00 +0000 Subject: [PATCH] Move retract value to hw config const --- firmware/MotionControllerRP/src/hw_config.h | 5 +++++ firmware/MotionControllerRP/src/robot_joint/robot_joint.cpp | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/firmware/MotionControllerRP/src/hw_config.h b/firmware/MotionControllerRP/src/hw_config.h index b773443..252e1a0 100644 --- a/firmware/MotionControllerRP/src/hw_config.h +++ b/firmware/MotionControllerRP/src/hw_config.h @@ -43,6 +43,11 @@ constexpr float CALIBRATION_RANGE = 83; // velocity of the magnetic field during calibration (lower is more accurate) constexpr float CALIBRATION_FIELD_VELOCITY = 20.0f; +// angle to retract after homing before starting calibration run +// can be used if the encoder measurements at the beginning of the calibration +// run is non-linear +constexpr float CALIBRATION_RETRACT_ANGLE = 17.5f; + // size of the calibration lookup table constexpr int ENCODER_LUT_SIZE = 256; diff --git a/firmware/MotionControllerRP/src/robot_joint/robot_joint.cpp b/firmware/MotionControllerRP/src/robot_joint/robot_joint.cpp index d4263e9..2478c2f 100644 --- a/firmware/MotionControllerRP/src/robot_joint/robot_joint.cpp +++ b/firmware/MotionControllerRP/src/robot_joint/robot_joint.cpp @@ -57,7 +57,7 @@ bool RobotJoint::calibrate(bool print_measurements) { bool homing_ok = homing_controller.run_blocking(servo_controller, -HOMING_VELOCITY, 360.0f*DEG_TO_RAD, HOMING_CURRENT, ENCODER_ANGLE_TO_ROTOR_ANGLE, - 17.5f*DEG_TO_RAD); + CALIBRATION_RETRACT_ANGLE*DEG_TO_RAD); if(homing_ok == false) { LOG_ERROR("Joint-%i: Calibration failed due to unsuccessful homing sequence", joint_idx); return false;