19 #include <mavros_msgs/WaypointList.h> 20 #include <mavros_msgs/WaypointSetCurrent.h> 21 #include <mavros_msgs/WaypointReached.h> 25 namespace std_plugins {
38 PluginBase::initialize(uas_);
39 MissionBase::initialize(&
wp_nh);
42 wp_type = plugin::WP_TYPE::MISSION;
127 auto wpr = boost::make_shared<mavros_msgs::WaypointReached>();
130 wpr->wp_seq = mitr.seq;
158 if (wp_nh.
hasParam(
"enable_partial_push")) {
173 auto wpl = boost::make_shared<mavros_msgs::WaypointList>();
177 wpl->waypoints.clear();
178 wpl->waypoints.reserve(
waypoints.size());
180 wpl->waypoints.push_back(it);
189 bool pull_cb(mavros_msgs::WaypointPull::Request &req,
190 mavros_msgs::WaypointPull::Response &res)
212 bool push_cb(mavros_msgs::WaypointPush::Request &req,
213 mavros_msgs::WaypointPush::Response &res)
221 if (req.start_index) {
227 res.wp_transfered = 0;
231 if (
waypoints.size() < req.start_index + req.waypoints.size()) {
234 res.wp_transfered = 0;
241 uint16_t seq = req.start_index;
242 for (
auto &it : req.waypoints) {
285 bool clear_cb(mavros_msgs::WaypointClear::Request &req,
286 mavros_msgs::WaypointClear::Response &res)
305 bool set_cur_cb(mavros_msgs::WaypointSetCurrent::Request &req,
306 mavros_msgs::WaypointSetCurrent::Response &res)
void mission_request_list()
MAVROS Plugin base class.
ros::Timer schedule_timer
#define ROS_INFO_NAMED(name,...)
bool set_cur_cb(mavros_msgs::WaypointSetCurrent::Request &req, mavros_msgs::WaypointSetCurrent::Response &res)
void initialize(UAS &uas_) override
Plugin initializer.
void publish(const boost::shared_ptr< M > &message) const
const ros::Duration BOOTUP_TIME_DT
#define ROS_WARN_NAMED(name,...)
std::recursive_mutex mutex
ros::ServiceServer push_srv
HandlerInfo make_handler(const mavlink::msgid_t id, void(_C::*fn)(const mavlink::mavlink_message_t *msg, const mavconn::Framing framing))
ros::ServiceServer pull_srv
void restart_timeout_timer(void)
void handle_mission_item_int(const mavlink::mavlink_message_t *msg, WP_ITEM_INT &wpi)
handle MISSION_ITEM_INT mavlink msg handles and stores mission items when pulling waypoints ...
MissionBase(std::string _name)
void set_current_waypoint(size_t seq)
set the FCU current waypoint
bool has_capability(T capability)
Function to check if the flight controller has a capability.
ServiceServer advertiseService(const std::string &service, bool(T::*srv_func)(MReq &, MRes &), T *obj)
void handle_mission_count(const mavlink::mavlink_message_t *msg, mavlink::common::msg::MISSION_COUNT &mcnt)
handle MISSION_COUNT mavlink msg Handles a mission count from FCU in a Waypoint Pull Triggers a pull ...
bool clear_cb(mavros_msgs::WaypointClear::Request &req, mavros_msgs::WaypointClear::Response &res)
bool push_cb(mavros_msgs::WaypointPush::Request &req, mavros_msgs::WaypointPush::Response &res)
void handle_mission_current(const mavlink::mavlink_message_t *msg, mavlink::common::msg::MISSION_CURRENT &mcur)
handle MISSION_CURRENT mavlink msg This confirms a SET_CUR action
void mission_set_current(uint16_t seq)
ros::ServiceServer clear_srv
#define ROS_DEBUG_NAMED(name,...)
bool pull_cb(mavros_msgs::WaypointPull::Request &req, mavros_msgs::WaypointPull::Response &res)
void enable_capabilities_cb()
void handle_mission_item_reached(const mavlink::mavlink_message_t *msg, mavlink::common::msg::MISSION_ITEM_REACHED &mitr)
handle MISSION_ITEM_REACHED mavlink msg
std::lock_guard< std::recursive_mutex > lock_guard
void publish_waypoints() override
publish the updated waypoint list after operation
bool param(const std::string ¶m_name, T ¶m_val, const T &default_val) const
bool mission_item_int_support_confirmed
Mission manupulation plugin.
bool is_ardupilotmega()
Check that FCU is APM.
mavlink::common::MAV_PROTOCOL_CAPABILITY MAV_CAP
bool wait_fetch_all()
wait until a waypoint pull is complete. Pull happens asynchronously, this function blocks until it is...
std::vector< mavros_msgs::Waypoint > send_waypoints
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
bool wait_push_all()
wait until a waypoint push is complete. Push happens asynchronously, this function blocks until it is...
void mission_write_partial_list(uint16_t start_index, uint16_t end_index)
std::unique_lock< std::recursive_mutex > unique_lock
std::condition_variable list_sending
void handle_mission_request_int(const mavlink::mavlink_message_t *msg, mavlink::common::msg::MISSION_REQUEST_INT &mreq)
handle MISSION_REQUEST_INT mavlink msg handles and acts on misison request from FCU ...
void handle_mission_item(const mavlink::mavlink_message_t *msg, WP_ITEM &wpi)
handle MISSION_ITEM mavlink msg handles and stores mission items when pulling waypoints ...
void enable_connection_cb()
std::vector< HandlerInfo > Subscriptions
Subscriptions vector.
bool getParam(const std::string &key, std::string &s) const
void connection_cb(bool connected) override
ros::Publisher wp_reached_pub
void capabilities_cb(UAS::MAV_CAP capabilities) override
void handle_mission_ack(const mavlink::mavlink_message_t *msg, mavlink::common::msg::MISSION_ACK &mack)
handle MISSION_ACK mavlink msg Handles a MISSION_ACK which marks the end of a push, or a failure
void schedule_pull(const ros::Duration &dt)
bool hasParam(const std::string &key) const
ros::Publisher wp_list_pub
bool use_mission_item_int
void handle_mission_request(const mavlink::mavlink_message_t *msg, mavlink::common::msg::MISSION_REQUEST &mreq)
handle MISSION_REQUEST mavlink msg handles and acts on misison request from FCU
std::vector< mavros_msgs::Waypoint > waypoints
#define PLUGINLIB_EXPORT_CLASS(class_type, base_class_type)
ros::ServiceServer set_cur_srv
Subscriptions get_subscriptions() override
Return vector of MAVLink message subscriptions (handlers)
void mission_count(uint16_t cnt)