Skip to content

RC Interface

Ashish Jaiswal edited this page Jul 21, 2026 · 2 revisions

RC-Interface.h

Remote control interface: read the pilot's stick/aux inputs, and inject your own RC commands for autonomous control.

Enumerations

rc_channel_e

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;

RC Data (read)

int16_t RcData_Get(rc_channel_e CHANNEL)

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 );
}

int16_t *RcData_Get(void)

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.

RC Command (read and write)

int16_t RcCommand_Get(rc_channel_e CHANNEL)

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 );
}

int16_t *RcCommand_Get(void)

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.

void RcCommand_Set(rc_channel_e CHANNEL, int16_t rcValue)

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
}

void RcCommand_Set(int16_t *rcValueArray)

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 );
}

Application

int16_t App_getAppHeading(void)

Returns the app's current heading in degrees.

void plutoLoop ( void ) {
    int16_t heading = App_getAppHeading();
    Monitor_Print ( "Heading: ", heading );
}

bool App_isArmSwitchOn(void)

Returns true if the arm switch is active.

void plutoLoop ( void ) {
    if ( App_isArmSwitchOn() ) {
        Monitor_Println ( "Arm switch ON" );
    }
}

Usage Example

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 );
    }
}

Clone this wiki locally