Skip to content

Commit

Permalink
Fix offboard plugin creation in example (mavlink#246)
Browse files Browse the repository at this point in the history
Fix offboard plugin creation in example
  • Loading branch information
hamishwillee authored Feb 7, 2018
1 parent b43744e commit ddbc7c3
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions example/offboard_velocity/offboard_velocity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,8 @@ inline void offboard_log(const std::string &offb_mode, const std::string msg)
*
* returns true if everything went well in Offboard control, exits with a log otherwise.
*/
bool offb_ctrl_ned(Device &device)
bool offb_ctrl_ned(std::shared_ptr<dronecore::Offboard> offboard)
{
std::shared_ptr<Offboard> offboard = std::make_shared<Offboard>(&device);

const std::string offb_mode = "NED";
// Send it once before starting offboard, otherwise it will be rejected.
offboard->set_velocity_ned({0.0f, 0.0f, 0.0f, 0.0f});
Expand Down Expand Up @@ -122,9 +120,8 @@ bool offb_ctrl_ned(Device &device)
*
* returns true if everything went well in Offboard control, exits with a log otherwise.
*/
bool offb_ctrl_body(Device &device)
bool offb_ctrl_body(std::shared_ptr<dronecore::Offboard> offboard)
{
std::shared_ptr<Offboard> offboard = std::make_shared<Offboard>(&device);

const std::string offb_mode = "BODY";

Expand Down Expand Up @@ -204,14 +201,15 @@ int main(int, char **)
std::cout << "In Air..." << std::endl;
sleep_for(seconds(5));


// using local NED co-ordinates
bool ret = offb_ctrl_ned(device);
bool ret = offb_ctrl_ned(offboard);
if (ret == false) {
return EXIT_FAILURE;
}

// using body co-ordinates
ret = offb_ctrl_body(device);
ret = offb_ctrl_body(offboard);
if (ret == false) {
return EXIT_FAILURE;
}
Expand Down

0 comments on commit ddbc7c3

Please sign in to comment.