I am currently using Mission Planner with a Pixhawk. As I am new to ardupilot, i just made my first flight mode. It doesn’t do anything, but after adding the appropriate parameters to Mission Planner, It is showing up! However, anything I added to the parameters shows up regardless if code exists for the flight mode. My idea was to have the buzzer beep once it entered the custom flight mode so i know the build on the Pixhawk of the custom flight mode is getting called properly. I can’t seem to find how to interface with the buzzer and make it beep through the new mode code. I’ve looked through AP_Notify but I only have a year’s worth of experience with c++. Any help would be greatly appreciated!
Add a state variable here:
bool firmware_update; // true just before vehicle firmware is updated
bool compass_cal_running; // true if a compass calibration is running
bool leak_detected; // true if leak detected
bool gps_fusion; // true if the GPS is in use by EKF, usable for flight
bool gps_glitching; // true f the GPS is believed to be glitching is affecting navigation accuracy
bool have_pos_abs; // true if absolute position is available
bool vehicle_lost; // true when lost copter tone is requested (normally only used for copter)
bool waiting_for_throw; // true when copter is in THROW mode and waiting to detect the user hand launch
bool powering_off; // true when the vehicle is powering off
bool video_recording; // true when the vehicle is recording video
};
/// notify_events_type - bitmask of active events.
// Notify library is responsible for setting back to zero after notification has been completed
struct notify_events_type {
uint32_t arming_failed : 1; // 1 if copter failed to arm after user input
uint32_t user_mode_change : 1; // 1 if user has initiated a flight mode change
uint32_t user_mode_change_failed: 1; // 1 when user initiated flight mode change fails
uint32_t failsafe_mode_change : 1; // 1 when failsafe has triggered a flight mode change
uint32_t autotune_complete : 1; // 1 when autotune has successfully completed
uint32_t autotune_failed : 1; // 1 when autotune has failed
Frob that on in your init method (AP_Notify::flags.daniels_mode = 1;) and
off in Copter::exit_mode
Add a block in here to play a tone:
Add your tone here:
#define AP_NOTIFY_TONE_TUNING_SAVE 24
{ "MFT100L10DBDB>", false},
#define AP_NOTIFY_TONE_TUNING_ERROR 25
{ "MFT100L10>BBBBBBBB", false},
#define AP_NOTIFY_TONE_LEAK_DETECTED 26
{ "MBT255L8>A+AA-", true},
#define AP_NOTIFY_TONE_QUIET_SHUTDOWN 27
{ "MFMST200L32O3ceP32cdP32ceP32c<c>c<cccP8L32>c>c<P32<c<c", false },
#define AP_NOTIFY_TONE_QUIET_NOT_READY_OR_NOT_FINISHED 28
{ "MFT200L4<B#4A#6G#6", false },
#define AP_NOTIFY_TONE_STARTUP 29
{ "MFT240L8O4aO5dcO4aO5dcO4aO5dcL16dcdcdcdc", false },
};
bool AP_ToneAlarm::init()
{
if (pNotify->buzzer_enabled() == false) {
return false;
}
if (!hal.util->toneAlarm_init()) {
return false;
… and then do all the things I’ve forgotten about
3 Likes
Thank you so much! My flight mode activates perfectly. I appreciate your help.