Skip to content

Commit

Permalink
[rotorcraft] navigation: unsigned nav_leg_length
Browse files Browse the repository at this point in the history
  • Loading branch information
flixr committed Nov 18, 2014
1 parent b0070b2 commit dd0c6cc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions sw/airborne/firmwares/rotorcraft/navigation.c
Expand Up @@ -77,7 +77,7 @@ struct EnuCoor_i nav_circle_center;
int32_t nav_circle_radius, nav_circle_qdr, nav_circle_radians;

int32_t nav_leg_progress;
int32_t nav_leg_length;
uint32_t nav_leg_length;

int32_t nav_roll, nav_pitch;
int32_t nav_heading;
Expand Down Expand Up @@ -269,8 +269,8 @@ void nav_route(struct EnuCoor_i * wp_start, struct EnuCoor_i * wp_end) {
VECT2_COPY(wp_diff_prec, wp_diff);
INT32_VECT2_RSHIFT(wp_diff,wp_diff,INT32_POS_FRAC);
INT32_VECT2_RSHIFT(pos_diff,pos_diff,INT32_POS_FRAC);
int32_t leg_length2 = Max((wp_diff.x * wp_diff.x + wp_diff.y * wp_diff.y),1);
INT32_SQRT(nav_leg_length,leg_length2);
uint32_t leg_length2 = Max((wp_diff.x * wp_diff.x + wp_diff.y * wp_diff.y),1);
nav_leg_length = int32_sqrt(leg_length2);
nav_leg_progress = (pos_diff.x * wp_diff.x + pos_diff.y * wp_diff.y) / nav_leg_length;
int32_t progress = Max((CARROT_DIST >> INT32_POS_FRAC), 0);
nav_leg_progress += progress;
Expand Down
2 changes: 1 addition & 1 deletion sw/airborne/firmwares/rotorcraft/navigation.h
Expand Up @@ -60,7 +60,7 @@ extern int32_t nav_heading; ///< with #INT32_ANGLE_FRAC
extern float nav_radius;

extern int32_t nav_leg_progress;
extern int32_t nav_leg_length;
extern uint32_t nav_leg_length;

extern uint8_t vertical_mode;
extern uint32_t nav_throttle; ///< direct throttle from 0:MAX_PPRZ, used in VERTICAL_MODE_MANUAL
Expand Down

0 comments on commit dd0c6cc

Please sign in to comment.