Ground Station (GS) API
myGS
This is the main class that contains all basic flight critical functions for the ground station module
myGS.controlInputs
Struct used to store current control values to be sent to the plane. Includes the following:
- pitch_command (uint16_t)
- elevator servo position
- roll_command (uint16_t)
- aileron servo position
- yaw_command (uint16_t)
- rudder servo position
- throttle _command (uint16_t)
- ESC speed
- autopilot _command (uint16_t)
- autopilot toggle
- limiter _command (uint16_t)
- pitch and roll angle limiter toggle
- landingGear _command (uint16_t)
- landing gear toggle
- flaps_command (uint16_t)
- flaps toggle
Example Code:
myGS.controlInputs.pitch_command = 200;
myGS.telemetry
Struct used to store current telemetry data received from the plane. Includes the following:
- altitude (float)
- altitude in cm
- rollAngle (float)
- roll euler angle in degrees
- pitchAngle (float)
- pitch euler angle in degrees
- velocity (float)
- airspeed in m/s
- latitude (float)
- latitude in dd
- longitude (float)
- longitude in dd
- UTC_year (uint16_t)
- year of GPS fix
- UTC_month (uint16_t)
- month of GPS fix
- UTC_hour (uint16_t)
- hour of GPS fix
- UTC_minute (uint16_t)
- minute of GPS fix
- UTC_second (uint16_t)
- second of GPS fix
- speedOverGround (float)
- speed over ground in knots
- courseOverGround (uint16_t)
- heading in degrees
Example Code:
Serial.println(myGS.telemetry.altitude);
begin()
Class constructor for myGS. It initializes all serial ports as listed in GS_Serial.h, the Arduino built in LED, analog resolution (library uses 16 bit resolution by default), and the radio link to the plane.
Example Code:
myGS.begin();
grabData_Radio()
Uses the AirComms library to determine if new telemetry data has arrived from the plane. If so, the telemetry struct is updated with the new telemetry values. Returns one of the following integers:
- AIR_NO_DATA
- AIR_NEW_DATA
Example Code:
if(myGS.grabData_Radio() == AIR_NEW_DATA)
{
//do something
}
computeCommands()
Uses private functions to compute and update all values in the controlInputs struct before being sent to the plane.
Example Code:
myGS.computeCommands();
sendCommands()
Uses the AirComms library to send all values currently in the controlInputs struct to the plane.
Example Code:
myGS.sendCommands();
computeAndSendCommands()
Uses computeCommands() and sendCommands() to automatically compute and transfer new command data to the plane.
Example Code:
myGS.sendCommands();
Serial Constants
- GS_DEBUG_PORT_NUMBER
- Debugging serial port number
- 0 (Serial) by default
- GS_COMMAND_PORT_NUMBER
- Serial port number the command/control radio is connected to
- 4 (Serial4) by default
- GS_TELEM_PORT_NUMBER
- Serial port number the telemetry radio is connected to
- 5 (Serial5) by default
Main Constants
Analog Pins
- YAW_ANALOG_PIN
- The analog pin number connected to the yaw joystick output
- 0 by default
- THROTTLE_ANALOG_PIN
- The analog pin number connected to the throttle joystick output
- 1 by default
- ROLL_ANALOG_PIN
- The analog pin number connected to the roll joystick output
- 2 by default
- PITCH_ANALOG_PIN
- The analog pin number connected to the pitch joystick output
- 3 by default
Rate Pins
- PITCH_RATE_PIN
- The digital pin number connected to the pitch high/lowrate switch
- Uses internal pullup resistor
- 0 by default
- ROLL_RATE_PIN
- The digital pin number connected to the roll high/lowrate switch
- Uses internal pullup resistor
- 1 by default
- YAW_RATE_PIN
- The digital pin number connected to the yaw high/lowrate switch
- Uses internal pullup resistor
- 2 by default
Servo Offsets
- AILERON_OFFSET
- Servo offset from center of range AILERON_MIN to AILERON_MAX
- 0 by default
- ELEVATOR_OFFSET
- Servo offset from center of range ELEVATOR_MIN to ELEVATOR_MAX
- 0 by default
- RUDDER_OFFSET
- Servo offset from center of range RUDDER_MIN to RUDDER_MAX
- 0 by default
- THROTTLE_OFFSET
- ESC offset from center of range THROTTLE_MIN to THROTTLE_MAX
- 0 by default
Maximum Servo Inputs on Low Rates
- AILERON_MAX_LOWRATES
- Max servo input when low rates for roll is used
- 325 by default
- ELEVATOR_MAX_LOWRATES
- Max servo input when low rates for pitch is used
- 350 by default
- RUDDER_MAX_LOWRATES
- Max servo input when low rates for yaw is used
- 292 by default
Minimum Servo Inputs on Low Rates
- AILERON_MIN_LOWRATES
- Min servo input when low rates for roll is used
- 289 by default
- ELEVATOR_MIN_LOWRATES
- Min servo input when low rates for pitch is used
- 264 by default
- RUDDER_MIN_LOWRATES
- Min servo input when low rates for yaw is used
- 264 by default
Maximum Expected ADC Values From Joysticks
- THROTTLE_MAX_ADC
- Max expected ADC value from the throttle joystick output
- 61220 by default
- AILERON_MAX_ADC
- Max expected ADC value from the roll joystick output
- 60180 by default
- ELEVATOR_MAX_ADC
- Max expected ADC value from the pitch joystick output
- 62300 by default
- RUDDER_MAX_ADC
- Max expected ADC value from the throttle yaw output
- 62170 by default
Minimum Expected ADC Values From Joysticks
- THROTTLE_MIN_ADC
- Min expected ADC value from the throttle joystick output
- 35880 by default
- AILERON_MIN_ADC
- Min expected ADC value from the roll joystick output
- 35300 by default
- ELEVATOR_MIN_ADC
- Min expected ADC value from the pitch joystick output
- 36620 by default
- RUDDER_MIN_ADC
- Min expected ADC value from the yaw joystick output
- 37330 by default
Example Sketch
#include "GS_Tools.h"
void setup()
{
//initialize the core ground station software class
myGS.begin();
}
void loop()
{
//get telemetry data from the plane
if(myGS.grabData_Radio())
{
//send data to datalogging computer via debugging port
myGS.sendTelem();
}
//determine each command value based off GS sensor data and send commands to plane
myGS.computeAndSendCommands();
}