Skip to content

Commit

Permalink
[telemetry] protect telemetry code with #if DOWNLINK
Browse files Browse the repository at this point in the history
- also get rid of AP_DOWNLINK and FBW_DOWNLINK
- still needs to make it work again (for the only remaining classix in
  the world...)
  • Loading branch information
gautierhattenberger committed Jun 16, 2013
1 parent 6ec20fd commit 116faae
Show file tree
Hide file tree
Showing 38 changed files with 203 additions and 125 deletions.
2 changes: 1 addition & 1 deletion conf/firmwares/setup.makefile
Expand Up @@ -84,7 +84,7 @@ setup_actuators.CFLAGS += -DUSE_$(MODEM_PORT)
setup_actuators.CFLAGS += -D$(MODEM_PORT)_BAUD=$(MODEM_BAUD)
setup_actuators.srcs += mcu_periph/uart.c $(SRC_ARCH)/mcu_periph/uart_arch.c

setup_actuators.CFLAGS += -DDOWNLINK -DDOWNLINK_FBW_DEVICE=$(MODEM_PORT) -DDOWNLINK_AP_DEVICE=$(MODEM_PORT) -DPPRZ_UART=$(MODEM_PORT)
setup_actuators.CFLAGS += -DDOWNLINK -DDOWNLINK_DEVICE=$(MODEM_PORT) -DPPRZ_UART=$(MODEM_PORT)
setup_actuators.CFLAGS += -DDOWNLINK_TRANSPORT=PprzTransport -DDATALINK=PPRZ
setup_actuators.srcs += subsystems/datalink/downlink.c subsystems/datalink/pprz_transport.c
ifneq ($(SYS_TIME_LED),none)
Expand Down
Expand Up @@ -4,7 +4,7 @@
ap.CFLAGS += -DUSE_$(MODEM_PORT)
ap.CFLAGS += -D$(MODEM_PORT)_BAUD=$(MODEM_BAUD)

ap.CFLAGS += -DDOWNLINK -DDOWNLINK_FBW_DEVICE=$(MODEM_PORT) -DDOWNLINK_AP_DEVICE=$(MODEM_PORT) -DPPRZ_UART=$(MODEM_PORT)
ap.CFLAGS += -DDOWNLINK -DDOWNLINK_DEVICE=$(MODEM_PORT) -DPPRZ_UART=$(MODEM_PORT)
ap.CFLAGS += -DDOWNLINK_TRANSPORT=PprzTransport -DDATALINK=PPRZ
ap.srcs += subsystems/datalink/downlink.c subsystems/datalink/pprz_transport.c
ap.srcs += $(SRC_FIRMWARE)/datalink.c
Expand Up @@ -4,7 +4,7 @@
#serial USB (e.g. /dev/ttyACM0)

ifeq ($(ARCH), lpc21)
ap.CFLAGS += -DDOWNLINK -DDOWNLINK_FBW_DEVICE=UsbS -DDOWNLINK_AP_DEVICE=UsbS -DPPRZ_UART=UsbS
ap.CFLAGS += -DDOWNLINK -DDOWNLINK_DEVICE=UsbS -DPPRZ_UART=UsbS
ap.CFLAGS += -DDOWNLINK_TRANSPORT=PprzTransport -DDATALINK=PPRZ -DUSE_USB_SERIAL -DUSE_USB_HIGH_PCLK
ap.srcs += subsystems/datalink/downlink.c subsystems/datalink/pprz_transport.c
ap.srcs += $(SRC_FIRMWARE)/datalink.c
Expand Down
Expand Up @@ -7,7 +7,7 @@ W5100_SUBNET ?= "255,255,255,0"
W5100_MULTICAST_IP ?= "224,1,1,11"
W5100_MULTICAST_PORT ?= "1234"

ap.CFLAGS += -DDOWNLINK -DDOWNLINK_FBW_DEVICE=W5100 -DDOWNLINK_AP_DEVICE=W5100
ap.CFLAGS += -DDOWNLINK -DDOWNLINK_DEVICE=W5100
ap.CFLAGS += -DDOWNLINK_TRANSPORT=W5100Transport -DDATALINK=W5100
ap.CFLAGS += -DW5100_IP=$(W5100_IP) -DW5100_SUBNET=$(W5100_SUBNET) -DW5100_MULTICAST_IP=$(W5100_MULTICAST_IP) -DW5100_MULTICAST_PORT=$(W5100_MULTICAST_PORT)
ap.srcs += subsystems/datalink/downlink.c subsystems/datalink/w5100.c
Expand Down
Expand Up @@ -5,7 +5,7 @@
ap.CFLAGS += -DUSE_$(MODEM_PORT)
ap.CFLAGS += -D$(MODEM_PORT)_BAUD=$(MODEM_BAUD) -DXBEE_BAUD=$(MODEM_BAUD)

