Skip to content
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

ROMFS: disable esc failure detector for fixed-wing simulations #23586

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

MAD-CRAZY-MAN
Copy link
Contributor

Problem

When running SITL simulations for fixed-wing models like rc_cessna or advanced_plane, arming the system in manual or position mode results in an ESC Failure, preventing the system from arming.

Solution

This issue can be resolved by disabling the ESC failure detector (FD_ESCS_EN: 0).

The ESC failure detector monitors the esc_armed_flags from the esc_status topic. In real aircraft, motor output drivers like PX4IO or pwm_out check whether the ESC is actually armed.

However, in a simulation environment, the ESC status is inferred from the actuator's velocity using the gz_bridge module (as implemented in GZMixingInterfaceESC.cpp).
For fixed-wing aircraft, the motor does not spin until the throttle is increased, even when the system is armed. Therefore, it is necessary to disable the ESC failure detector for fixed-wing simulations.

@dagar
Copy link
Member

dagar commented Aug 26, 2024

Arguably the real problem is the way we're setting ESC armed here?

if (actuators.velocity(i) > 0) {
esc_status.esc_armed_flags |= 1 << i;
}

Why don't we just change it so that it's respected armed from the mixer module instead?

@MAD-CRAZY-MAN
Copy link
Contributor Author

Arguably the real problem is the way we're setting ESC armed here?

if (actuators.velocity(i) > 0) {
esc_status.esc_armed_flags |= 1 << i;
}

Why don't we just change it so that it's respected armed from the mixer module instead?

Yes, the issue is setting the ESC armed flag based on motor velocity. As you suggested, modifying the mixer module is a better approach. thank you.

I’d like to rectify my previous information.
The px4io and pwm_out modules do not receive esc telemetry data, so they do not publish 'esc_status' topic. Instead, modules like 'dshot', 'gz_bridge' and 'simulator_mavlink' do.

Here`s what i found:

  1. The simulator_mavlink module(for JMAVSim and gazebo-classic), whitch performs a similar role to gz_bridge, marks all ESCs as online and armed.

    esc_status.esc_armed_flags = (1u << esc_status.esc_count) - 1;
    esc_status.esc_online_flags = (1u << esc_status.esc_count) - 1;

  2. Even the dshot module marks all ESCs as online and armed due to a single dropcut issue.

    // FIXME: mark all UART Telemetry ESC's as online, otherwise commander complains even for a single dropout
    esc_status.esc_count = _telemetry->handler.numMotors();
    esc_status.esc_online_flags = (1 << esc_status.esc_count) - 1;
    esc_status.esc_armed_flags = (1 << esc_status.esc_count) - 1;

Since using motor velocity for the ESC armed flag is inaccurate and unnecessary for simulations, I`ve updated the system to mark all ESCs as armed, regardless of motor velocity.

@MAD-CRAZY-MAN MAD-CRAZY-MAN force-pushed the pr_airframes_gz-fixedwing branch from 43a01bc to 73f9bd1 Compare August 27, 2024 05:38
@MAD-CRAZY-MAN
Copy link
Contributor Author

any feedback? @dagar

@github-actions github-actions bot added the stale label Oct 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants