Skip to content

Commit

Permalink
add some comments and fix callback
Browse files Browse the repository at this point in the history
  • Loading branch information
gautierhattenberger authored and fvantienen committed Feb 28, 2019
1 parent 905c980 commit 8e4029c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
12 changes: 8 additions & 4 deletions conf/abi.xml
Expand Up @@ -192,10 +192,14 @@
</message>

<message name="JOYSTICK" id="28">
<field name="roll" type="int16_t"/>
<field name="pitch" type="int16_t"/>
<field name="yaw" type="int16_t"/>
<field name="throttle" type="int16_t"/>
<!--
This message can be used to send command inputs from a joystick or equivalent
either for the control of the airframe or the control of the payload
-->
<field name="roll" type="int16_t">Roll input in pprz_t [-9600;9600]</field>
<field name="pitch" type="int16_t">Pitch input in pprz_t [-9600;9600]</field>
<field name="yaw" type="int16_t">Yaw input in pprz_t [-9600;9600]</field>
<field name="throttle" type="int16_t">Throttle input in pprz_t [0;9600] or [-9600;9600] (for vertical speed control for instance)</field>
</message>

</msg_class>
Expand Down
9 changes: 5 additions & 4 deletions conf/flight_plans/joystick.xml
Expand Up @@ -7,11 +7,11 @@
#ifdef NAV_C
#include "firmwares/fixedwing/stabilization/stabilization_attitude.h"
#include "autopilot.h"
void joystick_handler(void) {
static inline void joystick_handler(uint8_t sender_id __attribute__((unused)), int16_t roll, int16_t pitch, int16_t yaw __attribute__((unused)), int16_t throttle) {
if (And(autopilot_get_mode() == AP_MODE_AUTO2, nav_block == joystick_block)) {
h_ctl_roll_setpoint = AUTO1_MAX_ROLL * joystick.roll / MAX_PPRZ;
h_ctl_pitch_setpoint = AUTO1_MAX_PITCH * joystick.pitch / MAX_PPRZ;
v_ctl_throttle_setpoint = joystick.throttle;
h_ctl_roll_setpoint = AUTO1_MAX_ROLL * roll / MAX_PPRZ;
h_ctl_pitch_setpoint = AUTO1_MAX_PITCH * pitch / MAX_PPRZ;
v_ctl_throttle_setpoint = throttle;
}
}
#endif
Expand All @@ -31,6 +31,7 @@ void joystick_handler(void) {
</waypoints>
<variables>
<variable var="joystick_block" type="uint8_t" init="255"/>
<abi_binding name="JOYSTICK" handler="joystick_handler"/>
</variables>
<modules>
<module name="joystick"/>
Expand Down

0 comments on commit 8e4029c

Please sign in to comment.