Skip to content

Commit

Permalink
[rotorcraft] RC commands set when not in nav
Browse files Browse the repository at this point in the history
Rotorcraft commands are set with a specific macro
  • Loading branch information
gautierhattenberger committed Jan 7, 2013
1 parent 4ed232b commit 1cfdb7a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
7 changes: 3 additions & 4 deletions sw/airborne/firmwares/rotorcraft/autopilot.c
Expand Up @@ -114,9 +114,8 @@ void autopilot_periodic(void) {
else {
guidance_v_run( autopilot_in_flight );
guidance_h_run( autopilot_in_flight );
SetCommands(stabilization_cmd);
SetRotorcraftCommands(stabilization_cmd, autopilot_in_flight, autopilot_motors_on);
}
RotorcraftCommandsTest(commands, autopilot_in_flight, autopilot_motors_on);

This comment has been minimized.

Copy link
@flixr

flixr Jan 9, 2013

Member

Now it won't turn of the motors anymore if FAILSAFE_GROUND_DETECT is used and throttle is killed (e.g. via GCS).
Maybe better to just also apply the rc commands to stabilization_cmd instead of to commands directly?


}

Expand Down Expand Up @@ -268,9 +267,9 @@ void autopilot_on_rc_frame(void) {
SetAutoCommandsFromRC(commands, radio_control.values);
#endif

/* if in "MANUAL" set commands from the rc */
/* if not in NAV_MODE set commands from the rc */
#ifdef SetCommandsFromRC
if (autopilot_mode == MODE_MANUAL) {
if (autopilot_mode != AP_MODE_NAV) {
SetCommandsFromRC(commands, radio_control.values);

This comment has been minimized.

Copy link
@flixr

flixr Jan 7, 2013

Member

I guess it would make more sense to also set stabilization_cmd here (maybe rename it then?) instead of setting commands directly...?

}
#endif
Expand Down
20 changes: 14 additions & 6 deletions sw/airborne/firmwares/rotorcraft/autopilot.h
Expand Up @@ -116,18 +116,26 @@ extern uint16_t autopilot_flight_time;
}
#endif

/** Thrust and Yaw commands limitation.
/** Set Rotorcraft commands.
* Limit thrust and/or yaw depending of the in_flight
* and motors_on flag status
*/
#ifndef ROTORCRAFT_COMMANDS_YAW_ALWAYS_ENABLED
#define RotorcraftCommandsTest(_cmd, _in_flight, _motor_on) { \
if (!(_in_flight)) { _cmd[COMMAND_YAW] = 0; } \
if (!(_motor_on)) { _cmd[COMMAND_THRUST] = 0; } \
#define SetRotorcraftCommands(_cmd, _in_flight, _motor_on) { \
if (!(_in_flight)) { _cmd[COMMAND_YAW] = 0; } \
if (!(_motor_on)) { _cmd[COMMAND_THRUST] = 0; } \
commands[COMMAND_ROLL] = _cmd[COMMAND_ROLL]; \
commands[COMMAND_PITCH] = _cmd[COMMAND_PITCH]; \
commands[COMMAND_YAW] = _cmd[COMMAND_YAW]; \
commands[COMMAND_THRUST] = _cmd[COMMAND_THRUST]; \
}
#else
#define RotorcraftCommandsTest(_cmd, _in_flight, _motor_on) { \
if (!(_motor_on)) { _cmd[COMMAND_THRUST] = 0; } \
#define SetRotorcraftCommands(_cmd, _in_flight, _motor_on) { \
if (!(_motor_on)) { _cmd[COMMAND_THRUST] = 0; } \
commands[COMMAND_ROLL] = _cmd[COMMAND_ROLL]; \
commands[COMMAND_PITCH] = _cmd[COMMAND_PITCH]; \
commands[COMMAND_YAW] = _cmd[COMMAND_YAW]; \
commands[COMMAND_THRUST] = _cmd[COMMAND_THRUST]; \
}
#endif

Expand Down

0 comments on commit 1cfdb7a

Please sign in to comment.