Skip to content

Commit

Permalink
#113: Started reorganizing commander architecture
Browse files Browse the repository at this point in the history
The commander is now accepting setpoint structure with a priority
information: the function that pushes a setpoint with the highest
priority will set the actual setpoint.

Moved current Roll Pitch Yaw Thrust CRTP setpoint to its own file in
preparation for the new 'type' CRTP setpoint.
  • Loading branch information
ataffanel committed Jan 25, 2017
1 parent 183c1dd commit c03d543
Show file tree
Hide file tree
Showing 10 changed files with 416 additions and 350 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ PROJ_OBJ_CF1 += sound_cf1.o sensors_cf1.o
PROJ_OBJ_CF2 += platformservice.o sound_cf2.o extrx.o sysload.o

# Stabilizer modules
PROJ_OBJ += commander.o ext_position.o
PROJ_OBJ += commander.o ext_position.o crtp_commander.o crtp_commander_rpyt.o
PROJ_OBJ += attitude_pid_controller.o sensfusion6.o stabilizer.o
PROJ_OBJ += position_estimator_altitude.o position_controller_pid.o
PROJ_OBJ += estimator_$(ESTIMATOR).o controller_$(CONTROLLER).o
Expand Down
2 changes: 1 addition & 1 deletion src/config/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
#define MCU_ID_ADDRESS 0x1FFFF7E8
#define MCU_FLASH_SIZE_ADDRESS 0x1FFFF7E0
#define FREERTOS_HEAP_SIZE 14000
#define FREERTOS_MIN_STACK_SIZE 100
#define FREERTOS_MIN_STACK_SIZE 80
#define FREERTOS_MCU_CLOCK_HZ 72000000
#endif

Expand Down
17 changes: 6 additions & 11 deletions src/modules/interface/commander.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,16 @@
#define COMMANDER_WDT_TIMEOUT_STABILIZE M2T(500)
#define COMMANDER_WDT_TIMEOUT_SHUTDOWN M2T(2000)

/**
* CRTP commander data struct
*/
struct CommanderCrtpValues
{
float roll; // deg
float pitch; // deg
float yaw; // deg
uint16_t thrust;
} __attribute__((packed));
#define COMMANDER_PRIORITY_DISABLE 0
#define COMMANDER_PRIORITY_CRTP 1
#define COMMANDER_PRIORITY_EXTRX 2

void commanderInit(void);
bool commanderTest(void);
uint32_t commanderGetInactivityTime(void);
void commanderExtrxSet(const struct CommanderCrtpValues* val);

void commanderSetSetpoint(setpoint_t *setpoint, int priority);
int commanderGetActivePriority(void);

void commanderGetSetpoint(setpoint_t *setpoint, const state_t *state);

Expand Down
39 changes: 39 additions & 0 deletions src/modules/interface/crtp_commander.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/**
* || ____ _ __ ______
* +------+ / __ )(_) /_/ ____/_________ _____ ___
* | 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 CRTP_COMMANDER_H_
#define CRTP_COMMANDER_H_

#include <stdint.h>
#include "stabilizer_types.h"
#include "crtp.h"

#define CRTP_CONTROLLER_LEGACY_CH 0
#define CRTP_CONTROLLER_TYPE_CH 1

void crtpCommanderInit(void);
void crtpCommanderRpytDecodeSetpoint(setpoint_t *setpoint, CRTPPacket *pk);

#endif /* CRTP_COMMANDER_H_ */
2 changes: 2 additions & 0 deletions src/modules/interface/stabilizer_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ typedef enum mode_e {
} mode_t;

typedef struct setpoint_s {
uint32_t timestamp;

attitude_t attitude;
attitude_t attitudeRate;
float thrust;
Expand Down
Loading

0 comments on commit c03d543

Please sign in to comment.