-
Notifications
You must be signed in to change notification settings - Fork 13.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ackermann: Refactor #24285
base: main
Are you sure you want to change the base?
Ackermann: Refactor #24285
Conversation
8411c45
to
c91cfa7
Compare
🔎 FLASH Analysispx4_fmu-v5x [Total VM Diff: 344 byte (0.02 %)]
px4_fmu-v6x [Total VM Diff: 352 byte (0.02 %)]
Updated: 2025-02-07T15:06:33 |
b3b20c0
to
dc7162a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for putting in the effort for a clean and shared interface and architecture between all the rover types!
General remarks:
- as handle both position and velocity in the "Position" controller - how about renaming it to PositionVelocityControl?
- in the diagram you show that also attitude and rate controllers subscribe to TrajectorySetpoint.msg - is this only for Differential/Mecanum?
|
||
void AckermannAttControl::generateAttitudeSetpoint() | ||
{ | ||
bool stab_mode_enabled = _vehicle_control_mode.flag_control_manual_enabled |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bool stab_mode_enabled = _vehicle_control_mode.flag_control_manual_enabled | |
const bool stab_mode_enabled = _vehicle_control_mode.flag_control_manual_enabled |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please go through and set const also below where applicable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Scanned all files and added the missing const prefixes here: 454995a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mhh cannot find this commit anymore - is it still applied? And my comment here for a const
was not valid?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that should be const. Fixed in e226138
src/modules/rover_ackermann/AckermannRateControl/AckermannRateControl.cpp
Show resolved
Hide resolved
src/modules/rover_ackermann/AckermannPosControl/AckermannPosControl.hpp
Outdated
Show resolved
Hide resolved
src/modules/rover_ackermann/AckermannPosControl/AckermannPosControl.cpp
Outdated
Show resolved
Hide resolved
8d3e04b
to
5cdc876
Compare
@sfuhrer Thanks for the review!
Implemented that in 5cdc876, also renamed the parameter group
Yes, while the refactor does technically enable setting yaw/yaw rate setpoints through the TrajectorySetpoint also for ackermann it gets messy because the yaw/yaw rate is not decoupled from the velocity (or speed) as it is in differential/mecanum rovers. |
3cdb723
to
53c100f
Compare
rebased on main |
729c948
to
7c03dec
Compare
@Pedro-Roque Just FYI i properly disabled the rover modules on the spacecraft board here. |
|
||
void AckermannAttControl::generateAttitudeSetpoint() | ||
{ | ||
bool stab_mode_enabled = _vehicle_control_mode.flag_control_manual_enabled |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mhh cannot find this commit anymore - is it still applied? And my comment here for a const
was not valid?
@@ -71,13 +71,13 @@ void AckermannRateControl::updateRateControl() | |||
vehicle_angular_velocity.xyz[2] : 0.f; | |||
} | |||
|
|||
if (_vehicle_control_mode.flag_control_rates_enabled && _vehicle_control_mode.flag_armed) { | |||
if (_vehicle_control_mode.flag_control_rates_enabled && _vehicle_control_mode.flag_armed && runSanityChecks()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about just checking _sanity_check
here and calling runSanityChecks
only on param update?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that it is suboptimal to run this check on every update rather then on paramUpdate, but the check should also only be performed if the corresponding flag of the mode is active (i.e. only do the check for posVelControl if it is actually active). And there is the scenario where the mode is switched from i.e. acro to position without changing parameters which will then not perform the checks for posVel parameters.
@@ -112,6 +119,7 @@ class AckermannRateControl : public ModuleParams | |||
float _vehicle_yaw_rate{0.f}; | |||
hrt_abstime _timestamp{0}; | |||
float _dt{0.f}; // Time since last update [s]. | |||
bool _sanity_check{true}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like when bools are very clearly visible as such - e.g. _parameter_sanity_checks_passed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clarified in 3734e4a
Thanks @chfriedrich98 ! 🙏 |
Solved Problem
This PR starts a restructure of the rover modules to the following architecture:
![rover_code_architecture](https://private-user-images.githubusercontent.com/125505139/410871114-aaac9601-c88a-41d5-9c7a-92a73bc600d5.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzg5OTgwMzcsIm5iZiI6MTczODk5NzczNywicGF0aCI6Ii8xMjU1MDUxMzkvNDEwODcxMTE0LWFhYWM5NjAxLWM4OGEtNDFkNS05YzdhLTkyYTczYmM2MDBkNS5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwMjA4JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDIwOFQwNjU1MzdaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1iMTk0ZjMyOGJlNGE4ZjEwYTQ5OTNhZjdjNDM0ZjA5N2E4MzFmYzE3MGRjNzhkOGZkNGMwYmRmZTlkYzY4MWE0JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.JZ9-UZowuvvYWQgvklZfMb2JkphPCk_cR6yRjtif4S4)
This PR focuses on restructuring the ackermann rover module (differential and mecanum will be updated in subsequent PRs).
It also moves functions and parameters that are shared by the different rover modules to a common rover library (
rover_control
) to reduce redundancy. This library and parameters will also be used in follow up PRs for the differential and mecanum rover modules.In order to homogenize the 3 rover modules, the rate control for the ackermann module is transformed from lateral acceleration to yaw rate control (to get in line with differential/mecanum). This does not lead to a functional difference as lateral acceleration ($$a_y$$ ) and yaw rate ($$\dot{\psi}$$ ) are direclty linked with this equation: $$a_y = V \cdot \dot{\psi}$$ with $$V: $$ Forward speed.
This PR also introduces offboard support for ackermann rovers through the
trajectorySetpoint.msg
. (Works on #23663)The Ackermann module supports position and velocity setpoints.
Test coverage