-
Notifications
You must be signed in to change notification settings - Fork 1k
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
[WIP] Set framework to define offset between global origin and current local position #691
Merged
Merged
Changes from 3 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
92b275c
add handlers for GPS_GLOBAL_ORIGIN and SET_GPS_GLOBAL_ORIGIN
TSC21 c4941a9
fix cast of encoding types
TSC21 5828670
refactor gps coord conversions
TSC21 5ec3c56
uncrustify
TSC21 55315c4
Merge branch 'master' of https://github.com/mavlink/mavros into globa…
TSC21 b732739
global_position: add LOCAL_POSITION_NED_SYSTEM_GLOBAL_OFFSET handler
TSC21 64111d4
global_position: add trasform sender for offset
TSC21 8215c7c
global_origin: refactor covariance matrix
TSC21 cbf87be
global_position: update copyright
TSC21 9420462
global_position: add initial support to REP 105
TSC21 35b0817
px4_config: global_position: update frame description
TSC21 555c3f1
global_position: correct identation
TSC21 855835e
global position: be consistent with frame and methods names (ecef!=wg…
TSC21 fd1fe5e
global_position: updates to code structure
TSC21 4f4127a
global_position: fix identation
TSC21 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,7 @@ | |
#include <nav_msgs/Odometry.h> | ||
#include <sensor_msgs/NavSatFix.h> | ||
#include <sensor_msgs/NavSatStatus.h> | ||
#include <geometry_msgs/PoseStamped.h> | ||
#include <geometry_msgs/TwistStamped.h> | ||
#include <geometry_msgs/TransformStamped.h> | ||
#include <geographic_msgs/GeoPointStamped.h> | ||
|
@@ -56,6 +57,7 @@ class GlobalPositionPlugin : public plugin::PluginBase { | |
// tf subsection | ||
gp_nh.param("tf/send", tf_send, true); | ||
gp_nh.param<std::string>("tf/frame_id", tf_frame_id, "map"); | ||
gp_nh.param<std::string>("tf/global_frame_id", tf_global_frame_id, "global_map"); | ||
gp_nh.param<std::string>("tf/child_frame_id", tf_child_frame_id, "base_link"); | ||
|
||
UAS_DIAG(m_uas).add("GPS", this, &GlobalPositionPlugin::gps_diag_run); | ||
|
@@ -70,6 +72,7 @@ class GlobalPositionPlugin : public plugin::PluginBase { | |
gp_rel_alt_pub = gp_nh.advertise<std_msgs::Float64>("rel_alt", 10); | ||
gp_hdg_pub = gp_nh.advertise<std_msgs::Float64>("compass_hdg", 10); | ||
gp_global_origin_pub = gp_nh.advertise<geographic_msgs::GeoPointStamped>("gp_origin", 10); | ||
gp_global_offset_pub = gp_nh.advertise<geometry_msgs::PoseStamped>("gp_lp_offset", 10); | ||
|
||
gp_set_global_origin_sub = gp_nh.subscribe("set_gp_origin", 10, &GlobalPositionPlugin::set_gp_origin_cb, this); | ||
} | ||
|
@@ -80,7 +83,8 @@ class GlobalPositionPlugin : public plugin::PluginBase { | |
make_handler(&GlobalPositionPlugin::handle_gps_raw_int), | ||
// GPS_STATUS: there no corresponding ROS message, and it is not supported by APM | ||
make_handler(&GlobalPositionPlugin::handle_global_position_int), | ||
make_handler(&GlobalPositionPlugin::handle_gps_global_origin) | ||
make_handler(&GlobalPositionPlugin::handle_gps_global_origin), | ||
make_handler(&GlobalPositionPlugin::handle_lpned_system_global_offset) | ||
}; | ||
} | ||
|
||
|
@@ -94,11 +98,13 @@ class GlobalPositionPlugin : public plugin::PluginBase { | |
ros::Publisher gp_hdg_pub; | ||
ros::Publisher gp_rel_alt_pub; | ||
ros::Publisher gp_global_origin_pub; | ||
ros::Publisher gp_global_offset_pub; | ||
|
||
ros::Subscriber gp_set_global_origin_sub; | ||
|
||
std::string frame_id; //!< frame for topic headers | ||
std::string tf_frame_id; //!< origin for TF | ||
std::string tf_global_frame_id; //!< global origin for TF | ||
std::string tf_child_frame_id; //!< frame for TF and Pose | ||
bool tf_send; | ||
double rot_cov; | ||
|
@@ -191,11 +197,11 @@ class GlobalPositionPlugin : public plugin::PluginBase { | |
void handle_gps_global_origin(const mavlink::mavlink_message_t *msg, mavlink::common::msg::GPS_GLOBAL_ORIGIN &glob_orig) | ||
{ | ||
auto g_origin = boost::make_shared<geographic_msgs::GeoPointStamped>(); | ||
// auto header = m_uas->synchronized_header(frame_id, gpos.time_boot_ms); #TODO: requires Mavlink msg update | ||
// auto header = m_uas->synchronized_header(frame_id, glob_orig.time_boot_ms); #TODO: requires Mavlink msg update | ||
|
||
g_origin->header.frame_id = frame_id; | ||
g_origin->header.stamp = ros::Time::now(); | ||
fill_lla_wgs84(glob_orig, g_origin); // @warning TODO: #529 | ||
fill_lla_wgs84(glob_orig, g_origin); // @warning TODO: #693 | ||
|
||
gp_global_origin_pub.publish(g_origin); | ||
} | ||
|
@@ -276,12 +282,12 @@ class GlobalPositionPlugin : public plugin::PluginBase { | |
ftf::EigenMapConstCovariance3d gps_cov(fix->position_covariance.data()); | ||
ftf::EigenMapCovariance6d pos_cov_out(odom->pose.covariance.data()); | ||
pos_cov_out << | ||
gps_cov(0, 0), gps_cov(0, 1), gps_cov(0, 2), 0.0, 0.0, 0.0, | ||
gps_cov(1, 0), gps_cov(1, 1), gps_cov(1, 2), 0.0, 0.0, 0.0, | ||
gps_cov(2, 0), gps_cov(2, 1), gps_cov(2, 2), 0.0, 0.0, 0.0, | ||
0.0, 0.0, 0.0, rot_cov, 0.0, 0.0, | ||
0.0, 0.0, 0.0, 0.0, rot_cov, 0.0, | ||
0.0, 0.0, 0.0, 0.0, 0.0, rot_cov; | ||
gps_cov(0, 0) , gps_cov(0, 1) , gps_cov(0, 2) , 0.0 , 0.0 , 0.0 , | ||
gps_cov(1, 0) , gps_cov(1, 1) , gps_cov(1, 2) , 0.0 , 0.0 , 0.0 , | ||
gps_cov(2, 0) , gps_cov(2, 1) , gps_cov(2, 2) , 0.0 , 0.0 , 0.0 , | ||
0.0 , 0.0 , 0.0 , rot_cov , 0.0 , 0.0 , | ||
0.0 , 0.0 , 0.0 , 0.0 , rot_cov , 0.0 , | ||
0.0 , 0.0 , 0.0 , 0.0 , 0.0 , rot_cov ; | ||
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. Hmm, we probably may do that: pos_cov_out.setZero();
pos_cov_out.block<3, 3>(0, 0) = gps_cov;
pos_cov_out.block<3, 3>(3, 3).diagonal() = rot_cov; 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. yeah. more reasonable |
||
|
||
// publish | ||
gp_fix_pub.publish(fix); | ||
|
@@ -309,6 +315,41 @@ class GlobalPositionPlugin : public plugin::PluginBase { | |
} | ||
} | ||
|
||
void handle_lpned_system_global_offset(const mavlink::mavlink_message_t *msg, mavlink::common::msg::LOCAL_POSITION_NED_SYSTEM_GLOBAL_OFFSET &offset) | ||
{ | ||
auto global_offset = boost::make_shared<geometry_msgs::PoseStamped>(); | ||
global_offset->header = m_uas->synchronized_header(tf_global_frame_id, offset.time_boot_ms); | ||
|
||
auto enu_position = ftf::transform_frame_ned_enu(Eigen::Vector3d(offset.x, offset.y, offset.z)); | ||
auto enu_baselink_orientation = ftf::transform_orientation_aircraft_baselink( | ||
ftf::transform_orientation_ned_enu( | ||
ftf::quaternion_from_rpy(offset.roll, offset.pitch, offset.yaw))); | ||
|
||
tf::pointEigenToMsg(enu_position, global_offset->pose.position); | ||
tf::quaternionEigenToMsg(enu_baselink_orientation, global_offset->pose.orientation); | ||
|
||
gp_global_offset_pub.publish(global_offset); | ||
|
||
// TF | ||
if (tf_send) { | ||
geometry_msgs::TransformStamped transform; | ||
|
||
transform.header.stamp = global_offset->header.stamp; | ||
transform.header.frame_id = tf_global_frame_id; | ||
transform.child_frame_id = tf_frame_id; | ||
|
||
// setRotation() | ||
transform.transform.rotation = global_offset->pose.orientation; | ||
|
||
// setOrigin() | ||
transform.transform.translation.x = global_offset->pose.position.x; | ||
transform.transform.translation.y = global_offset->pose.position.y; | ||
transform.transform.translation.z = global_offset->pose.position.z; | ||
|
||
m_uas->tf2_broadcaster.sendTransform(transform); | ||
} | ||
} | ||
|
||
/* -*- diagnostics -*- */ | ||
void gps_diag_run(diagnostic_updater::DiagnosticStatusWrapper &stat) | ||
{ | ||
|
@@ -348,7 +389,7 @@ class GlobalPositionPlugin : public plugin::PluginBase { | |
|
||
gpo.target_system = m_uas->get_tgt_system(); | ||
// gpo.time_boot_ms = stamp.toNSec() / 1000; #TODO: requires Mavlink msg update | ||
fill_lla_amsl(gpo, req);// @warning TODO: #529 | ||
fill_lla_amsl(gpo, req);// @warning TODO: #693 | ||
|
||
UAS_FCU(m_uas)->send_message_ignore_drop(gpo); | ||
} | ||
|
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
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.
Why not latching type?
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.
what do you mean with latching type?