update firmware source code to v0.18 (#9)

This commit is contained in:
Forairaaaaa
2026-03-25 11:11:14 +08:00
committed by GitHub
parent 5001b7081b
commit 605b575fcc
123 changed files with 24590 additions and 1899 deletions
+10
View File
@@ -137,3 +137,13 @@ void Motion::setAutoAngleSyncEnabled(bool enabled)
_yaw_servo->setAutoAngleSyncEnabled(enabled);
_pitch_servo->setAutoAngleSyncEnabled(enabled);
}
void Motion::setModifyLock(bool locked)
{
_is_modify_locked = locked;
}
bool Motion::isModifyLocked()
{
return _is_modify_locked;
}
+4
View File
@@ -156,9 +156,13 @@ public:
void setAutoTorqueReleaseEnabled(bool enabled);
void setAutoAngleSyncEnabled(bool enabled);
void setModifyLock(bool locked);
bool isModifyLocked();
private:
std::unique_ptr<Servo> _yaw_servo;
std::unique_ptr<Servo> _pitch_servo;
bool _is_modify_locked = false;
static constexpr float RAD_TO_DEG = 180.0f / M_PI;
+9 -2
View File
@@ -37,7 +37,7 @@ void Servo::init()
void Servo::update()
{
// Update at 50Hz
// Keep update in at most 50Hz
if (GetHAL().millis() - _last_tick < 20) {
return;
}
@@ -45,7 +45,7 @@ void Servo::update()
// Apply animation
if (!_angle_anim.done()) {
_angle_anim.update();
_angle_anim.updateWithDelta(0.02f); // Fixed delta time for consistency
set_angle_impl(static_cast<int>(_angle_anim.directValue()));
}
@@ -92,6 +92,11 @@ int Servo::getCurrentAngle()
return _angle_anim.directValue();
}
bool Servo::isMoving()
{
return _angle_anim.done() == false || is_moving_impl();
}
void Servo::apply_default_spring_options()
{
auto& options = _angle_anim.springOptions();
@@ -102,6 +107,8 @@ void Servo::apply_default_spring_options()
void Servo::update_angle_anim_target(int angle)
{
angle = uitk::clamp(angle, _angle_limit.x, _angle_limit.y);
if (_auto_angle_sync_enabled) {
_angle_anim.teleport(getCurrentAngle()); // Use current angle as start
}
+14 -5
View File
@@ -86,10 +86,7 @@ public:
* @return true
* @return false
*/
virtual bool isMoving()
{
return false;
}
bool isMoving();
/**
* @brief
@@ -139,6 +136,14 @@ public:
{
}
/**
* @brief
*
*/
virtual void resetZeroCalibration()
{
}
protected:
Servo()
{
@@ -155,8 +160,12 @@ protected:
* @param angle
*/
virtual void set_angle_impl(int angle) = 0;
virtual bool is_moving_impl()
{
return false;
}
private:
protected:
uitk::Vector2i _angle_limit;
uitk::AnimateValue _angle_anim;