-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #147 from stephanbro/master.crtp_position_update
Master.crtp position update
- Loading branch information
Showing
9 changed files
with
157 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ bin/* | |
tools/make/config.mk | ||
cflie.* | ||
version.c | ||
tags | ||
|
||
/cf2.* | ||
/cf1.* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/** | ||
* || ____ _ __ ______ | ||
* +------+ / __ )(_) /_/ ____/_________ _____ ___ | ||
* | 0xBC | / __ / / __/ / / ___/ __ `/_ / / _ \ | ||
* +------+ / /_/ / / /_/ /___ / / / /_/ / / /_/ __/ | ||
* || || /_____/_/\__/\____//_/ \__,_/ /___/\___/ | ||
* | ||
* Crazyflie control firmware | ||
* | ||
* Copyright (C) 2011-2012 Bitcraze AB | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, in version 3. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
*/ | ||
|
||
#ifndef _EXT_POSITION_H_ | ||
#define _EXT_POSITION_H_ | ||
|
||
#include "stabilizer_types.h" | ||
|
||
/** | ||
* CRTP external position data struct | ||
*/ | ||
struct CrtpExtPosition | ||
{ | ||
float x; // in m | ||
float y; // in m | ||
float z; // in m | ||
} __attribute__((packed)); | ||
|
||
// Set up the callback for the CRTP_PORT_POSITION | ||
void extPositionInit(void); | ||
|
||
// Get the current position from the cache | ||
bool getExtPosition(state_t *state); | ||
|
||
#endif /* _EXT_POSITION_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
/** | ||
* || ____ _ __ | ||
* +------+ / __ )(_) /_______________ _____ ___ | ||
* | 0xBC | / __ / / __/ ___/ ___/ __ `/_ / / _ \ | ||
* +------+ / /_/ / / /_/ /__/ / / /_/ / / /_/ __/ | ||
* || || /_____/_/\__/\___/_/ \__,_/ /___/\___/ | ||
* | ||
* Crazyflie Firmware | ||
* | ||
* Copyright (C) 2011-2012 Bitcraze AB | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, in version 3. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
* | ||
*/ | ||
|
||
#include "FreeRTOS.h" | ||
#include "task.h" | ||
|
||
#include "ext_position.h" | ||
#include "crtp.h" | ||
#include "log.h" | ||
|
||
#ifdef ESTIMATOR_TYPE_kalman | ||
#include "estimator_kalman.h" | ||
#endif | ||
|
||
/** | ||
* Position data cache | ||
*/ | ||
typedef struct | ||
{ | ||
struct CrtpExtPosition targetVal[2]; | ||
bool activeSide; | ||
uint32_t timestamp; // FreeRTOS ticks | ||
} ExtPositionCache; | ||
|
||
// Struct for logging position information | ||
static positionMeasurement_t ext_pos; | ||
static ExtPositionCache crtpExtPosCache; | ||
static void extPositionCrtpCB(CRTPPacket* pk); | ||
|
||
static bool isInit = false; | ||
|
||
void extPositionInit() | ||
{ | ||
if (isInit) { | ||
return; | ||
} | ||
|
||
crtpRegisterPortCB(CRTP_PORT_POSITION, extPositionCrtpCB); | ||
isInit = true; | ||
} | ||
|
||
static void extPositionCrtpCB(CRTPPacket* pk) | ||
{ | ||
crtpExtPosCache.targetVal[!crtpExtPosCache.activeSide] = *((struct CrtpExtPosition*)pk->data); | ||
crtpExtPosCache.activeSide = !crtpExtPosCache.activeSide; | ||
crtpExtPosCache.timestamp = xTaskGetTickCount(); | ||
} | ||
|
||
|
||
bool getExtPosition(state_t *state) | ||
{ | ||
// Only use position information if it's valid and recent | ||
if ((xTaskGetTickCount() - crtpExtPosCache.timestamp) < M2T(5)) { | ||
// Get the updated position from the mocap | ||
ext_pos.x = crtpExtPosCache.targetVal[crtpExtPosCache.activeSide].x; | ||
ext_pos.y = crtpExtPosCache.targetVal[crtpExtPosCache.activeSide].y; | ||
ext_pos.z = crtpExtPosCache.targetVal[crtpExtPosCache.activeSide].z; | ||
ext_pos.stdDev = 0.01; | ||
#ifdef ESTIMATOR_TYPE_kalman | ||
stateEstimatorEnqueuePosition(&ext_pos); | ||
#endif | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
LOG_GROUP_START(ext_pos) | ||
LOG_ADD(LOG_FLOAT, X, &ext_pos.x) | ||
LOG_ADD(LOG_FLOAT, Y, &ext_pos.y) | ||
LOG_ADD(LOG_FLOAT, Z, &ext_pos.z) | ||
LOG_GROUP_STOP(ext_pos) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule libdw1000
updated
3 files
+2 −0 | inc/libdw1000.h | |
+1 −0 | inc/libdw1000Types.h | |
+21 −3 | src/libdw1000.c |