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
GCS Bridge Plugin #1117
Closed
Closed
GCS Bridge Plugin #1117
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
438b6d5
Add QGC bridge plugin
arwagoner edd908e
Removed unncessary spacing
arwagoner e85b27f
Correcting formatting issues
arwagoner 8474bdc
Fixing indentions
arwagoner 7c19f0a
Fixing indentations
arwagoner 17a7774
Formatting fix
arwagoner File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,4 +47,7 @@ | |
<class name="vision_speed_estimate" type="mavros::extra_plugins::VisionSpeedEstimatePlugin" base_class_type="mavros::plugin::PluginBase"> | ||
<description>Send vision speed estimate to FCU.</description> | ||
</class> | ||
<class name="gcs_bridge_plugin" type="mavros::extra_plugins::GCSBridgePlugin" base_class_type="mavros::plugin::PluginBase" output="screen"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indentation please |
||
<description> Establishes a connection between FCU, companion computer, and GCS. </description> | ||
</class> | ||
</library> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/** | ||
* @brief GCSBridge plugin | ||
* @file gcs_bridge_plugin.cpp | ||
* @author Amy Wagoner <arwagoner@gmail.com> | ||
* | ||
* @addtogroup plugin | ||
* @{ | ||
*/ | ||
/* | ||
* Copyright 2018 Amy Wagoner. | ||
* | ||
* This file is part of the mavros package and subject to the license terms | ||
* in the top-level LICENSE file of the mavros repository. | ||
* https://github.com/mavlink/mavros/tree/master/LICENSE.md | ||
*/ | ||
|
||
#include <mavros/mavros_plugin.h> | ||
|
||
|
||
namespace mavros { | ||
namespace extra_plugins{ | ||
/** | ||
* @brief GCS Bridge plugin | ||
* | ||
* | ||
*/ | ||
class GCSBridgePlugin : public plugin::PluginBase { | ||
public: | ||
GCSBridgePlugin() : PluginBase(), | ||
mavlink_nh("mavlink") | ||
{ } | ||
|
||
void initialize(UAS &uas_) | ||
{ | ||
PluginBase::initialize(uas_); | ||
|
||
mavlink_sub = mavlink_nh.subscribe("from", 10, &GCSBridgePlugin::mavlink_sub_cb,this); | ||
mavlink_pub = mavlink_nh.advertise<mavros_msgs::Mavlink>("to", 10); | ||
} | ||
|
||
Subscriptions get_subscriptions() | ||
{ | ||
return { /* Rx disabled */ }; | ||
} | ||
|
||
private: | ||
ros::NodeHandle mavlink_nh; | ||
|
||
ros::Subscriber mavlink_sub; | ||
ros::Publisher mavlink_pub; | ||
|
||
void mavlink_pub_cb(const mavlink::mavlink_message_t *mmsg, const mavconn::Framing framing) | ||
{ | ||
auto rmsg = boost::make_shared<mavros_msgs::Mavlink>(); | ||
|
||
rmsg->header.stamp = ros::Time::now(); | ||
mavros_msgs::mavlink::convert(*mmsg, *rmsg, mavros::utils::enum_value(framing)); | ||
mavlink_pub.publish(rmsg); | ||
} | ||
|
||
void mavlink_sub_cb(const mavros_msgs::Mavlink::ConstPtr &rmsg) | ||
{ | ||
mavlink::mavlink_message_t mmsg; | ||
if (mavros_msgs::mavlink::convert(*rmsg, mmsg)) | ||
{ | ||
UAS_GCS(m_uas)->send_message_ignore_drop(&mmsg); | ||
} | ||
else | ||
ROS_ERROR("Packet drop: convert error."); | ||
} | ||
}; | ||
} // namespace extra_plugins | ||
} // namespace mavros | ||
|
||
#include <pluginlib/class_list_macros.h> | ||
PLUGINLIB_EXPORT_CLASS(mavros::extra_plugins::GCSBridgePlugin, mavros::plugin::PluginBase) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation are 8 spaces, not 4. Please use uncrustify (
uncrustify -c ${ROS_WORKSPACE}/src/mavros/mavros/tools/uncrustify-cpp.cfg --replace --no-backup <path/to/file.ext>
).