-
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 #1392 from bitcraze/rik/ootcontrollerfix
Fix out of tree controllers
- Loading branch information
Showing
8 changed files
with
114 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
bin/* | ||
cf2.* |
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 @@ | ||
obj-y += src/ |
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,23 @@ | ||
# The firmware uses the Kbuild build system. There are 'Kbuild' files in this | ||
# example that outlays what needs to be built. (check src/Kbuild). | ||
# | ||
# The firmware is configured using options in Kconfig files, the | ||
# values of these end up in the .config file in the firmware directory. | ||
# | ||
# By setting the OOT_CONFIG (it is '$(PWD)/oot-config' by default) environment | ||
# variable you can provide a custom configuration. It is important that you | ||
# enable the app-layer. See app-config in this directory for example. | ||
|
||
# | ||
# We want to execute the main Makefile for the firmware project, | ||
# it will handle the build for us. | ||
# | ||
CRAZYFLIE_BASE := ../.. | ||
|
||
# | ||
# We override the default OOT_CONFIG here, we could also name our config | ||
# to oot-config and that would be the default. | ||
# | ||
OOT_CONFIG := $(PWD)/app-config | ||
|
||
include $(CRAZYFLIE_BASE)/tools/make/oot.mk |
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,5 @@ | ||
# Out of tree controller app for Crazyflie 2.X | ||
|
||
This folder contains an out of tree controller implementation for the Crazyflie. Instead of using a custom controller, this example uses the built-in PID controller. | ||
|
||
Check out [the OOT build documentation](https://www.bitcraze.io/documentation/repository/crazyflie-firmware/master/development/oot/) and [this blog post](https://www.bitcraze.io/2023/02/adding-an-estimator-or-controller/) for more information. |
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,4 @@ | ||
CONFIG_APP_ENABLE=y | ||
CONFIG_APP_PRIORITY=1 | ||
CONFIG_APP_STACKSIZE=350 | ||
CONFIG_CONTROLLER_OOT=y |
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 @@ | ||
obj-y += out_of_tree_controller.o |
76 changes: 76 additions & 0 deletions
76
examples/app_out_of_tree_controller/src/out_of_tree_controller.c
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,76 @@ | ||
/** | ||
* ,---------, ____ _ __ | ||
* | ,-^-, | / __ )(_) /_______________ _____ ___ | ||
* | ( O ) | / __ / / __/ ___/ ___/ __ `/_ / / _ \ | ||
* | / ,--´ | / /_/ / / /_/ /__/ / / /_/ / / /_/ __/ | ||
* +------` /_____/_/\__/\___/_/ \__,_/ /___/\___/ | ||
* | ||
* Crazyflie control firmware | ||
* | ||
* Copyright (C) 2024 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/>. | ||
* | ||
* | ||
* out_of_tree_controller.c - App layer application of an out of tree controller. | ||
*/ | ||
|
||
#include <string.h> | ||
#include <stdint.h> | ||
#include <stdbool.h> | ||
|
||
#include "app.h" | ||
|
||
#include "FreeRTOS.h" | ||
#include "task.h" | ||
|
||
// Edit the debug name to get nice debug prints | ||
#define DEBUG_MODULE "MYCONTROLLER" | ||
#include "debug.h" | ||
|
||
|
||
// We still need an appMain() function, but we will not really use it. Just let it quietly sleep. | ||
void appMain() { | ||
DEBUG_PRINT("Waiting for activation ...\n"); | ||
|
||
while(1) { | ||
vTaskDelay(M2T(2000)); | ||
} | ||
} | ||
|
||
// The new controller goes here -------------------------------------------- | ||
// Move the includes to the the top of the file if you want to | ||
#include "controller.h" | ||
|
||
// Call the PID controller in this example to make it possible to fly. When you implement you own controller, there is | ||
// no need to include the pid controller. | ||
#include "controller_pid.h" | ||
|
||
void controllerOutOfTreeInit() { | ||
// Initialize your controller data here... | ||
|
||
// Call the PID controller instead in this example to make it possible to fly | ||
controllerPidInit(); | ||
} | ||
|
||
bool controllerOutOfTreeTest() { | ||
// Always return true | ||
return true; | ||
} | ||
|
||
void controllerOutOfTree(control_t *control, const setpoint_t *setpoint, const sensorData_t *sensors, const state_t *state, const uint32_t tick) { | ||
// Implement your controller here... | ||
|
||
// Call the PID controller instead in this example to make it possible to fly | ||
controllerPid(control, setpoint, sensors, state, tick); | ||
} |
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