ap.CFLAGS += -DDOWNLINK -DDOWNLINK_FBW_DEVICE=$(MODEM_PORT) -DDOWNLINK_AP_DEVICE=$(MODEM_PORT) -DXBEE_UART=$(MODEM_PORT)
ap.CFLAGS += -DDOWNLINK -DDOWNLINK_DEVICE=$(MODEM_PORT) -DXBEE_UART=$(MODEM_PORT)
ap.CFLAGS += -DDOWNLINK_TRANSPORT=XBeeTransport -DDATALINK=XBEE
ap.srcs += subsystems/datalink/downlink.c subsystems/datalink/xbee.c
ap.srcs += $(SRC_FIRMWARE)/datalink.c
10 changes: 7 additions & 3 deletions sw/airborne/boards/ardrone/navdata.c
Expand Up @@ -36,11 +36,11 @@
#include <math.h>
#include "navdata.h"

#include "subsystems/datalink/downlink.h"
#include "generated/periodic_telemetry.h"

int nav_fd;

#if DOWNLINK
#include "subsystems/datalink/telemetry.h"

static void send_navdata(void) {
DOWNLINK_SEND_ARDRONE_NAVDATA(DefaultChannel, DefaultDevice,
&navdata->taille,
Expand Down Expand Up @@ -72,6 +72,7 @@ static void send_navdata(void) {
&navdata->mz,
&navdata->chksum);
}
#endif

int navdata_init()
{
Expand Down Expand Up @@ -122,7 +123,10 @@ int navdata_init()

previousUltrasoundHeight = 0;

#if DOWNLINK
register_periodic_telemetry(DefaultPeriodic, "ARDRONE_NAVDATA", send_navdata);
#endif

return 0;
}

Expand Down
Expand Up @@ -36,12 +36,6 @@
#include CTRL_TYPE_H
#include "firmwares/fixedwing/autopilot.h"

#ifndef DOWNLINK_DEVICE
#define DOWNLINK_DEVICE DOWNLINK_AP_DEVICE
#endif
#include "subsystems/datalink/downlink.h"
#include "generated/periodic_telemetry.h"

/* outer loop parameters */
float h_ctl_course_setpoint; /* rad, CW/north */
float h_ctl_course_pre_bank;
Expand Down Expand Up @@ -149,6 +143,9 @@ inline static void h_ctl_pitch_loop( void );
#define H_CTL_PITCH_KFFD 0.
#endif

#if DOWNLINK
#include "subsystems/datalink/telemetry.h"

static void send_calibration(void) {
DOWNLINK_SEND_CALIBRATION(DefaultChannel, DefaultDevice, &v_ctl_auto_throttle_sum_err, &v_ctl_auto_throttle_submode);
}
Expand All @@ -162,7 +159,7 @@ static void send_ctl_a(void) {
DOWNLINK_SEND_H_CTL_A(DefaultChannel, DefaultDevice,
&h_ctl_roll_sum_err, &h_ctl_ref_roll_angle, &h_ctl_pitch_sum_err, &h_ctl_ref_pitch_angle)
}

#endif

void h_ctl_init( void ) {
h_ctl_course_setpoint = 0.;
Expand Down Expand Up @@ -211,9 +208,11 @@ void h_ctl_init( void ) {
v_ctl_pitch_dash_trim = 0.;
#endif

#if DOWNLINK
register_periodic_telemetry(DefaultPeriodic, "CALIBRATION", send_calibration);
register_periodic_telemetry(DefaultPeriodic, "TUNE_ROLL", send_tune_roll);
register_periodic_telemetry(DefaultPeriodic, "H_CTL_A", send_ctl_a);
#endif
}

/**
Expand Down
Expand Up @@ -35,12 +35,6 @@
#include CTRL_TYPE_H
#include "firmwares/fixedwing/autopilot.h"

#ifndef DOWNLINK_DEVICE
#define DOWNLINK_DEVICE DOWNLINK_AP_DEVICE
#endif
#include "subsystems/datalink/downlink.h"
#include "generated/periodic_telemetry.h"

/* outer loop parameters */
float h_ctl_course_setpoint; /* rad, CW/north */
float h_ctl_course_pre_bank;
Expand Down Expand Up @@ -118,9 +112,13 @@ float h_ctl_roll_rate_gain;
static float nav_ratio;
#endif

#if DOWNLINK
#include "subsystems/datalink/telemetry.h"

static void send_calibration(void) {
DOWNLINK_SEND_CALIBRATION(DefaultChannel, DefaultDevice, &v_ctl_auto_throttle_sum_err, &v_ctl_auto_throttle_submode);
}
#endif

void h_ctl_init( void ) {
h_ctl_course_setpoint = 0.;
Expand Down Expand Up @@ -178,7 +176,9 @@ void h_ctl_init( void ) {
nav_ratio=0;
#endif

#if DOWNLINK
register_periodic_telemetry(DefaultPeriodic, "CALIBRATION", send_calibration);
#endif
}

/**
Expand Down
2 changes: 1 addition & 1 deletion sw/airborne/firmwares/rotorcraft/autopilot.c
Expand Up @@ -35,10 +35,10 @@
#include "subsystems/actuators.h"
#include "subsystems/electrical.h"
#include "subsystems/settings.h"
#include "subsystems/datalink/telemetry.h"
#include "firmwares/rotorcraft/navigation.h"
#include "firmwares/rotorcraft/guidance.h"
#include "firmwares/rotorcraft/stabilization.h"
#include "firmwares/rotorcraft/telemetry.h"
#include "led.h"

uint8_t autopilot_mode;
Expand Down
10 changes: 6 additions & 4 deletions sw/airborne/firmwares/rotorcraft/guidance/guidance_h.c
Expand Up @@ -34,10 +34,6 @@

#include "generated/airframe.h"

#include "mcu_periph/uart.h"
#include "subsystems/datalink/downlink.h"
#include "generated/periodic_telemetry.h"

/* error if some gains are negative */
#if (GUIDANCE_H_PGAIN < 0) || \
(GUIDANCE_H_DGAIN < 0) || \
Expand Down Expand Up @@ -93,6 +89,9 @@ static void guidance_h_hover_enter(void);
static void guidance_h_nav_enter(void);
static inline void transition_run(void);

#if DOWNLINK
#include "subsystems/datalink/telemetry.h"

static void send_gh(void) {
struct NedCoor_i* pos = stateGetPositionNed_i();
DOWNLINK_SEND_GUIDANCE_H_INT(DefaultChannel, DefaultDevice,
Expand Down Expand Up @@ -127,6 +126,7 @@ static void send_href(void) {
&guidance_h_pos_sp.y, &guidance_h_pos_ref.y,
&guidance_h_speed_ref.y, &guidance_h_accel_ref.y);
}
#endif

void guidance_h_init(void) {

Expand All @@ -144,9 +144,11 @@ void guidance_h_init(void) {
transition_percentage = 0;
transition_theta_offset = 0;

#if DOWNLINK
register_periodic_telemetry(DefaultPeriodic, "GUIDANCE_H_INT", send_gh);
register_periodic_telemetry(DefaultPeriodic, "HOVER_LOOP", send_hover_loop);
register_periodic_telemetry(DefaultPeriodic, "GUIDANCE_H_REF", send_href);
#endif
}


Expand Down
9 changes: 6 additions & 3 deletions sw/airborne/firmwares/rotorcraft/guidance/guidance_v.c
Expand Up @@ -39,9 +39,6 @@

#include "generated/airframe.h"

#include "subsystems/datalink/downlink.h"
#include "generated/periodic_telemetry.h"


/* warn if some gains are still negative */
#if (GUIDANCE_V_HOVER_KP < 0) || \
Expand Down Expand Up @@ -96,6 +93,9 @@ int32_t guidance_v_z_sum_err;

__attribute__ ((always_inline)) static inline void run_hover_loop(bool_t in_flight);

#if DOWNLINK
#include "subsystems/datalink/telemetry.h"

static void send_vert_loop(void) {
DOWNLINK_SEND_VERT_LOOP(DefaultChannel, DefaultDevice,
&guidance_v_z_sp, &guidance_v_zd_sp,
Expand All @@ -112,6 +112,7 @@ static void send_vert_loop(void) {
&guidance_v_fb_cmd,
&guidance_v_delta_t);
}
#endif

void guidance_v_init(void) {

Expand All @@ -129,7 +130,9 @@ void guidance_v_init(void) {

gv_adapt_init();

#if DOWNLINK
register_periodic_telemetry(DefaultPeriodic, "VERT_LOOP", send_vert_loop);
#endif
}


Expand Down
3 changes: 1 addition & 2 deletions sw/airborne/firmwares/rotorcraft/main.c
Expand Up @@ -33,8 +33,7 @@
#include "mcu_periph/sys_time.h"
#include "led.h"

#include "subsystems/datalink/downlink.h"
#include "firmwares/rotorcraft/telemetry.h"
#include "subsystems/datalink/telemetry.h"
#include "subsystems/datalink/datalink.h"
#include "subsystems/settings.h"
#include "subsystems/datalink/xbee.h"
Expand Down
9 changes: 6 additions & 3 deletions sw/airborne/firmwares/rotorcraft/navigation.c
Expand Up @@ -44,9 +44,6 @@

#include "math/pprz_algebra_int.h"

#include "subsystems/datalink/downlink.h"
#include "generated/periodic_telemetry.h"

const uint8_t nb_waypoint = NB_WAYPOINT;
struct EnuCoor_i waypoints[NB_WAYPOINT];

Expand Down Expand Up @@ -86,6 +83,9 @@ static inline void nav_set_altitude( void );
#define ARRIVED_AT_WAYPOINT (3 << 8)
#define CARROT_DIST (12 << 8)

#if DOWNLINK
#include "subsystems/datalink/telemetry.h"

static void send_nav_status(void) {
DOWNLINK_SEND_ROTORCRAFT_NAV_STATUS(DefaultChannel, DefaultDevice,
&block_time, &stage_time,
Expand Down Expand Up @@ -115,6 +115,7 @@ static void send_wp_moved(void) {
&(waypoints[i].y),
&(waypoints[i].z));
}
#endif

void nav_init(void) {
// convert to
Expand Down Expand Up @@ -148,8 +149,10 @@ void nav_init(void) {
nav_leg_progress = 0;
nav_leg_length = 1;

#if DOWNLINK
register_periodic_telemetry(DefaultPeriodic, "ROTORCRAFT_NAV_STATUS", send_nav_status);
register_periodic_telemetry(DefaultPeriodic, "WP_MOVED", send_wp_moved);
#endif
}

static inline void nav_advance_carrot(void) {
Expand Down
Expand Up @@ -35,6 +35,9 @@ struct FloatEulers stabilization_att_sum_err;
float stabilization_att_fb_cmd[COMMANDS_NB];
float stabilization_att_ff_cmd[COMMANDS_NB];

#if DOWNLINK
#include "subsystems/datalink/telemetry.h"

static void send_att(void) {
struct FloatRates* body_rate = stateGetBodyRates_i();
struct FloatEulers* att = stateGetNedToBodyEulers_i();
Expand Down Expand Up @@ -75,7 +78,7 @@ static void send_att_ref(void) {
&stab_att_ref_accel.q,
&stab_att_ref_accel.r);
}

#endif

void stabilization_attitude_init(void) {

Expand Down Expand Up @@ -103,8 +106,10 @@ void stabilization_attitude_init(void) {

FLOAT_EULERS_ZERO( stabilization_att_sum_err );

#if DOWNLINK
register_periodic_telemetry(DefaultPeriodic, "STAB_ATTITUDE", send_att);
register_periodic_telemetry(DefaultPeriodic, "STAB_ATTITUDE_REF", send_att_ref);
#endif
}


Expand Down
Expand Up @@ -27,9 +27,6 @@

#include "generated/airframe.h"

#include "subsystems/datalink/downlink.h"
#include "generated/periodic_telemetry.h"

struct Int32AttitudeGains stabilization_gains;

/* warn if some gains are still negative */
Expand Down Expand Up @@ -57,6 +54,9 @@ static inline void reset_psi_ref_from_body(void) {
stab_att_ref_accel.r = 0;
}

#if DOWNLINK
#include "subsystems/datalink/telemetry.h"

static void send_att(void) {
struct Int32Rates* body_rate = stateGetBodyRates_i();
struct Int32Eulers* att = stateGetNedToBodyEulers_i();
Expand Down Expand Up @@ -95,6 +95,7 @@ static void send_att_ref(void) {
&stab_att_ref_accel.q,
&stab_att_ref_accel.r);
}
#endif

void stabilization_attitude_init(void) {

Expand Down Expand Up @@ -124,8 +125,10 @@ void stabilization_attitude_init(void) {

INT_EULERS_ZERO( stabilization_att_sum_err );

#if DOWNLINK
register_periodic_telemetry(DefaultPeriodic, "STAB_ATTITUDE", send_att);
register_periodic_telemetry(DefaultPeriodic, "STAB_ATTITUDE_REF", send_att_ref);
#endif
}


Expand Down

0 comments on commit 116faae

Please sign in to comment.