Add option to publish a pure 2D pose. (#683)

If the new `publish_frame_projected_to_2d` option is set to true,
the published pose will be restricted to a pure 2D pose
(no roll, pitch, or z-offset).
This prevents potentially unwanted out-of-plane poses in 2D mode
that can occur due to the pose extrapolation step (e.g. if the pose
shall be published as a 'base-footprint'-like frame).
master
Michael Grupp 2018-02-26 12:30:58 +01:00 committed by Wally B. Feed
parent caac1b3ae5
commit 5251634d3d
9 changed files with 18 additions and 1 deletions

View File

@ -211,7 +211,13 @@ void Node::PublishTrajectoryStates(const ::ros::WallTimerEvent& timer_event) {
const ::cartographer::common::Time now = std::max( const ::cartographer::common::Time now = std::max(
FromRos(ros::Time::now()), extrapolator.GetLastExtrapolatedTime()); FromRos(ros::Time::now()), extrapolator.GetLastExtrapolatedTime());
stamped_transform.header.stamp = ToRos(now); stamped_transform.header.stamp = ToRos(now);
const Rigid3d tracking_to_local = extrapolator.ExtrapolatePose(now);
Rigid3d tracking_to_local = extrapolator.ExtrapolatePose(now);
if (trajectory_state.trajectory_options.publish_frame_projected_to_2d) {
tracking_to_local = carto::transform::Embed3D(
carto::transform::Project2D(tracking_to_local));
}
const Rigid3d tracking_to_map = const Rigid3d tracking_to_map =
trajectory_state.local_to_map * tracking_to_local; trajectory_state.local_to_map * tracking_to_local;

View File

@ -54,6 +54,8 @@ TrajectoryOptions CreateTrajectoryOptions(
lua_parameter_dictionary->GetBool("provide_odom_frame"); lua_parameter_dictionary->GetBool("provide_odom_frame");
options.use_odometry = lua_parameter_dictionary->GetBool("use_odometry"); options.use_odometry = lua_parameter_dictionary->GetBool("use_odometry");
options.use_nav_sat = lua_parameter_dictionary->GetBool("use_nav_sat"); options.use_nav_sat = lua_parameter_dictionary->GetBool("use_nav_sat");
options.publish_frame_projected_to_2d =
lua_parameter_dictionary->GetBool("publish_frame_projected_to_2d");
options.num_laser_scans = options.num_laser_scans =
lua_parameter_dictionary->GetNonNegativeInt("num_laser_scans"); lua_parameter_dictionary->GetNonNegativeInt("num_laser_scans");
options.num_multi_echo_laser_scans = options.num_multi_echo_laser_scans =
@ -108,6 +110,7 @@ bool FromRosMessage(const cartographer_ros_msgs::TrajectoryOptions& msg,
options->provide_odom_frame = msg.provide_odom_frame; options->provide_odom_frame = msg.provide_odom_frame;
options->use_odometry = msg.use_odometry; options->use_odometry = msg.use_odometry;
options->use_nav_sat = msg.use_nav_sat; options->use_nav_sat = msg.use_nav_sat;
options->publish_frame_projected_to_2d = msg.publish_frame_projected_to_2d;
options->num_laser_scans = msg.num_laser_scans; options->num_laser_scans = msg.num_laser_scans;
options->num_multi_echo_laser_scans = msg.num_multi_echo_laser_scans; options->num_multi_echo_laser_scans = msg.num_multi_echo_laser_scans;
options->num_subdivisions_per_laser_scan = options->num_subdivisions_per_laser_scan =
@ -136,6 +139,7 @@ cartographer_ros_msgs::TrajectoryOptions ToRosMessage(
msg.provide_odom_frame = options.provide_odom_frame; msg.provide_odom_frame = options.provide_odom_frame;
msg.use_odometry = options.use_odometry; msg.use_odometry = options.use_odometry;
msg.use_nav_sat = options.use_nav_sat; msg.use_nav_sat = options.use_nav_sat;
msg.publish_frame_projected_to_2d = options.publish_frame_projected_to_2d;
msg.num_laser_scans = options.num_laser_scans; msg.num_laser_scans = options.num_laser_scans;
msg.num_multi_echo_laser_scans = options.num_multi_echo_laser_scans; msg.num_multi_echo_laser_scans = options.num_multi_echo_laser_scans;
msg.num_subdivisions_per_laser_scan = options.num_subdivisions_per_laser_scan; msg.num_subdivisions_per_laser_scan = options.num_subdivisions_per_laser_scan;

View File

@ -35,6 +35,7 @@ struct TrajectoryOptions {
bool provide_odom_frame; bool provide_odom_frame;
bool use_odometry; bool use_odometry;
bool use_nav_sat; bool use_nav_sat;
bool publish_frame_projected_to_2d;
int num_laser_scans; int num_laser_scans;
int num_multi_echo_laser_scans; int num_multi_echo_laser_scans;
int num_subdivisions_per_laser_scan; int num_subdivisions_per_laser_scan;

View File

@ -23,6 +23,7 @@ options = {
published_frame = "base_link", published_frame = "base_link",
odom_frame = "odom", odom_frame = "odom",
provide_odom_frame = true, provide_odom_frame = true,
publish_frame_projected_to_2d = false,
use_odometry = false, use_odometry = false,
use_nav_sat = false, use_nav_sat = false,
num_laser_scans = 0, num_laser_scans = 0,

View File

@ -23,6 +23,7 @@ options = {
published_frame = "base_link", published_frame = "base_link",
odom_frame = "odom", odom_frame = "odom",
provide_odom_frame = true, provide_odom_frame = true,
publish_frame_projected_to_2d = false,
use_odometry = false, use_odometry = false,
use_nav_sat = false, use_nav_sat = false,
num_laser_scans = 0, num_laser_scans = 0,

View File

@ -23,6 +23,7 @@ options = {
published_frame = "base_footprint", published_frame = "base_footprint",
odom_frame = "odom", odom_frame = "odom",
provide_odom_frame = true, provide_odom_frame = true,
publish_frame_projected_to_2d = false,
use_odometry = false, use_odometry = false,
use_nav_sat = false, use_nav_sat = false,
num_laser_scans = 1, num_laser_scans = 1,

View File

@ -23,6 +23,7 @@ options = {
published_frame = "horizontal_laser_link", published_frame = "horizontal_laser_link",
odom_frame = "odom", odom_frame = "odom",
provide_odom_frame = true, provide_odom_frame = true,
publish_frame_projected_to_2d = false,
use_odometry = false, use_odometry = false,
use_nav_sat = false, use_nav_sat = false,
num_laser_scans = 1, num_laser_scans = 1,

View File

@ -23,6 +23,7 @@ options = {
published_frame = "odom", published_frame = "odom",
odom_frame = "odom", odom_frame = "odom",
provide_odom_frame = false, provide_odom_frame = false,
publish_frame_projected_to_2d = false,
use_odometry = true, use_odometry = true,
use_nav_sat = false, use_nav_sat = false,
num_laser_scans = 1, num_laser_scans = 1,

View File

@ -18,6 +18,7 @@ string odom_frame
bool provide_odom_frame bool provide_odom_frame
bool use_odometry bool use_odometry
bool use_nav_sat bool use_nav_sat
bool publish_frame_projected_to_2d
int32 num_laser_scans int32 num_laser_scans
int32 num_multi_echo_laser_scans int32 num_multi_echo_laser_scans
int32 num_subdivisions_per_laser_scan int32 num_subdivisions_per_laser_scan