19 #include <mavros_msgs/CommandLong.h> 20 #include <mavros_msgs/MountControl.h> 21 #include <geometry_msgs/Quaternion.h> 22 #include <mavros_msgs/MountConfigure.h> 25 namespace extra_plugins {
28 using mavlink::common::MAV_MOUNT_MODE;
29 using mavlink::common::MAV_CMD;
79 geometry_msgs::Quaternion quaternion_msg;
81 mount_orientation_pub.
publish(quaternion_msg);
92 mavlink::common::msg::COMMAND_LONG
cmd {};
97 cmd.param1 = req->pitch;
98 cmd.param2 = req->roll;
99 cmd.param3 = req->yaw;
100 cmd.param4 = req->altitude;
101 cmd.param5 = req->latitude;
102 cmd.param6 = req->longitude;
103 cmd.param7 = req->mode;
109 mavros_msgs::MountConfigure::Response &res)
111 using mavlink::common::MAV_CMD;
114 auto client = nh.
serviceClient<mavros_msgs::CommandLong>(
"cmd/command");
116 mavros_msgs::CommandLong
cmd{};
118 cmd.request.broadcast =
false;
119 cmd.request.command =
enum_value(MAV_CMD::DO_MOUNT_CONFIGURE);
120 cmd.request.confirmation =
false;
121 cmd.request.param1 = req.mode;
122 cmd.request.param2 = req.stabilize_roll;
123 cmd.request.param3 = req.stabilize_pitch;
124 cmd.request.param4 = req.stabilize_yaw;
125 cmd.request.param5 = req.roll_input;
126 cmd.request.param6 = req.pitch_input;
127 cmd.request.param7 = req.yaw_input;
129 ROS_DEBUG_NAMED(
"mount",
"MountConfigure: Request mode %u ", req.mode);
130 res.success = client.call(
cmd);
136 ROS_ERROR_COND_NAMED(!res.success,
"mount",
"MountCongifure: command plugin service call failed!");
ServiceClient serviceClient(const std::string &service_name, bool persistent=false, const M_string &header_values=M_string())
#define ROS_ERROR_COND_NAMED(cond, name,...)
Subscriptions get_subscriptions() override
void initialize(UAS &uas_) override
std::shared_ptr< MAVConnInterface const > ConstPtr
void publish(const boost::shared_ptr< M > &message) const
void quaternionEigenToMsg(const Eigen::Quaterniond &e, geometry_msgs::Quaternion &m)
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
HandlerInfo make_handler(const mavlink::msgid_t id, void(_C::*fn)(const mavlink::mavlink_message_t *msg, const mavconn::Framing framing))
ServiceServer advertiseService(const std::string &service, bool(T::*srv_func)(MReq &, MRes &), T *obj)
void handle_mount_orientation(const mavlink::mavlink_message_t *msg, mavlink::common::msg::MOUNT_ORIENTATION &mo)
Publish the mount orientation.
bool mount_configure_cb(mavros_msgs::MountConfigure::Request &req, mavros_msgs::MountConfigure::Response &res)
ros::Subscriber command_sub
#define ROS_DEBUG_NAMED(name,...)
#define UAS_FCU(uasobjptr)
ros::ServiceServer configure_srv
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
Eigen::Quaterniond quaternion_from_rpy(const Eigen::Vector3d &rpy)
std::vector< HandlerInfo > Subscriptions
#define ROS_ERROR_NAMED(name,...)
void initialize(UAS &uas_) override
ros::Publisher mount_orientation_pub
#define PLUGINLIB_EXPORT_CLASS(class_type, base_class_type)
uint8_t get_tgt_component()
void command_cb(const mavros_msgs::MountControl::ConstPtr &req)
Send mount control commands to vehicle.
constexpr std::underlying_type< _T >::type enum_value(_T e)