Skip to content

Commit

Permalink
[state interface] speed_norm_i is unsigned
Browse files Browse the repository at this point in the history
  • Loading branch information
flixr committed Nov 18, 2014
1 parent c03427b commit b0070b2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions sw/airborne/state.c
Expand Up @@ -762,8 +762,8 @@ void stateCalcHorizontalSpeedNorm_i(void) {
state.h_speed_norm_i = SPEED_BFP_OF_REAL(state.h_speed_norm_f);
}
else if (bit_is_set(state.speed_status, SPEED_NED_I)) {
int32_t n2 = (state.ned_speed_i.x*state.ned_speed_i.x +
state.ned_speed_i.y*state.ned_speed_i.y) >> INT32_SPEED_FRAC;
uint32_t n2 = (state.ned_speed_i.x*state.ned_speed_i.x +
state.ned_speed_i.y*state.ned_speed_i.y) >> INT32_SPEED_FRAC;
INT32_SQRT(state.h_speed_norm_i, n2);
}
else if (bit_is_set(state.speed_status, SPEED_NED_F)) {
Expand All @@ -772,8 +772,8 @@ void stateCalcHorizontalSpeedNorm_i(void) {
state.h_speed_norm_i = SPEED_BFP_OF_REAL(state.h_speed_norm_f);
}
else if (bit_is_set(state.speed_status, SPEED_ENU_I)) {
int32_t n2 = (state.enu_speed_i.x*state.enu_speed_i.x +
state.enu_speed_i.y*state.enu_speed_i.y) >> INT32_SPEED_FRAC;
uint32_t n2 = (state.enu_speed_i.x*state.enu_speed_i.x +
state.enu_speed_i.y*state.enu_speed_i.y) >> INT32_SPEED_FRAC;
INT32_SQRT(state.h_speed_norm_i, n2);
}
else if (bit_is_set(state.speed_status, SPEED_ENU_F)) {
Expand All @@ -785,8 +785,8 @@ void stateCalcHorizontalSpeedNorm_i(void) {
/* transform ecef speed to ned, set status bit, then compute norm */
ned_of_ecef_vect_i(&state.ned_speed_i, &state.ned_origin_i, &state.ecef_speed_i);
SetBit(state.speed_status, SPEED_NED_I);
int32_t n2 = (state.ned_speed_i.x*state.ned_speed_i.x +
state.ned_speed_i.y*state.ned_speed_i.y) >> INT32_SPEED_FRAC;
uint32_t n2 = (state.ned_speed_i.x*state.ned_speed_i.x +
state.ned_speed_i.y*state.ned_speed_i.y) >> INT32_SPEED_FRAC;
INT32_SQRT(state.h_speed_norm_i, n2);
}
else if (bit_is_set(state.speed_status, SPEED_ECEF_F)) {
Expand Down
4 changes: 2 additions & 2 deletions sw/airborne/state.h
Expand Up @@ -277,7 +277,7 @@ struct State {
* Norm of horizontal ground speed.
* Unit: m/s in BFP with #INT32_SPEED_FRAC
*/
int32_t h_speed_norm_i;
uint32_t h_speed_norm_i;

/**
* Direction of horizontal ground speed.
Expand Down Expand Up @@ -816,7 +816,7 @@ static inline struct EcefCoor_i* stateGetSpeedEcef_i(void) {
}

/// Get norm of horizontal ground speed (int).
static inline int32_t* stateGetHorizontalSpeedNorm_i(void) {
static inline uint32_t* stateGetHorizontalSpeedNorm_i(void) {
if (!bit_is_set(state.speed_status, SPEED_HNORM_I))
stateCalcHorizontalSpeedNorm_i();
return &state.h_speed_norm_i;
Expand Down

0 comments on commit b0070b2

Please sign in to comment.