simple_offboard: param for performing land only in offboard mode

This commit is contained in:
Oleg Kalachev
2019-04-13 16:10:04 +03:00
parent bb9f56f6a6
commit 86da07bca8

View File

@@ -70,6 +70,7 @@ ros::Duration global_position_timeout;
ros::Duration battery_timeout;
float default_speed;
bool auto_release;
bool land_only_in_offboard;
std::map<string, string> reference_frames;
// Publishers
@@ -644,6 +645,12 @@ bool land(std_srvs::Trigger::Request& req, std_srvs::Trigger::Response& res)
checkState();
if (land_only_in_offboard) {
if (state.mode != "OFFBOARD") {
throw std::runtime_error("Copter is not in OFFBOARD mode");
}
}
static mavros_msgs::SetMode sm;
sm.request.custom_mode = "AUTO.LAND";
@@ -688,6 +695,7 @@ int main(int argc, char **argv)
nh.param<string>("mavros/local_position/tf/child_frame_id", fcu_frame, "base_link");
nh_priv.param("target_frame", target.child_frame_id, string("navigate_target"));
nh_priv.param("auto_release", auto_release, true);
nh_priv.param("land_only_in_offboard", land_only_in_offboard, true);
nh_priv.param("default_speed", default_speed, 0.5f);
nh_priv.getParam("reference_frames", reference_frames);