Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding mount orientation to mount_control plugin #1297

Merged
merged 2 commits into from
Oct 25, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion mavros_extras/src/plugins/mount_control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include <mavros_msgs/CommandLong.h>
#include <mavros_msgs/MountControl.h>
#include <geometry_msgs/Quaternion.h>
#include <mavros_msgs/MountConfigure.h>

namespace mavros {
Expand Down Expand Up @@ -46,21 +47,40 @@ class MountControlPlugin : public plugin::PluginBase {
PluginBase::initialize(uas_);

command_sub = mount_nh.subscribe("command", 10, &MountControlPlugin::command_cb, this);
mount_orientation_pub = mount_nh.advertise<geometry_msgs::Quaternion>("orientation", 10);
configure_srv = mount_nh.advertiseService("configure", &MountControlPlugin::mount_configure_cb, this);

}

Subscriptions get_subscriptions()
{
return { /* Rx disabled */ };
return {
make_handler(&MountControlPlugin::handle_mount_orientation)
};
}

private:
ros::NodeHandle nh;
ros::NodeHandle mount_nh;
ros::Subscriber command_sub;
ros::Publisher mount_orientation_pub;
ros::ServiceServer configure_srv;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove the extra line

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably better to apply autoformatter?

/**
* @brief Publish the mount orientation
*
* Message specification: https://mavlink.io/en/messages/common.html#MOUNT_ORIENTATION
vooon marked this conversation as resolved.
Show resolved Hide resolved
* @param msg the mavlink message
* @param mo received MountOrientation msg
*/
void handle_mount_orientation(const mavlink::mavlink_message_t *msg, mavlink::common::msg::MOUNT_ORIENTATION &mo)
{
auto q = ftf::quaternion_from_rpy(Eigen::Vector3d(mo.roll, mo.pitch, mo.yaw) * M_PI / 180.0);
geometry_msgs::Quaternion quaternion_msg;
tf::quaternionEigenToMsg(q, quaternion_msg);
mount_orientation_pub.publish(quaternion_msg);
}

/**
* @brief Send mount control commands to vehicle
*
Expand Down