Skip to content

Commit d386d20

Browse files
authored
Merge pull request #57 from AutonomyLab/add-auto-flight
Add autonomous flight plan capabilities to driver
2 parents 5e8af86 + 1a346e6 commit d386d20

File tree

6 files changed

+142
-3
lines changed

6 files changed

+142
-3
lines changed

bebop_driver/include/bebop_driver/bebop.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,9 @@ class Bebop
162162
void FlatTrim();
163163
// false: Stop, true: Start
164164
void NavigateHome(const bool& start_stop);
165+
void StartAutonomousFlight(const std::string &filepath);
166+
void PauseAutonomousFlight();
167+
void StopAutonomousFlight();
165168
void AnimationFlip(const uint8_t& anim_id);
166169

167170
// -1..1

bebop_driver/include/bebop_driver/bebop_driver_nodelet.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSI
3535
#include <std_msgs/Empty.h>
3636
#include <std_msgs/UInt8.h>
3737
#include <std_msgs/Bool.h>
38+
#include <std_msgs/String.h>
3839
#include <camera_info_manager/camera_info_manager.h>
3940
#include <image_transport/image_transport.h>
4041
#include <dynamic_reconfigure/server.h>
@@ -115,6 +116,9 @@ class BebopDriverNodelet : public nodelet::Nodelet
115116
ros::Subscriber reset_sub_;
116117
ros::Subscriber flattrim_sub_;
117118
ros::Subscriber navigatehome_sub_;
119+
ros::Subscriber start_autoflight_sub_;
120+
ros::Subscriber pause_autoflight_sub_;
121+
ros::Subscriber stop_autoflight_sub_;
118122
ros::Subscriber animation_sub_;
119123
ros::Subscriber snapshot_sub_;
120124
ros::Subscriber toggle_recording_sub_;
@@ -151,6 +155,9 @@ class BebopDriverNodelet : public nodelet::Nodelet
151155
void EmergencyCallback(const std_msgs::EmptyConstPtr& empty_ptr);
152156
void FlatTrimCallback(const std_msgs::EmptyConstPtr& empty_ptr);
153157
void NavigateHomeCallback(const std_msgs::BoolConstPtr& start_stop_ptr);
158+
void StartAutonomousFlightCallback(const std_msgs::StringConstPtr& file_path_ptr);
159+
void PauseAutonomousFlightCallback(const std_msgs::EmptyConstPtr& empty_ptr);
160+
void StopAutonomousFlightCallback(const std_msgs::EmptyConstPtr& empty_ptr);
154161
void FlipAnimationCallback(const std_msgs::UInt8ConstPtr& animid_ptr);
155162
void TakeSnapshotCallback(const std_msgs::EmptyConstPtr& empty_ptr);
156163
void ToggleRecordingCallback(const std_msgs::BoolConstPtr& toggle_ptr);

bebop_driver/src/bebop.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,30 @@ void Bebop::NavigateHome(const bool &start_stop)
475475
"Navigate home failed");
476476
}
477477

478+
void Bebop::StartAutonomousFlight(const std::string &filepath)
479+
{
480+
ThrowOnInternalError("Start autonomous flight failed");
481+
ThrowOnCtrlError(
482+
device_controller_ptr_->common->sendMavlinkStart(device_controller_ptr_->common, const_cast<char*>(filepath.c_str()), (eARCOMMANDS_COMMON_MAVLINK_START_TYPE)0),
483+
"Start autonomous flight failed");
484+
}
485+
486+
void Bebop::PauseAutonomousFlight()
487+
{
488+
ThrowOnInternalError("Pause autonomous flight failed");
489+
ThrowOnCtrlError(
490+
device_controller_ptr_->common->sendMavlinkPause(device_controller_ptr_->common),
491+
"Pause autonomous flight failed");
492+
}
493+
494+
void Bebop::StopAutonomousFlight()
495+
{
496+
ThrowOnInternalError("Stop autonomous flight failed");
497+
ThrowOnCtrlError(
498+
device_controller_ptr_->common->sendMavlinkStop(device_controller_ptr_->common),
499+
"Stop autonomous flight failed");
500+
}
501+
478502
void Bebop::AnimationFlip(const uint8_t &anim_id)
479503
{
480504
ThrowOnInternalError("Animation failed");

bebop_driver/src/bebop_driver_nodelet.cpp

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,10 @@ void BebopDriverNodelet::onInit()
126126
land_sub_ = nh.subscribe("land", 1, &BebopDriverNodelet::LandCallback, this);
127127
reset_sub_ = nh.subscribe("reset", 1, &BebopDriverNodelet::EmergencyCallback, this);
128128
flattrim_sub_ = nh.subscribe("flattrim", 1, &BebopDriverNodelet::FlatTrimCallback, this);
129-
navigatehome_sub_ = nh.subscribe("navigate_home", 1, &BebopDriverNodelet::NavigateHomeCallback, this);
129+
navigatehome_sub_ = nh.subscribe("autoflight/navigate_home", 1, &BebopDriverNodelet::NavigateHomeCallback, this);
130+
start_autoflight_sub_ = nh.subscribe("autoflight/start", 1, &BebopDriverNodelet::StartAutonomousFlightCallback, this);
131+
pause_autoflight_sub_ = nh.subscribe("autoflight/pause", 1, &BebopDriverNodelet::PauseAutonomousFlightCallback, this);
132+
stop_autoflight_sub_ = nh.subscribe("autoflight/stop", 1, &BebopDriverNodelet::StopAutonomousFlightCallback, this);
130133
animation_sub_ = nh.subscribe("flip", 1, &BebopDriverNodelet::FlipAnimationCallback, this);
131134
snapshot_sub_ = nh.subscribe("snapshot", 10, &BebopDriverNodelet::TakeSnapshotCallback, this);
132135
toggle_recording_sub_ = nh.subscribe("record", 10, &BebopDriverNodelet::ToggleRecordingCallback, this);
@@ -304,6 +307,56 @@ void BebopDriverNodelet::NavigateHomeCallback(const std_msgs::BoolConstPtr &star
304307
}
305308
}
306309

