Commit a9884684 authored by Ian McInerney's avatar Ian McInerney

Made some structures into types

parent 1105db44
......@@ -45,18 +45,13 @@
// Private
#include "CCrazyRadio.h"
#include "CTOC.h"
#include "structures.h"
#include "vrpn_Connection.h"
#include "vrpn_Tracker.h"
#define PID_BUFFER_SIZE 12
enum takeoffStepType {
step_final = 0,
step_time,
step_height
};
// Numbers specified here must match the quadcopter ID numbers
enum PID_Controller_IDs {
PID_X = 0,
......@@ -94,39 +89,6 @@ enum FlightMode{
IDLE_MODE
};
struct PID_ControllerParams {
float Kp;
float Ki;
float Kd;
float iLimit;
uint8_t controllerID;
};
struct angularPosition {
float roll;
float pitch;
float yaw;
};
struct lateralPosition {
float x;
float y;
float z;
};
struct quaternionPosition {
float q0;
float q1;
float q2;
float q3;
};
typedef struct takeoffProfileStep {
uint16_t thrust;
enum takeoffStepType type;
double condition;
} takeoffProfileStep;
// Backward declaration of the CCrazyflie class to make the compiler happy
class CCrazyRadio;
class CTOC;
......@@ -162,12 +124,12 @@ class CCrazyflie {
reach) */
// Structures to hold the current position and orientation of the quad
struct lateralPosition m_currentCameraPosition;
struct angularPosition m_currentCameraAngle;
struct quaternionPosition m_currentCameraQuat;
lateralPosition m_currentCameraPosition;
angularPosition m_currentCameraAngle;
quaternionPosition m_currentCameraQuat;
// Structures to hold the desired setpoints
struct lateralPosition m_desiredPosition;
lateralPosition m_desiredPosition;
float m_desiredYaw;
uint16_t m_baseThrust;
......@@ -200,7 +162,7 @@ class CCrazyflie {
// Various things for setting the PID parameters of the quadcopter
uint8_t m_bufferEnd;
struct PID_ControllerParams bufferedParams[PID_BUFFER_SIZE];
PID_ControllerParams bufferedParams[PID_BUFFER_SIZE];
// Control related parameters
/*! \brief Maximum absolute value for the roll that will be sent to
......@@ -286,9 +248,9 @@ class CCrazyflie {
int queryControllerType();
int getControllerType();
void setCameraPosition(struct lateralPosition cameraPosition);
void setCameraAngle(struct angularPosition cameraAngle);
void setCameraQuat(struct quaternionPosition cameraQuat);
void setCameraPosition(lateralPosition cameraPosition);
void setCameraAngle(angularPosition cameraAngle);
void setCameraQuat(quaternionPosition cameraQuat);
/*
* These functions will return the current quadcopter
......@@ -416,9 +378,9 @@ class CCrazyflie {
is sent to the copter while performing cycle(). */
bool sendsSetpoints();
uint8_t setPID_Constants( struct PID_ControllerParams params );
uint8_t setPID_Constants( PID_ControllerParams params );
bool sendPID_Constants( struct PID_ControllerParams params );
bool sendPID_Constants( PID_ControllerParams params );
void setXYZYawPosition(float xPosition, float yPosition, float zPosition,
float yawPosition);
......
......@@ -17,9 +17,9 @@ void VRPN_CALLBACK CCrazyflie::vrpnTrackerCallback(void *crazyflie, const vrpn_T
CCrazyflie *crazy = (CCrazyflie *) crazyflie;
// Temp structs to pass inside the function
struct angularPosition angles;
struct lateralPosition lat;
struct quaternionPosition quat;
angularPosition angles;
lateralPosition lat;
quaternionPosition quat;
// Pull out the lateral position into the struct
lat.x = t.pos[0];
......
......@@ -41,7 +41,7 @@ int CCrazyflie::queryControllerType() {
return( retVal );
}
bool CCrazyflie::sendPID_Constants( struct PID_ControllerParams params ) {
bool CCrazyflie::sendPID_Constants( PID_ControllerParams params ) {
if( ALL_THE_DEBUG ) printf( "Enter: %s\n", __FUNCTION__ );
int nSize = 4 * sizeof(float) + 1*sizeof(uint8_t);
......
......@@ -76,7 +76,7 @@ bool CCrazyflie::disableThrustController() {
}
uint8_t CCrazyflie::setPID_Constants( struct PID_ControllerParams params ) {
uint8_t CCrazyflie::setPID_Constants( PID_ControllerParams params ) {
if( ALL_THE_DEBUG ) printf( "Enter: %s\n", __FUNCTION__ );
// If there is space in the buffer, add the data to it
if (m_bufferEnd < PID_BUFFER_SIZE) {
......
......@@ -11,7 +11,7 @@ void CCrazyflie::setTakeoffProfile( takeoffProfileStep *profile, int numSteps )
size_t length = sizeof(takeoffProfileStep) * numSteps;
// Allocate the memory for the takeoff profile
this->takeoffProfile = (struct takeoffProfileStep*) realloc( this->takeoffProfile, length);
this->takeoffProfile = (takeoffProfileStep*) realloc( this->takeoffProfile, length);
if ( this->takeoffProfile == NULL ) {
// This is an error...
std::cout << "Memory allocation for takeoff routine failed" << std::endl;
......@@ -75,15 +75,15 @@ void CCrazyflie::setXYZYawPosition(float xPosition, float yPosition, float zPosi
if( ALL_THE_DEBUG ) printf( "Exit: %s\n", __FUNCTION__ );
}
void CCrazyflie::setCameraPosition(struct lateralPosition cameraPosition) {
void CCrazyflie::setCameraPosition(lateralPosition cameraPosition) {
this->m_currentCameraPosition = cameraPosition;
}
void CCrazyflie::setCameraAngle(struct angularPosition cameraAngle) {
void CCrazyflie::setCameraAngle(angularPosition cameraAngle) {
this->m_currentCameraAngle = cameraAngle;
}
void CCrazyflie::setCameraQuat( struct quaternionPosition cameraQuat) {
void CCrazyflie::setCameraQuat(quaternionPosition cameraQuat) {
this->m_currentCameraQuat = cameraQuat;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment