Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add OSX compiler support #15

Merged
merged 5 commits into from
Feb 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
269 changes: 138 additions & 131 deletions AirLib/include/control/DroneControlCommon.hpp
Original file line number Diff line number Diff line change
@@ -1,131 +1,138 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

#ifndef msr_air_control_VehicleCommon_hpp
#define msr_air_control_VehicleCommon_hpp

#include "common/Common.hpp"
namespace msr {
namespace airlib {

enum class MoveCommandType {
Invalid = 0,

Arm,
Disarm,
RequestControl,
ReleaseControl,
TakeOff,
Land,
Hover,
GoHome,

MoveByAngle,
MoveByVelocity,
MoveByVelocityZ,
MoveToPosition,
MoveOnPath,
MoveToZ,
MoveByManual,

SetSafety,

RotateByYawRate,
RotateToYaw,
Sleep
};

const string kActionServerName = "drone_move";

enum class DrivetrainType {
MaxDegreeOfFreedome = 0,
ForwardOnly
};

//Yaw mode specifies if yaw should be set as angle or angular velocity around the center of drone
struct YawMode {
bool is_rate = true;
float yaw_or_rate = 0.0f;

YawMode()
{}

YawMode(bool is_rate_val, float yaw_or_rate_val) {
is_rate = is_rate_val;
yaw_or_rate = yaw_or_rate_val;
}

static YawMode Zero() {
return YawMode(true, 0);
}

void setZeroRate() {
is_rate = true;
yaw_or_rate = 0;
}
};

//properties of vehicle
struct VehicleParams {
//what is the breaking distance for given velocity?
//currently we support simple linear relationship
float vel_to_breaking_dist = 0.5f; //ideally this should be 2X for very high speed but for testing we are keeping it 0.5
float min_vel_to_breaking_dist = 1;
float breaking_vel = 0.25f;

//what is the differential positional accuracy of cur_loc?
//this is not same as GPS accuracy because translational errors
//usually cancel out. Typically this would be 0.2m or less
float distance_accuracy = 0.1f;

//what is the minimum clearance from obstacles?
float obs_clearance = 2;

//what is the +/-window we should check on obstacle map?
//for example 2 means check from ticks -2 to 2
int obs_window = 0;
};

struct RCData {
double timestamp;
float pitch = 0, roll = 0, throttle = 0, yaw = 0, switch1 = 0, switch2 = 0, switch3 = 0;

void add(const RCData& other) {
pitch += other.pitch;
roll += other.roll;
throttle += other.throttle;
yaw += other.yaw;
}
void subtract(const RCData& other) {
pitch -= other.pitch;
roll -= other.roll;
throttle -= other.throttle;
yaw -= other.yaw;
}
void divideBy(float k) {
pitch /= k;
roll /= k;
throttle /= k;
yaw /= k;
}
bool isAnyMoreThan(float k) {
using std::abs;
return abs(pitch) > k || abs(roll) > k || abs(throttle) > k || abs(yaw) > k;
}
string toString() {
return Utils::stringf("RCData[pitch=%f, roll=%f, throttle=%f, yaw=%f]", pitch, roll, throttle, yaw);
}
};

//General exception when move command has runtime errors
class MoveException : public std::runtime_error {
public:
MoveException(const std::string& message)
: runtime_error(message) {
}
};


}
} //namespace
#endif
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

#ifndef msr_air_control_VehicleCommon_hpp
#define msr_air_control_VehicleCommon_hpp

#include "common/Common.hpp"
namespace msr {
namespace airlib {

enum class MoveCommandType {
Invalid = 0,

Arm,
Disarm,
RequestControl,
ReleaseControl,
TakeOff,
Land,
Hover,
GoHome,

MoveByAngle,
MoveByVelocity,
MoveByVelocityZ,
MoveToPosition,
MoveOnPath,
MoveToZ,
MoveByManual,

SetSafety,

RotateByYawRate,
RotateToYaw,
Sleep
};

const string kActionServerName = "drone_move";

enum class DrivetrainType {
MaxDegreeOfFreedome = 0,
ForwardOnly
};

//Yaw mode specifies if yaw should be set as angle or angular velocity around the center of drone
struct YawMode {
bool is_rate = true;
float yaw_or_rate = 0.0f;

YawMode()
{}

YawMode(bool is_rate_val, float yaw_or_rate_val) {
is_rate = is_rate_val;
yaw_or_rate = yaw_or_rate_val;
}

static YawMode Zero() {
return YawMode(true, 0);
}

void setZeroRate() {
is_rate = true;
yaw_or_rate = 0;
}
};

//properties of vehicle
struct VehicleParams {
//what is the breaking distance for given velocity?
//currently we support simple linear relationship
float vel_to_breaking_dist = 0.5f; //ideally this should be 2X for very high speed but for testing we are keeping it 0.5
float min_vel_to_breaking_dist = 1;
float breaking_vel = 0.25f;

//what is the differential positional accuracy of cur_loc?
//this is not same as GPS accuracy because translational errors
//usually cancel out. Typically this would be 0.2m or less
float distance_accuracy = 0.1f;

//what is the minimum clearance from obstacles?
float obs_clearance = 2;

//what is the +/-window we should check on obstacle map?
//for example 2 means check from ticks -2 to 2
int obs_window = 0;
VehicleParams()
: vel_to_breaking_dist(0.5f),
min_vel_to_breaking_dist(1),
breaking_vel(0.25f),
distance_accuracy(0.1f),
obs_clearance(2),
obs_window(0) {}
};

struct RCData {
double timestamp;
float pitch = 0, roll = 0, throttle = 0, yaw = 0, switch1 = 0, switch2 = 0, switch3 = 0;

void add(const RCData& other) {
pitch += other.pitch;
roll += other.roll;
throttle += other.throttle;
yaw += other.yaw;
}
void subtract(const RCData& other) {
pitch -= other.pitch;
roll -= other.roll;
throttle -= other.throttle;
yaw -= other.yaw;
}
void divideBy(float k) {
pitch /= k;
roll /= k;
throttle /= k;
yaw /= k;
}
bool isAnyMoreThan(float k) {
using std::abs;
return abs(pitch) > k || abs(roll) > k || abs(throttle) > k || abs(yaw) > k;
}
string toString() {
return Utils::stringf("RCData[pitch=%f, roll=%f, throttle=%f, yaw=%f]", pitch, roll, throttle, yaw);
}
};

//General exception when move command has runtime errors
class MoveException : public std::runtime_error {
public:
MoveException(const std::string& message)
: runtime_error(message) {
}
};


}
} //namespace
#endif
Loading