310+
void BebopDriverNodelet::StartAutonomousFlightCallback(const std_msgs::StringConstPtr& filepath_ptr)
311+
{
312+
std::string filepath;
313+
if (filepath_ptr->data.empty())
314+
{
315+
ROS_WARN("No flight plan provided. Using default: 'flightplan.mavlink'");
316+
filepath = "flightplan.mavlink";
317+
}
318+
else
319+
{
320+
filepath = filepath_ptr->data;
321+
}
322+
323+
try
324+
{
325+
ROS_INFO("Starting autonomous flight path: %s", filepath.c_str());
326+
bebop_ptr_->StartAutonomousFlight(filepath);
327+
}
328+
catch (const std::runtime_error& e)
329+
{
330+
ROS_ERROR_STREAM(e.what());
331+
}
332+
}
333+
334+
void BebopDriverNodelet::PauseAutonomousFlightCallback(const std_msgs::EmptyConstPtr& empty_ptr)
335+
{
336+
try
337+
{
338+
ROS_INFO("Pausing autonomous flight");
339+
bebop_ptr_->PauseAutonomousFlight();
340+
}
341+
catch (const std::runtime_error& e)
342+
{
343+
ROS_ERROR_STREAM(e.what());
344+
}
345+
}
346+
347+
void BebopDriverNodelet::StopAutonomousFlightCallback(const std_msgs::EmptyConstPtr& empty_ptr)
348+
{
349+
try
350+
{
351+
ROS_INFO("Stopping autonomous flight");
352+
bebop_ptr_->StopAutonomousFlight();
353+
}
354+
catch (const std::runtime_error& e)
355+
{
356+
ROS_ERROR_STREAM(e.what());
357+
}
358+
}
359+
307360
void BebopDriverNodelet::FlipAnimationCallback(const std_msgs::UInt8ConstPtr &animid_ptr)
308361
{
309362
try

bebop_tools/config/log710.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ teleop:
6666
type: topic
6767
message_type: "std_msgs/Empty"
6868
topic_name: flattrim
69-
deadman_buttons: [4, 5] # RT + X
69+
deadman_buttons: [0, 7] # RT + X
7070
axis_mappings: []
7171
flip:
7272
type: topic

docs/piloting.rst

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,59 @@ To move Bebop's virtual camera, publish a message of type `geometry_msgs/Twist <
6868
GPS Navigation
6969
==============
7070

71-
.. warning:: Not fully integrated/tested yet.
71+
Start Flight Plan
72+
-----------------
73+
74+
An autonomous flight plan consists of a series of GPS waypoints along with Bebop velocities and camera angles encoded in an XML file.
75+
76+
Requirements that must be met before an autonomous flight can start:
77+
78+
* Bebop is calibrated
79+
* Bebop is in outdoor mode
80+
* Bebop has fixed its GPS
81+
82+
To start an autonomous flight plan, publish a message of type `std_msgs/String <http://docs.ros.org/api/std_msgs/html/msg/String.html>`_ to `autoflight/start` topic. The ``data`` field should contain the name of the flight plan to execute, which is already stored on-board Bebop.
83+
84+
.. note:: If an empty string is published, then the default 'flightplan.mavlink' is used.
85+
86+
.. warning:: If not already flying, Bebop will attempt to take off upon starting a flight plan.
87+
88+
The `Flight Plan App <https://play.google.com/store/apps/details?id=com.parrot.freeflight3>`_ allows easy construction of flight plans and saves them on-board Bebop.
89+
90+
An FTP client can also be used to view and copy flight plans on-board Bebop. `FileZilla` is recommended:
91+
92+
.. code-block:: bash
93+
94+
$ sudo apt-get install filezilla
95+
$ filezilla
96+
97+
Then open `Site Manager` (top left), click `New Site`:
98+
99+
* `Host`: 192.168.42.1
100+
* `Protocol`: FTP
101+
* `Encrpytion`: Use plain FTP
102+
* `Logon Type`: Anonymous
103+
* Connect.
104+
105+
Pause Flight Plan
106+
-----------------
107+
108+
To pause the execution of an autonomous flight plan, publish a message of type `std_msgs/Empty <http://docs.ros.org/api/std_msgs/html/msg/Empty.html>`_ to `autoflight/pause` topic. Bebop will then hover and await further commands.
109+
To resume a paused flight plan, publish the same message that was used to start the autonomous flight (ie. to the topic `autoflight/start`). Bebop will fly to the lastest waypoint reached before continuing the flight plan.
110+
111+
.. note:: Any velocity commands sent to Bebop during an autonomous flight plan will pause the plan.
112+
113+
Stop Flight Plan
114+
----------------
115+
116+
To stop the execution of an autonomous flight plan, publish a message of type `std_msgs/Empty <http://docs.ros.org/api/std_msgs/html/msg/Empty.html>`_ to `autoflight/stop` topic. Bebop will hover and await further commands.
117+
118+
Navigate Home
119+
-------------
120+
121+
To ask Bebop to autonomously fly to it's home position, publish a message of type `std_msgs/Bool <http://docs.ros.org/api/std_msgs/html/msg/Bool.html>`_ to `autoflight/navigate_home` topic with the ``data`` field set to ``true``. To stop Bebop from navigating home, publish another message with ``data`` set to ``false``.
122+
123+
.. warning:: The topic has changed from `navigate_home` to `autoflight/navigate_home` after version 0.5.1.
72124

73125
Flat Trim
74126
=========

0 commit comments

Comments
 (0)