2011-09-08 22:29:39 -03:00
|
|
|
// -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*-
|
|
|
|
|
2011-09-18 00:33:01 -03:00
|
|
|
#ifndef _DEFINES_H
|
|
|
|
#define _DEFINES_H
|
|
|
|
|
2011-09-08 22:29:39 -03:00
|
|
|
// Internal defines, don't edit and expect things to work
|
|
|
|
// -------------------------------------------------------
|
|
|
|
|
|
|
|
#define TRUE 1
|
|
|
|
#define FALSE 0
|
2012-12-19 02:02:13 -04:00
|
|
|
#define ToRad(x) radians(x) // *pi/180
|
|
|
|
#define ToDeg(x) degrees(x) // *180/pi
|
2011-09-08 22:29:39 -03:00
|
|
|
|
|
|
|
#define DEBUG 0
|
|
|
|
#define LOITER_RANGE 60 // for calculating power outside of loiter radius
|
2012-08-16 21:50:16 -03:00
|
|
|
#define SERVO_MAX 4500 // This value represents 45 degrees and is just an
|
|
|
|
// arbitrary representation of servo max travel.
|
2011-09-08 22:29:39 -03:00
|
|
|
|
2011-09-09 11:18:38 -03:00
|
|
|
// failsafe
|
2011-09-08 22:29:39 -03:00
|
|
|
// ----------------------
|
2012-08-16 21:50:16 -03:00
|
|
|
#define FAILSAFE_NONE 0
|
|
|
|
#define FAILSAFE_SHORT 1
|
|
|
|
#define FAILSAFE_LONG 2
|
|
|
|
#define FAILSAFE_GCS 3
|
|
|
|
#define FAILSAFE_SHORT_TIME 1500 // Miliiseconds
|
|
|
|
#define FAILSAFE_LONG_TIME 20000 // Miliiseconds
|
2011-09-08 22:29:39 -03:00
|
|
|
|
|
|
|
|
|
|
|
// active altitude sensor
|
|
|
|
// ----------------------
|
|
|
|
#define SONAR 0
|
|
|
|
#define BARO 1
|
|
|
|
|
2011-11-13 00:08:04 -04:00
|
|
|
#define PITOT_SOURCE_ADC 1
|
|
|
|
#define PITOT_SOURCE_ANALOG_PIN 2
|
|
|
|
|
2011-09-08 22:29:39 -03:00
|
|
|
#define T6 1000000
|
|
|
|
#define T7 10000000
|
|
|
|
|
|
|
|
// GPS type codes - use the names, not the numbers
|
2012-08-16 21:50:16 -03:00
|
|
|
#define GPS_PROTOCOL_NONE -1
|
|
|
|
#define GPS_PROTOCOL_NMEA 0
|
|
|
|
#define GPS_PROTOCOL_SIRF 1
|
|
|
|
#define GPS_PROTOCOL_UBLOX 2
|
|
|
|
#define GPS_PROTOCOL_IMU 3
|
|
|
|
#define GPS_PROTOCOL_MTK 4
|
|
|
|
#define GPS_PROTOCOL_HIL 5
|
2012-12-21 15:19:32 -04:00
|
|
|
#define GPS_PROTOCOL_MTK19 6
|
2012-08-16 21:50:16 -03:00
|
|
|
#define GPS_PROTOCOL_AUTO 7
|
2011-09-08 22:29:39 -03:00
|
|
|
|
|
|
|
#define CH_ROLL CH_1
|
|
|
|
#define CH_PITCH CH_2
|
|
|
|
#define CH_THROTTLE CH_3
|
|
|
|
#define CH_RUDDER CH_4
|
|
|
|
#define CH_YAW CH_4
|
|
|
|
|
|
|
|
// HIL enumerations
|
2012-08-16 21:50:16 -03:00
|
|
|
#define HIL_MODE_DISABLED 0
|
|
|
|
#define HIL_MODE_ATTITUDE 1
|
|
|
|
#define HIL_MODE_SENSORS 2
|
2011-09-08 22:29:39 -03:00
|
|
|
|
2012-11-30 05:34:56 -04:00
|
|
|
enum FlightMode {
|
2012-12-04 02:32:37 -04:00
|
|
|
MANUAL = 0,
|
|
|
|
CIRCLE = 1,
|
|
|
|
STABILIZE = 2,
|
|
|
|
TRAINING = 3,
|
2012-11-30 05:34:56 -04:00
|
|
|
FLY_BY_WIRE_A = 5,
|
|
|
|
FLY_BY_WIRE_B = 6,
|
2012-12-04 02:32:37 -04:00
|
|
|
AUTO = 10,
|
|
|
|
RTL = 11,
|
|
|
|
LOITER = 12,
|
|
|
|
GUIDED = 15,
|
|
|
|
INITIALISING = 16
|
2012-11-30 05:34:56 -04:00
|
|
|
};
|
2011-09-08 22:29:39 -03:00
|
|
|
|
|
|
|
|
2012-08-16 21:50:16 -03:00
|
|
|
// Commands - Note that APM now uses a subset of the MAVLink protocol
|
|
|
|
// commands. See enum MAV_CMD in the GCS_Mavlink library
|
|
|
|
#define CMD_BLANK 0 // there is no command stored in the mem location
|
|
|
|
// requested
|
2011-09-08 22:29:39 -03:00
|
|
|
#define NO_COMMAND 0
|
2011-10-27 16:43:19 -03:00
|
|
|
#define WAIT_COMMAND 255
|
2011-09-08 22:29:39 -03:00
|
|
|
|
|
|
|
// Command/Waypoint/Location Options Bitmask
|
|
|
|
//--------------------
|
2012-08-16 21:50:16 -03:00
|
|
|
#define MASK_OPTIONS_RELATIVE_ALT (1<<0) // 1 = Relative
|
|
|
|
// altitude
|
2011-09-08 22:29:39 -03:00
|
|
|
|
|
|
|
//repeating events
|
|
|
|
#define NO_REPEAT 0
|
|
|
|
#define CH_5_TOGGLE 1
|
|
|
|
#define CH_6_TOGGLE 2
|
|
|
|
#define CH_7_TOGGLE 3
|
|
|
|
#define CH_8_TOGGLE 4
|
|
|
|
#define RELAY_TOGGLE 5
|
|
|
|
#define STOP_REPEAT 10
|
|
|
|
|
|
|
|
// GCS Message ID's
|
2011-09-09 11:18:38 -03:00
|
|
|
/// NOTE: to ensure we never block on sending MAVLink messages
|
|
|
|
/// please keep each MSG_ to a single MAVLink message. If need be
|
|
|
|
/// create new MSG_ IDs for additional messages on the same
|
2011-09-13 17:00:28 -03:00
|
|
|
/// stream
|
2011-09-18 00:33:01 -03:00
|
|
|
enum ap_message {
|
|
|
|
MSG_HEARTBEAT,
|
|
|
|
MSG_ATTITUDE,
|
|
|
|
MSG_LOCATION,
|
|
|
|
MSG_EXTENDED_STATUS1,
|
|
|
|
MSG_EXTENDED_STATUS2,
|
|
|
|
MSG_NAV_CONTROLLER_OUTPUT,
|
|
|
|
MSG_CURRENT_WAYPOINT,
|
|
|
|
MSG_VFR_HUD,
|
|
|
|
MSG_RADIO_OUT,
|
|
|
|
MSG_RADIO_IN,
|
|
|
|
MSG_RAW_IMU1,
|
|
|
|
MSG_RAW_IMU2,
|
|
|
|
MSG_RAW_IMU3,
|
|
|
|
MSG_GPS_RAW,
|
|
|
|
MSG_SERVO_OUT,
|
2011-09-18 03:39:09 -03:00
|
|
|
MSG_NEXT_WAYPOINT,
|
|
|
|
MSG_NEXT_PARAM,
|
2011-09-18 05:57:41 -03:00
|
|
|
MSG_STATUSTEXT,
|
2011-12-15 21:41:11 -04:00
|
|
|
MSG_FENCE_STATUS,
|
2012-03-11 05:13:31 -03:00
|
|
|
MSG_AHRS,
|
2012-03-01 00:23:00 -04:00
|
|
|
MSG_SIMSTATE,
|
|
|
|
MSG_HWSTATUS,
|
2012-08-11 02:57:13 -03:00
|
|
|
MSG_WIND,
|
2011-09-18 00:33:01 -03:00
|
|
|
MSG_RETRY_DEFERRED // this must be last
|
|
|
|
};
|
2011-09-08 22:29:39 -03:00
|
|
|
|
2011-09-18 05:02:33 -03:00
|
|
|
enum gcs_severity {
|
|
|
|
SEVERITY_LOW=1,
|
|
|
|
SEVERITY_MEDIUM,
|
|
|
|
SEVERITY_HIGH,
|
|
|
|
SEVERITY_CRITICAL
|
|
|
|
};
|
2011-09-08 22:29:39 -03:00
|
|
|
|
|
|
|
// Logging parameters
|
2012-08-16 21:50:16 -03:00
|
|
|
#define LOG_INDEX_MSG 0xF0
|
|
|
|
#define LOG_ATTITUDE_MSG 0x01
|
|
|
|
#define LOG_GPS_MSG 0x02
|
|
|
|
#define LOG_MODE_MSG 0X03
|
|
|
|
#define LOG_CONTROL_TUNING_MSG 0X04
|
|
|
|
#define LOG_NAV_TUNING_MSG 0X05
|
|
|
|
#define LOG_PERFORMANCE_MSG 0X06
|
|
|
|
#define LOG_RAW_MSG 0x07
|
|
|
|
#define LOG_CMD_MSG 0x08
|
|
|
|
#define LOG_CURRENT_MSG 0x09
|
|
|
|
#define LOG_STARTUP_MSG 0x0A
|
|
|
|
#define TYPE_AIRSTART_MSG 0x00
|
|
|
|
#define TYPE_GROUNDSTART_MSG 0x01
|
|
|
|
#define MAX_NUM_LOGS 100
|
|
|
|
|
|
|
|
#define MASK_LOG_ATTITUDE_FAST (1<<0)
|
|
|
|
#define MASK_LOG_ATTITUDE_MED (1<<1)
|
|
|
|
#define MASK_LOG_GPS (1<<2)
|
|
|
|
#define MASK_LOG_PM (1<<3)
|
|
|
|
#define MASK_LOG_CTUN (1<<4)
|
|
|
|
#define MASK_LOG_NTUN (1<<5)
|
|
|
|
#define MASK_LOG_MODE (1<<6)
|
|
|
|
#define MASK_LOG_RAW (1<<7)
|
|
|
|
#define MASK_LOG_CMD (1<<8)
|
|
|
|
#define MASK_LOG_CUR (1<<9)
|
2011-09-08 22:29:39 -03:00
|
|
|
|
|
|
|
// Waypoint Modes
|
|
|
|
// ----------------
|
|
|
|
#define ABS_WP 0
|
|
|
|
#define REL_WP 1
|
|
|
|
|
|
|
|
// Command Queues
|
|
|
|
// ---------------
|
|
|
|
#define COMMAND_MUST 0
|
|
|
|
#define COMMAND_MAY 1
|
|
|
|
#define COMMAND_NOW 2
|
|
|
|
|
|
|
|
// Events
|
|
|
|
// ------
|
|
|
|
#define EVENT_WILL_REACH_WAYPOINT 1
|
2011-10-25 22:27:23 -03:00
|
|
|
#define EVENT_SET_NEW_COMMAND_INDEX 2
|
2011-09-08 22:29:39 -03:00
|
|
|
#define EVENT_LOADED_WAYPOINT 3
|
|
|
|
#define EVENT_LOOP 4
|
|
|
|
|
|
|
|
// Climb rate calculations
|
2012-08-16 21:50:16 -03:00
|
|
|
#define ALTITUDE_HISTORY_LENGTH 8 //Number of (time,altitude) points to
|
|
|
|
// regress a climb rate from
|
2011-09-08 22:29:39 -03:00
|
|
|
|
|
|
|
|
2011-09-13 17:00:28 -03:00
|
|
|
#define BATTERY_VOLTAGE(x) (x*(g.input_voltage/1024.0))*g.volt_div_ratio
|
2012-11-20 22:33:23 -04:00
|
|
|
#define CURRENT_AMPS(x) ((x*(g.input_voltage/1024.0))-g.curr_amp_offset)*g.curr_amp_per_volt
|
2011-09-08 22:29:39 -03:00
|
|
|
|
2012-08-16 21:50:16 -03:00
|
|
|
#define AN4 4
|
|
|
|
#define AN5 5
|
2011-09-08 22:29:39 -03:00
|
|
|
|
2012-08-16 21:50:16 -03:00
|
|
|
#define SPEEDFILT 400 // centimeters/second; the speed below
|
|
|
|
// which a groundstart will be
|
|
|
|
// triggered
|
2011-09-08 22:29:39 -03:00
|
|
|
|
|
|
|
|
|
|
|
// EEPROM addresses
|
2012-08-16 21:50:16 -03:00
|
|
|
#define EEPROM_MAX_ADDR 4096
|
2012-02-17 19:51:17 -04:00
|
|
|
// parameters get the first 1280 bytes of EEPROM, remainder is for waypoints
|
2012-08-16 21:50:16 -03:00
|
|
|
#define WP_START_BYTE 0x500 // where in memory home WP is stored + all other
|
|
|
|
// WP
|
2011-09-08 22:29:39 -03:00
|
|
|
#define WP_SIZE 15
|
|
|
|
|
2011-12-15 03:08:58 -04:00
|
|
|
// fence points are stored at the end of the EEPROM
|
|
|
|
#define MAX_FENCEPOINTS 20
|
2011-12-15 22:48:15 -04:00
|
|
|
#define FENCE_WP_SIZE sizeof(Vector2l)
|
2011-12-15 03:08:58 -04:00
|
|
|
#define FENCE_START_BYTE (EEPROM_MAX_ADDR-(MAX_FENCEPOINTS*FENCE_WP_SIZE))
|
|
|
|
|
2012-08-16 21:50:16 -03:00
|
|
|
#define MAX_WAYPOINTS ((FENCE_START_BYTE - WP_START_BYTE) / WP_SIZE) - 1 // -
|
|
|
|
// 1
|
|
|
|
// to
|
|
|
|
// be
|
|
|
|
// safe
|
2011-12-15 03:08:58 -04:00
|
|
|
|
2012-08-16 21:50:16 -03:00
|
|
|
// convert a boolean (0 or 1) to a sign for multiplying (0 maps to 1, 1 maps
|
|
|
|
// to -1)
|
|
|
|
#define BOOL_TO_SIGN(bvalue) ((bvalue) ? -1 : 1)
|
2011-09-18 00:33:01 -03:00
|
|
|
|
2011-09-18 03:39:09 -03:00
|
|
|
// mark a function as not to be inlined
|
|
|
|
#define NOINLINE __attribute__((noinline))
|
|
|
|
|
2012-11-05 00:32:13 -04:00
|
|
|
#define CONFIG_INS_OILPAN 1
|
|
|
|
#define CONFIG_INS_MPU6000 2
|
2012-12-17 22:31:56 -04:00
|
|
|
#define CONFIG_INS_STUB 3
|
2011-11-13 00:08:04 -04:00
|
|
|
|
2011-11-27 02:07:49 -04:00
|
|
|
#define AP_BARO_BMP085 1
|
|
|
|
#define AP_BARO_MS5611 2
|
2013-01-04 06:07:56 -04:00
|
|
|
#define AP_BARO_PX4 3
|
2011-11-27 02:07:49 -04:00
|
|
|
|
2012-08-28 00:15:04 -03:00
|
|
|
// altitude control algorithms
|
|
|
|
enum {
|
|
|
|
ALT_CONTROL_DEFAULT=0,
|
|
|
|
ALT_CONTROL_NON_AIRSPEED=1
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2011-09-18 00:33:01 -03:00
|
|
|
#endif // _DEFINES_H
|