camera.cpp
Go to the documentation of this file.
1 
9 /*
10  * Copyright 2021 Jaeyoung Lim.
11  *
12  * This file is part of the mavros package and subject to the license terms
13  * in the top-level LICENSE file of the mavros repository.
14  * https://github.com/mavlink/mavros/tree/master/LICENSE.md
15  */
16 
17 #include <mavros/mavros_plugin.h>
18 
19 #include <mavros_msgs/CameraImageCaptured.h>
20 
21 namespace mavros {
22 namespace extra_plugins {
23 
25 using mavlink::common::MAV_CMD;
26 using utils::enum_value;
27 
35 public:
37  nh("~"),
38  camera_nh("~camera")
39  { }
40 
41  void initialize(UAS &uas_) override
42  {
44 
45  camera_image_captured_pub = camera_nh.advertise<mavros_msgs::CameraImageCaptured>("image_captured", 10);
46 
47  }
48 
50  {
51  return {
53  };
54  }
55 
56 private:
60 
68  void handle_camera_image_captured(const mavlink::mavlink_message_t *msg, mavlink::common::msg::CAMERA_IMAGE_CAPTURED &mo)
69  {
70  auto ic = boost::make_shared<mavros_msgs::CameraImageCaptured>();
71 
72  ic->header.stamp = m_uas->synchronise_stamp(mo.time_boot_ms);
73  ic->geo.latitude = mo.lat/ 1E7;
74  ic->geo.longitude = mo.lon / 1E7; // deg
75  ic->geo.altitude = mo.alt / 1E3 + m_uas->geoid_to_ellipsoid_height(&ic->geo); // in meters
76  ic->relative_alt = mo.relative_alt / 1E3;
77  auto q = ftf::mavlink_to_quaternion(mo.q);
78  tf::quaternionEigenToMsg(q, ic->orientation);
79  ic->file_url = mavlink::to_string(mo.file_url);
80 
81  camera_image_captured_pub.publish(ic);
82  }
83 
84 };
85 } // namespace extra_plugins
86 } // namespace mavros
87 
void quaternionEigenToMsg(const Eigen::Quaterniond &e, geometry_msgs::Quaternion &m)
HandlerInfo make_handler(const mavlink::msgid_t id, void(_C::*fn)(const mavlink::mavlink_message_t *msg, const mavconn::Framing framing))
Eigen::Quaterniond mavlink_to_quaternion(const std::array< float, 4 > &q)
void publish(const boost::shared_ptr< M > &message) const
ros::Time synchronise_stamp(uint32_t time_boot_ms)
Subscriptions get_subscriptions() override
Definition: camera.cpp:49
ros::Publisher camera_image_captured_pub
Definition: camera.cpp:59
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
std::vector< HandlerInfo > Subscriptions
Camera plugin plugin.
Definition: camera.cpp:34
void initialize(UAS &uas_) override
void handle_camera_image_captured(const mavlink::mavlink_message_t *msg, mavlink::common::msg::CAMERA_IMAGE_CAPTURED &mo)
Publish camera image capture information.
Definition: camera.cpp:68
#define PLUGINLIB_EXPORT_CLASS(class_type, base_class_type)
double geoid_to_ellipsoid_height(T lla)
void initialize(UAS &uas_) override
Definition: camera.cpp:41
constexpr std::underlying_type< _T >::type enum_value(_T e)


mavros_extras
Author(s): Vladimir Ermakov , Amilcar Lucas
autogenerated on Tue Jun 13 2023 02:17:59