-
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
Add IC engine control module #24055
base: main
Are you sure you want to change the base?
Add IC engine control module #24055
Conversation
🔎 FLASH Analysispx4_fmu-v5x [Total VM Diff: 680 byte (0.03 %)]
px4_fmu-v6x [Total VM Diff: 632 byte (0.03 %)]
Updated: 2025-02-13T12:26:46 |
src/modules/internal_combustion_engine_control/InternalCombustionEngineControl.cpp
Outdated
Show resolved
Hide resolved
src/modules/internal_combustion_engine_control/InternalCombustionEngineControl.cpp
Outdated
Show resolved
Hide resolved
This pull request has been mentioned on Discussion Forum for PX4, Pixhawk, QGroundControl, MAVSDK, MAVLink. There might be relevant details there: |
src/modules/internal_combustion_engine_control/InternalCombustionEngineControl.cpp
Outdated
Show resolved
Hide resolved
src/modules/internal_combustion_engine_control/InternalCombustionEngineControl.hpp
Outdated
Show resolved
Hide resolved
src/modules/internal_combustion_engine_control/InternalCombustionEngineControl.cpp
Outdated
Show resolved
Hide resolved
src/modules/internal_combustion_engine_control/InternalCombustionEngineControl.hpp
Outdated
Show resolved
Hide resolved
src/modules/internal_combustion_engine_control/InternalCombustionEngineControl.cpp
Outdated
Show resolved
Hide resolved
src/modules/internal_combustion_engine_control/InternalCombustionEngineControl.cpp
Outdated
Show resolved
Hide resolved
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 made some comments, but in general it looks good to me
8eb6dfb
to
00375b9
Compare
d810d24
to
c5f8416
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.
Beside the small comments I would have one "feature" request: To add a 1s delay between the starting retries. That should help to reduce wear on the starter motor and makes the starter retries audibly distinguishable from each other.
src/modules/internal_combustion_engine_control/InternalCombustionEngineControl.cpp
Outdated
Show resolved
Hide resolved
Signed-off-by: Silvan Fuhrer <[email protected]>
Signed-off-by: Silvan Fuhrer <[email protected]>
Signed-off-by: Silvan Fuhrer <[email protected]>
Signed-off-by: Silvan Fuhrer <[email protected]>
Signed-off-by: Silvan Fuhrer <[email protected]>
c5f8416
to
5a28e64
Compare
c43a32b
to
f39fbb1
Compare
…starting instead of fault
f39fbb1
to
7ea59c3
Compare
7217f52
to
dd0cd98
Compare
|
||
const hrt_abstime now = hrt_absolute_time(); | ||
|
||
UserOnOffRequest user_request = UserOnOffRequest::None; |
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.
UserOnOffRequest user_request = UserOnOffRequest::None; | |
UserOnOffRequest user_request = UserOnOffRequest::Off; |
We could remove the "None" enum value then.
// without RPM feedback we assume the engine is running after the | ||
// starting procedure but only switch state if fault detection is enabled | ||
_state = State::Starting; | ||
PX4_WARN("ICE: Running Fault detected"); |
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.
This should probably be an event as well.
|
||
ICE_ON_SOURCE: | ||
description: | ||
short: Source of input to activate engine |
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.
short: Source of input to activate engine | |
short: Engine start/stop input source |
type: enum | ||
default: 0 | ||
values: | ||
0: No activation |
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.
0: No activation |
I don't think we need that option actually. And lets keep arming-disarming as default.
)DESCR_STR"); | ||
|
||
PRINT_MODULE_USAGE_NAME("internal_combustion_engine_control", "system"); | ||
PRINT_MODULE_USAGE_COMMAND_DESCR("start", "Start the background task"); |
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.
What background task?
PRINT_MODULE_DESCRIPTION( | ||
R"DESCR_STR( | ||
### Description | ||
ICE controls. | ||
)DESCR_STR"); |
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.
This needs to be any docs you want to appear in the module docs you created in PX4/PX4-user_guide#3574 - you will still need to add the images in the issue, but not the docs, which get generated from here.
You'll need to test the generation, but to do your current docs this will look something like
(see, follow on suggestion in next comment)
PRINT_MODULE_DESCRIPTION( | |
R"DESCR_STR( | |
### Description | |
ICE controls. | |
)DESCR_STR"); | |
PRINT_MODULE_DESCRIPTION( | |
R"DESCR_STR( | |
### Description | |
::: note | |
This feature is not enabled by default and needs to be configured with the rpm capture driver. | |
::: | |
The module controls the internal combustion engine ICE as described in the following architecture diagram: | |
![Architecture](../../assets/diagrams/ice_control_diagram.png) | |
The module publishes [InternalCombustionEngineControl.msg](../msg_docs/InternalCombustionEngineControl.md) containing: | |
| Message | Values | Explanation | | |
| ------------------------ | ---------- | -------------------------------------------------------- | | |
| `ignition_on` | True/False | Activate/deactivate | | |
| `throttle_control` | [0, 1] | Motor should idle with 0. Includes slew rate if enabled. | | |
| `choke_control` | [0, 1] | 1 closes the air inlet | | |
| `starter_engine_control` | [0, 1] | 1 if engine start should be delayed | | |
| `user_request` | On/Off | User intent | | |
### Implementation | |
The ICE is implemented with a (4) state machine: | |
![Architecture](../../assets/diagrams/ice_control_state_machine.png) | |
The state machine | |
- checks if [Rpm.msg](../msg_docs/Rpm.md) is updated to know if the engine is running | |
- allows for user inputs from | |
- AUX{N} | |
- Arming state in [VehicleStatus.msg(../msg_docs/VehicleStatus.md) | |
- MAVLink (TBD) | |
<a id="internal_combustion_engine_control_usage"></a> | |
)DESCR_STR"); |
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.
-
What does it mean
This feature is not enabled by default and needs to be configured with the rpm capture driver.
How?
As part of this I would state that the module is started with ICE_EN
(link to param and configured using the other ICE_
params (link to the group).
-
You might not need the table after:
The module publishes InternalCombustionEngineControl.msg.
Because now you are linking it. BUT, you should make sure that the information in this table is captured in the uorb topic (I added a comment)
-
What is the "user request" option?
-
But if you do that then you need to say a little more about what it does, so add info like that in:
The module controls the internal combustion engine ICE as described in the following architecture diagram:
So it might be more like
PRINT_MODULE_DESCRIPTION( | |
R"DESCR_STR( | |
### Description | |
ICE controls. | |
)DESCR_STR"); | |
PRINT_MODULE_DESCRIPTION( | |
R"DESCR_STR( | |
### Description | |
The module controls internal combustion engine (ICE) features including: ignition (on/off), throttle and choke level, starter engine delay, and user request. | |
The module publishes [InternalCombustionEngineControl.msg](../msg_docs/InternalCombustionEngineControl.md). | |
The architecture is as shown below.: | |
![Architecture](../../assets/diagrams/ice_control_diagram.png) | |
### Enabling | |
This feature is not enabled by default and needs to be configured with the rpm capture driver. | |
[YOUR INSTRUCTIONS here, covering ICE_EN, links to other params, any kconfig etc etc] | |
### Implementation | |
The ICE is implemented with a (4) state machine: | |
![Architecture](../../assets/diagrams/ice_control_state_machine.png) | |
The state machine: | |
- checks if [Rpm.msg](../msg_docs/Rpm.md) is updated to know if the engine is running | |
- allows for user inputs from | |
- AUX{N} | |
- Arming state in [VehicleStatus.msg(../msg_docs/VehicleStatus.md) | |
- MAVLink (TBD) | |
<a id="internal_combustion_engine_control_usage"></a> | |
)DESCR_STR"); |
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 much you do here vs in docs depends on what else you need /want to say about ICE. I think this is about right for module docs. However it might be nice to provide more context for ICE in the docs Hardware section
Note sure where, but places to consider:
uint64 timestamp # time since system start (microseconds) | ||
|
||
bool ignition_on # activate/deactivate ignition | ||
float32 throttle_control # [0,1] - Motor should idle with 0. Includes slew rate if enabled. | ||
float32 choke_control # [0,1] | ||
float32 starter_engine_control # [0,1] | ||
|
||
uint8 user_request # user intent for on/off |
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.
Anything you had in your table in the docs should be captured here in comments
| `ignition_on` | True/False | Activate/deactivate |
| `throttle_control` | [0, 1] | Motor should idle with 0. Includes slew rate if enabled. |
| `choke_control` | [0, 1] | 1 closes the air inlet |
| `starter_engine_control` | [0, 1] | 1 if engine start should be delayed |
| `user_request` | On/Off | User intent |
The RPM based functionality requires #24041
Solved Problem
Adding fuel engine support to PX4, including:
Solution
Adding now module to handle ICE acutators. It gets fed by user inputs (for now manual control) and actuator_motors (TODO: add identifier which actuator_motor instances are fuel engines), and outputs the 4 fuel engine actuators: ignition, throttle, choke, starter motor.
A flow chart of the solution:
![Screenshot from 2025-02-07 09-25-14](https://private-user-images.githubusercontent.com/60040461/410827406-1f571790-bf58-4980-84c0-0b29f384a475.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk0OTc3NTAsIm5iZiI6MTczOTQ5NzQ1MCwicGF0aCI6Ii82MDA0MDQ2MS80MTA4Mjc0MDYtMWY1NzE3OTAtYmY1OC00OTgwLTg0YzAtMGIyOWYzODRhNDc1LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTQlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE0VDAxNDQxMFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTIzMDg1MDNmOTI0MDk1Y2E5MGUxYmNiYTdjYWQ4NmYyODdhNDc3NzRkZDgyMWRiMGQ5NmMwZTQ2ZTU0NmMzMWUmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.0kAeU5BevDDn2TZOCCtGvRl7kZk_IKNeejEURspYtxA)
The proposed state machine:
![Screenshot from 2025-02-13 14-42-54](https://private-user-images.githubusercontent.com/60040461/412912068-73fa1ffa-4b5e-4694-bbae-ccde16f8116e.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk0OTc3NTAsIm5iZiI6MTczOTQ5NzQ1MCwicGF0aCI6Ii82MDA0MDQ2MS80MTI5MTIwNjgtNzNmYTFmZmEtNGI1ZS00Njk0LWJiYWUtY2NkZTE2ZjgxMTZlLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTQlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE0VDAxNDQxMFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTFhMmM2N2ZiZGJkYzFiZGYzMGYxMmIyOTI4OTJkMTk0NDQxM2M0MWZhNzQ5ODU1OGY2ZDJlNTFiYWExYWIyMjMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.lZMKJgzpp6EZ9r4H3GILCrIq3LYtuQMdYcsJmyqiWIM)
Changelog Entry
For release notes:
Alternatives / Follow-ups
Couple of ideas for followup work:
- publish engine status over MAVLink EFI_STATUS
Test coverage
Tested on bench.
Context
Note: This feature is not enabled by default and needs to be configured together with the rpm capture driver: CONFIG_MODULES_INTERNAL_COMBUSTION_ENGINE_CONTROL=y
CONFIG_DRIVERS_RPM_CAPTURE=y
Below is a plot from the test bench:
![Screenshot from 2025-02-06 12-07-44](https://private-user-images.githubusercontent.com/60040461/410482073-16a06467-6be4-4fe7-a52f-88fc231f7eb6.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk0OTc3NTAsIm5iZiI6MTczOTQ5NzQ1MCwicGF0aCI6Ii82MDA0MDQ2MS80MTA0ODIwNzMtMTZhMDY0NjctNmJlNC00ZmU3LWE1MmYtODhmYzIzMWY3ZWI2LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTQlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE0VDAxNDQxMFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTA0NjA4NTZmZWI1ZjU4MDZlYzNmMDZiNWMyMWNkNjgyMjQ4NTZiYmMxNjg3NGE0YWIyNmVjZWY0OWI5MmFkYjAmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.0rToReUH1g7KUDS4vxaNa-g4jEGUyJz6nPpn4zh1XHM)
During the starting and running state there was a fault and ICE control was able to recover.