-
Notifications
You must be signed in to change notification settings - Fork 7
RC Interface
Remote control interface: read the pilot's stick/aux inputs, and inject your own RC commands for autonomous control.
Channel index used by the read/write functions.
typedef enum {
RC_ROLL, // Roll channel
RC_PITCH, // Pitch channel
RC_YAW, // Yaw channel
RC_THROTTLE, // Throttle channel
RC_AUX1, // Auxiliary channel 1
RC_AUX2, // Auxiliary channel 2
RC_AUX3, // Auxiliary channel 3
RC_AUX4, // Auxiliary channel 4
RC_USER1, // User-defined channel 1
RC_USER2, // User-defined channel 2
RC_USER3 // User-defined channel 3
} rc_channel_e;Returns the raw stick value for a channel (1000 - 2000). Poll it in the loop.
void plutoLoop ( void ) {
int16_t throttle = RcData_Get ( RC_THROTTLE ); // 1000 - 2000
Monitor_Print ( "Throttle: ", throttle );
}Returns a pointer to a copy of the RC data array.
Caveat: per the header this pointer is to a local array (undefined behavior). Prefer the channel-indexed
RcData_Get(CHANNEL)above.
Returns the processed command, offset by 1500 (roll/pitch/yaw are approximately -500 to +500). Poll it in the loop.
void plutoLoop ( void ) {
int16_t rollCmd = RcCommand_Get ( RC_ROLL ); // approx -500 to +500
Monitor_Print ( "Roll cmd: ", rollCmd );
}Returns a pointer to a copy of the RC command array.
Caveat: per the header this pointer is to a local array (undefined behavior). Prefer the channel-indexed
RcCommand_Get(CHANNEL)above.
Injects a command on one channel. Pass a raw value (1000 - 2000); the firmware constrains it and, for roll/pitch/yaw, offsets it by 1500 internally (throttle is applied directly). Drive it from the loop for autonomous control.
void plutoLoop ( void ) {
RcCommand_Set ( RC_ROLL, 1600 ); // roll right
RcCommand_Set ( RC_PITCH, 1400 ); // pitch forward
}Injects roll, pitch, yaw, and throttle at once from the first four raw values (1000 - 2000) of the array.
void plutoLoop ( void ) {
int16_t rc[4] = { 1600, 1400, 1500, 1300 }; // roll, pitch, yaw, throttle
RcCommand_Set ( rc );
}Returns the app's current heading in degrees.
void plutoLoop ( void ) {
int16_t heading = App_getAppHeading();
Monitor_Print ( "Heading: ", heading );
}Returns true if the arm switch is active.
void plutoLoop ( void ) {
if ( App_isArmSwitchOn() ) {
Monitor_Println ( "Arm switch ON" );
}
}Read the pilot's inputs, and inject a command when a condition is met.
#include "PlutoPilot.h"
void plutoLoop ( void ) {
// Read the pilot's sticks (raw 1000 - 2000).
int16_t throttle = RcData_Get ( RC_THROTTLE );
int16_t rollCmd = RcCommand_Get ( RC_ROLL ); // approx -500 to +500
Monitor_Print ( "Throttle: ", throttle );
Monitor_Print ( "Roll cmd: ", rollCmd );
// Autonomous nudge: hold a gentle right roll while armed.
if ( App_isArmSwitchOn() ) {
RcCommand_Set ( RC_ROLL, 1550 );
}
}MagisV2 © 2026 Drona Aviation | Licensed under GPL-3.0 | Report Issues