Skip to content

Commit

Permalink
#652 Moved and update API app
Browse files Browse the repository at this point in the history
  • Loading branch information
krichardsson committed Nov 19, 2020
1 parent f4e7b3e commit e6db718
Show file tree
Hide file tree
Showing 18 changed files with 150 additions and 639 deletions.
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,11 @@ script:
- docker run --rm -v ${PWD}:/module bitcraze/builder ./tools/build/make clean
- docker run --rm -v ${PWD}:/module bitcraze/builder ./tools/build/build PLATFORM=cf2 "EXTRA_CFLAGS=-DDISABLE_LIGHTHOUSE_DRIVER=0" UNIT_TEST_STYLE=min

# Build app API
- docker run --rm -v ${PWD}:/module bitcraze/builder bash -c "cd app_api; make"

# Build examples
- docker run --rm -v ${PWD}:/module bitcraze/builder bash -c "cd examples/app_hello_world; make"
- docker run --rm -v ${PWD}:/module bitcraze/builder bash -c "cd examples/app_api; make"
- docker run --rm -v ${PWD}:/module bitcraze/builder bash -c "cd examples/app_peer_to_peer; make"
- docker run --rm -v ${PWD}:/module bitcraze/builder bash -c "cd examples/demos/app_push_demo; make"
- docker run --rm -v ${PWD}:/module bitcraze/builder bash -c "cd examples/demos/swarm_demo; make"
File renamed without changes.
10 changes: 10 additions & 0 deletions app_api/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

# enable app support
APP=1
APP_STACKSIZE=300

VPATH += src/
PROJ_OBJ += app_main.o

CRAZYFLIE_BASE=..
include $(CRAZYFLIE_BASE)/Makefile
22 changes: 22 additions & 0 deletions app_api/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# API App for Crazyflie 2.X

This folder contains an app layer application for the Crazyflie that is intended to document which functions that are part of the
app API. This is not an example app with useful code, see the example directroy for examples of how to use functions.

The app is built by CI servers to make sure we do not modify functions that is part of the official app API by misstake.
Please add any new functions that should be part of the API to it.

See App layer API guide [here](https://www.bitcraze.io/documentation/repository/crazyflie-firmware/master/userguides/app_layer/)

## How to use the app

Do NOT flash and use it! It does not do anything useful and may have unpredictable behaviour, it is only intended to be compiled but not to run.

## Build

Make sure that you are in the app_api folder (not the main folder of the crazyflie firmware). Then type the following to build and flash it while the crazyflie is put into bootloader mode:

```
make clean
make
```
115 changes: 115 additions & 0 deletions app_api/src/app_main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
/**
* ,---------, ____ _ __
* | ,-^-, | / __ )(_) /_______________ _____ ___
* | ( O ) | / __ / / __/ ___/ ___/ __ `/_ / / _ \
* | / ,--´ | / /_/ / / /_/ /__/ / / /_/ / / /_/ __/
* +------` /_____/_/\__/\___/_/ \__,_/ /___/\___/
*
* Crazyflie control firmware
*
* Copyright (C) 2020 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/>.
*
*
* api_app.c - App layer application that calls app API functions to make
* sure they are compiled in CI.
*/


#include <string.h>
#include <stdint.h>
#include <stdbool.h>

#include "app.h"

#include "FreeRTOS.h"
#include "task.h"

#include "debug.h"

#include "ledseq.h"
#include "crtp_commander_high_level.h"
#include "locodeck.h"
#include "mem.h"
#include "log.h"
#include "param.h"


#define DEBUG_MODULE "APPAPI"

void appMain() {
// Do not run this app
ASSERT_FAILED();

// LED sequencer
{
ledseqContext_t ledSeqContext;
ledseqRegisterSequence(&ledSeqContext);
ledseqRun(&ledSeqContext);
ledseqRunBlocking(&ledSeqContext);
ledseqStop(&ledSeqContext);
ledseqStopBlocking(&ledSeqContext);
}

// High level commander
{
uint8_t dummyTrajectory[10];
crtpCommanderHighLevelTakeoff(1.0f, 1.0f);
crtpCommanderHighLevelTakeoffYaw(1.0f, 1.0f, 1.0f);
crtpCommanderHighLevelLand(0.0f, 1.0f);
crtpCommanderHighLevelLandYaw(0.0f, 1.0f, 1.0f);
crtpCommanderHighLevelStop();
crtpCommanderHighLevelGoTo(1.0f, 0.0f, 0.0f, 0.0f, 1.0f, false);
crtpCommanderHighLevelStartTrajectory(3, 1.0f, true, false);
crtpCommanderHighLevelDefineTrajectory(3, CRTP_CHL_TRAJECTORY_TYPE_POLY4D_COMPRESSED, 0, 17);
crtpCommanderHighLevelTrajectoryMemSize();
crtpCommanderHighLevelWriteTrajectory(20, 10, dummyTrajectory);
crtpCommanderHighLevelReadTrajectory(20, 10, dummyTrajectory);
crtpCommanderHighLevelIsTrajectoryFinished();
}

// LPS
{
point_t position;
uint8_t unorderedAnchorList[5];

locoDeckGetAnchorPosition(0, &position);
locoDeckGetAnchorIdList(unorderedAnchorList, 5);
locoDeckGetActiveAnchorIdList(unorderedAnchorList, 5);
}

// Memory sub system
{
static const MemoryHandlerDef_t memDef = {.type = MEM_TYPE_APP,};
memoryRegisterHandler(&memDef);
}

// Log
{
logVarId_t id = logGetVarId("some", "log");
logGetFloat(id);
logGetInt(id);
logGetUint(id);
}

// Param
{
paramVarId_t id = paramGetVarId("some", "param");
paramGetFloat(id);
paramGetInt(id);
paramGetUint(id);
paramSetInt(id, 0);
paramSetFloat(id, 0.0f);
}
}
10 changes: 0 additions & 10 deletions examples/app_api/Makefile

This file was deleted.

18 changes: 0 additions & 18 deletions examples/app_api/README.md

This file was deleted.

Loading

0 comments on commit e6db718

Please sign in to comment.