Skip to content

Commit

Permalink
rename moveByAngle -> moveByAngleZ
Browse files Browse the repository at this point in the history
  • Loading branch information
sytelus committed Mar 23, 2018
1 parent 60a522c commit 012c753
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 27 deletions.
12 changes: 6 additions & 6 deletions AirLib/include/vehicles/multirotor/api/MultirotorApi.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ using namespace msr::airlib;

namespace msr { namespace airlib {

// We want to make it possible for MultirotorRpcLibClient to call the offboard movement methods (moveByAngle, moveByVelocity, etc) at a high
// We want to make it possible for MultirotorRpcLibClient to call the offboard movement methods (moveByAngleZ, moveByVelocity, etc) at a high
// rate, like 30 times a second. But we also want these movement methods to drive the drone at a reliable rate which we do inside
// DroneControllerBase using the Waiter object so it pumps the virtual commandVelocity method at a fixed rate defined by getCommandPeriod.
// This fixed rate is needed by the drone flight controller (for example PX4) because the flight controller usually reverts to
Expand Down Expand Up @@ -83,9 +83,9 @@ class MultirotorApi : public VehicleApiBase {
return controller_->goHome(*pending_);
}

bool moveByAngle(float pitch, float roll, float z, float yaw, float duration)
bool moveByAngleZ(float pitch, float roll, float z, float yaw, float duration)
{
std::shared_ptr<OffboardCommand> cmd = std::make_shared<MoveByAngle>(controller_, pitch, roll, z, yaw, duration);
std::shared_ptr<OffboardCommand> cmd = std::make_shared<MoveByAngleZ>(controller_, pitch, roll, z, yaw, duration);
return enqueueCommand(cmd);
}

Expand Down Expand Up @@ -384,18 +384,18 @@ class MultirotorApi : public VehicleApiBase {
return true;
}

class MoveByAngle : public OffboardCommand {
class MoveByAngleZ : public OffboardCommand {
float pitch_, roll_, z_, yaw_, duration_;
public:
MoveByAngle(DroneControllerBase* controller, float pitch, float roll, float z, float yaw, float duration) : OffboardCommand(controller) {
MoveByAngleZ(DroneControllerBase* controller, float pitch, float roll, float z, float yaw, float duration) : OffboardCommand(controller) {
this->pitch_ = pitch;
this->roll_ = roll;
this->z_ = z;
this->yaw_ = yaw;
this->duration_ = duration;
}
virtual void executeImpl(DroneControllerBase* controller, CancelableBase& cancelable) override {
controller->moveByAngle(pitch_, roll_, z_, yaw_, duration_, cancelable);
controller->moveByAngleZ(pitch_, roll_, z_, yaw_, duration_, cancelable);
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class MultirotorRpcLibClient : public RpcLibClientBase {
bool takeoff(float max_wait_ms = 15);
bool land(float max_wait_seconds = 60);
bool goHome();
bool moveByAngle(float pitch, float roll, float z, float yaw, float duration);
bool moveByAngleZ(float pitch, float roll, float z, float yaw, float duration);

bool moveByVelocity(float vx, float vy, float vz, float duration,
DrivetrainType drivetrain = DrivetrainType::MaxDegreeOfFreedom, const YawMode& yaw_mode = YawMode());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@ class DroneControllerBase : public VehicleControllerBase {
/// make the drone move forwards, a little bit of roll can make it move sideways. The yaw control can
/// make the drone spin around on the spot. The duration says how long you want to apply these settings
/// before reverting to a hover command. So you can say "fly forwards slowly for 1 second" using
/// moveByAngle(0.1, 0, z, yaw, 1, ...). The cancelable_action can be used to canel all actions. In fact,
/// moveByAngleZ(0.1, 0, z, yaw, 1, ...). The cancelable_action can be used to canel all actions. In fact,
/// every time you call another move* method you will automatically cancel any previous action that is
/// happening.
virtual bool moveByAngle(float pitch, float roll, float z, float yaw, float duration
virtual bool moveByAngleZ(float pitch, float roll, float z, float yaw, float duration
, CancelableBase& cancelable_action);


Expand Down
4 changes: 2 additions & 2 deletions AirLib/src/vehicles/multirotor/api/MultirotorRpcLibClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ bool MultirotorRpcLibClient::goHome()
return static_cast<rpc::client*>(getClient())->call("goHome").as<bool>();
}

bool MultirotorRpcLibClient::moveByAngle(float pitch, float roll, float z, float yaw, float duration)
bool MultirotorRpcLibClient::moveByAngleZ(float pitch, float roll, float z, float yaw, float duration)
{
return static_cast<rpc::client*>(getClient())->call("moveByAngle", pitch, roll, z, yaw, duration).as<bool>();
return static_cast<rpc::client*>(getClient())->call("moveByAngleZ", pitch, roll, z, yaw, duration).as<bool>();
}

bool MultirotorRpcLibClient::moveByVelocity(float vx, float vy, float vz, float duration, DrivetrainType drivetrain, const YawMode& yaw_mode)
Expand Down
4 changes: 2 additions & 2 deletions AirLib/src/vehicles/multirotor/api/MultirotorRpcLibServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ MultirotorRpcLibServer::MultirotorRpcLibServer(MultirotorApi* drone, string serv


(static_cast<rpc::server*>(getServer()))->
bind("moveByAngle", [&](float pitch, float roll, float z, float yaw, float duration) ->
bool { return getDroneApi()->moveByAngle(pitch, roll, z, yaw, duration); });
bind("moveByAngleZ", [&](float pitch, float roll, float z, float yaw, float duration) ->
bool { return getDroneApi()->moveByAngleZ(pitch, roll, z, yaw, duration); });
(static_cast<rpc::server*>(getServer()))->
bind("moveByVelocity", [&](float vx, float vy, float vz, float duration, DrivetrainType drivetrain, const MultirotorRpcLibAdapators::YawMode& yaw_mode) ->
bool { return getDroneApi()->moveByVelocity(vx, vy, vz, duration, drivetrain, yaw_mode.to()); });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ void DroneControllerBase::loopCommandPost()
//no-op by default. derived class can override it if needed
}

bool DroneControllerBase::moveByAngle(float pitch, float roll, float z, float yaw, float duration
bool DroneControllerBase::moveByAngleZ(float pitch, float roll, float z, float yaw, float duration
, CancelableBase& cancelable_action)
{
if (duration <= 0)
Expand Down
22 changes: 11 additions & 11 deletions DroneShell/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -482,9 +482,9 @@ class MoveByManualCommand : public DroneCommand {
};


class MoveByAngleCommand : public DroneCommand {
class MoveByAngleZCommand : public DroneCommand {
public:
MoveByAngleCommand() : DroneCommand("MoveByAngle", "Move with specified roll and pitch, leaving z as-is")
MoveByAngleZCommand() : DroneCommand("MoveByAngleZ", "Move with specified roll and pitch, leaving z as-is")
{
this->addSwitch({"-pitch", "0", "pitch angle in degrees (default 0)" });
this->addSwitch({"-roll", "0", "roll angle in degrees (default 0)" });
Expand All @@ -503,7 +503,7 @@ class MoveByAngleCommand : public DroneCommand {
CommandContext* context = params.context;

context->tasker.execute([=]() {
context->client.moveByAngle(pitch, roll, z, yaw, duration);
context->client.moveByAngleZ(pitch, roll, z, yaw, duration);
});

return false;
Expand Down Expand Up @@ -662,12 +662,12 @@ class BackForthByAngleCommand : public DroneCommand {
CommandContext* context = params.context;

context->tasker.execute([=]() {
if (!context->client.moveByAngle(pitch, roll, z, yaw, duration)) {
if (!context->client.moveByAngleZ(pitch, roll, z, yaw, duration)) {
throw std::runtime_error("BackForthByAngleCommand cancelled");
}
context->client.hover();
context->sleep_for(pause_time);
if (!context->client.moveByAngle(-pitch, -roll, z, yaw, duration)){
if (!context->client.moveByAngleZ(-pitch, -roll, z, yaw, duration)){
throw std::runtime_error("BackForthByAngleCommand cancelled");
}
}, iterations);
Expand Down Expand Up @@ -747,22 +747,22 @@ class SquareByAngleCommand : public DroneCommand {
CommandContext* context = params.context;

context->tasker.execute([=]() {
if (!context->client.moveByAngle(pitch, -roll, z, yaw, 0)) {
if (!context->client.moveByAngleZ(pitch, -roll, z, yaw, 0)) {
throw std::runtime_error("SquareByAngleCommand cancelled");
}
context->client.hover();
context->sleep_for(pause_time);
if (!context->client.moveByAngle(-pitch, -roll, z, yaw, 0)) {
if (!context->client.moveByAngleZ(-pitch, -roll, z, yaw, 0)) {
throw std::runtime_error("SquareByAngleCommand cancelled");
}
context->client.hover();
context->sleep_for(pause_time);
if (!context->client.moveByAngle(-pitch, roll, z, yaw, 0)) {
if (!context->client.moveByAngleZ(-pitch, roll, z, yaw, 0)) {
throw std::runtime_error("SquareByAngleCommand cancelled");
}
context->client.hover();
context->sleep_for(pause_time);
if (!context->client.moveByAngle(-pitch, -roll, z, yaw, 0)){
if (!context->client.moveByAngleZ(-pitch, -roll, z, yaw, 0)){
throw std::runtime_error("SquareByAngleCommand cancelled");
}
context->client.hover();
Expand Down Expand Up @@ -1351,7 +1351,7 @@ int main(int argc, const char *argv[]) {
MoveToPositionCommand moveToPosition;
GetPositionCommand getPosition;
MoveByManualCommand moveByManual;
MoveByAngleCommand moveByAngle;
MoveByAngleZCommand moveByAngleZ;
MoveByVelocityCommand moveByVelocity;
MoveByVelocityZCommand moveByVelocityZ;
MoveOnPathCommand moveOnPath;
Expand Down Expand Up @@ -1383,7 +1383,7 @@ int main(int argc, const char *argv[]) {
shell.addCommand(hover);
shell.addCommand(moveToPosition);
shell.addCommand(moveByManual);
shell.addCommand(moveByAngle);
shell.addCommand(moveByAngleZ);
shell.addCommand(moveByVelocity);
shell.addCommand(moveByVelocityZ);
shell.addCommand(moveOnPath);
Expand Down
4 changes: 2 additions & 2 deletions PythonClient/AirSimClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -547,8 +547,8 @@ def getServerDebugInfo(self):


# APIs for control
def moveByAngle(self, pitch, roll, z, yaw, duration):
return self.client.call('moveByAngle', pitch, roll, z, yaw, duration)
def moveByAngleZ(self, pitch, roll, z, yaw, duration):
return self.client.call('moveByAngleZ', pitch, roll, z, yaw, duration)

def moveByVelocity(self, vx, vy, vz, duration, drivetrain = DrivetrainType.MaxDegreeOfFreedom, yaw_mode = YawMode()):
return self.client.call('moveByVelocity', vx, vy, vz, duration, drivetrain, yaw_mode)
Expand Down

0 comments on commit 012c753

Please sign in to comment.