Skip to content

Commit

Permalink
#110 Added params to externally set the Crazyflie position
Browse files Browse the repository at this point in the history
This is experimental and intended to test integrated controller
  • Loading branch information
ataffanel committed May 2, 2016
1 parent e076413 commit db55d3b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
8 changes: 7 additions & 1 deletion src/modules/src/estimator_complementary.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ void stateEstimator(state_t *state, const sensorData_t *sensorData, const uint32
}

if (!RATE_SKIP_100HZ(tick)) {
positionEstimate(state, sensorData->baro.asl, POS_UPDATE_DT);
// If position sensor data is preset, pass it throught
// FIXME: The position sensor shall be used as an input of the estimator
if (sensorData->position.timestamp) {
state->position = sensorData->position;
} else {
positionEstimate(state, sensorData->baro.asl, POS_UPDATE_DT);
}
}
}
24 changes: 19 additions & 5 deletions src/modules/src/sensors_stock.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@
#include "lps25h.h"
#endif

#include "param.h"

static point_t position;

void sensorsInit(void)
{
imu6Init();
Expand All @@ -52,18 +56,28 @@ bool sensorsAcquire(sensorData_t *sensors, const uint32_t tick)
imu9Read(&sensors->gyro, &sensors->acc, &sensors->mag);
}

if (!RATE_SKIP_100HZ(tick) && imuHasBarometer()) {
if (!RATE_SKIP_100HZ(tick) && imuHasBarometer()) {
#ifdef PLATFORM_CF1
ms5611GetData(&sensors->baro.pressure,
ms5611GetData(&sensors->baro.pressure,
&sensors->baro.temperature,
&sensors->baro.asl);
#else
lps25hGetData(&sensors->baro.pressure,
lps25hGetData(&sensors->baro.pressure,
&sensors->baro.temperature,
&sensors->baro.asl);
#endif
}
// Get the position
// Experimental: receive the position from parameters
if (position.timestamp) {
sensors->position = position;
}
}

return imu6IsCalibrated();
}

PARAM_GROUP_START(lps)
PARAM_ADD(PARAM_UINT32, t, &position.timestamp)
PARAM_ADD(PARAM_FLOAT, x, &position.x)
PARAM_ADD(PARAM_FLOAT, y, &position.y)
PARAM_ADD(PARAM_FLOAT, z, &position.z)
PARAM_GROUP_STOP(sensorfusion6)

0 comments on commit db55d3b

Please sign in to comment.