Skip to content
Open
Show file tree
Hide file tree
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
31 changes: 23 additions & 8 deletions sensing/autoware_gnss_poser/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,20 @@ The antenna is rigidly mounted on the vehicle, so this transformation is expecte

If the transformation from `base_link` to the antenna cannot be obtained, the fix is skipped: `gnss_fixed` still reports the receiver's status, but no pose is published. Depending on the startup order, the transformation may arrive after the first fixes, so the fixes are skipped silently for the first 5 seconds, counted by the `header.stamp` of the fixes from the first fix (whatever its status). After that, a fix that cannot get the transformation makes the node log an error once, naming both frames, so that a `header.frame_id` that never gets a transformation is visible instead of silently yielding no pose. When TF has the transformations but the lookup still fails, for example because `header.frame_id` is not a frame name TF accepts (empty, or starting with `/`), waiting does not help, so it is logged as an error at once. Each of the two problems is logged once, and again only after the transformation has been obtained in between. A rosbag replayed in a loop gets the 5 seconds only on its first pass.

### Orientation

NavSatFix carries no orientation. `orientation_source` selects where the orientation of the pose comes from:

| Value | Orientation | Rotation covariance (roll, pitch, yaw) |
| -------- | ------------------------------------------------------------------------------------------------ | -------------------------------------- |
| `ins` | the latest `autoware_orientation`. No pose is published until the first one has arrived. | its `rmse_rotation_*` squared |
| `motion` | the heading of the displacement from the previous position to the current one (roll = pitch = 0) | 0.1, 0.1, 1.0 [rad^2] |
| `none` | unknown: the identity, that is heading east in the map frame | 1.0, 1.0, 1.0 [rad^2] |

`orientation_source` replaces `use_gnss_ins_orientation`, which is deprecated. A configuration that sets only `use_gnss_ins_orientation` still works and gets a warning at startup. `false` is read as `motion`. `true` keeps what it did: as `ins` once `autoware_orientation` has arrived, as `none` until then. No value of `orientation_source` selects that, because a pose with the stand-in orientation cannot be told apart from one with a measured orientation: use `ins` when `autoware_orientation` is published and `none` otherwise. When both are set, `use_gnss_ins_orientation` is ignored.

The node logs the source in use at startup, and warns once when `autoware_orientation` arrives while the source is `none`, since it is then ignored.

## Inputs / Outputs

### Input
Expand All @@ -35,13 +49,14 @@ If the transformation from `base_link` to the antenna cannot be obtained, the fi

Parameters in below table

| Name | Type | Default | Description |
| -------------------------- | --------- | ---------------- | ------------------------------------------------------------------------------------------------------------------------------------ |
| `base_frame` | `string` | `base_link` | frame id for base_frame |
| `gnss_base_frame` | `string` | `gnss_base_link` | frame id for gnss_base_frame |
| `map_frame` | `string` | `map` | frame id for map_frame |
| `use_gnss_ins_orientation` | `boolean` | `true` | use Gnss-Ins orientation |
| `gnss_pose_pub_method` | `integer` | `0` | 0: Instant Value 1: Average Value 2: Median Value. Any other value is rejected at startup. |
| `buff_epoch` | `integer` | `1` | Number of positions the average / median is taken over (ignored for method 0). Range: 1~inf; smaller values are rejected at startup. |
| Name | Type | Default | Description |
| -------------------------- | --------- | ---------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `base_frame` | `string` | `base_link` | frame id for base_frame |
| `gnss_base_frame` | `string` | `gnss_base_link` | frame id for gnss_base_frame |
| `map_frame` | `string` | `map` | frame id for map_frame |
| `orientation_source` | `string` | `none` | `ins`, `motion` or `none`; see [Orientation](#orientation). Any other value is rejected at startup. |
| `use_gnss_ins_orientation` | `boolean` | not set | Deprecated: set `orientation_source` instead. Read only when `orientation_source` is not set: `false` as `motion`; `true` as before, see [Orientation](#orientation). |
| `gnss_pose_pub_method` | `integer` | `0` | 0: Instant Value 1: Average Value 2: Median Value. Any other value is rejected at startup. |
| `buff_epoch` | `integer` | `1` | Number of positions the average / median is taken over (ignored for method 0). Range: 1~inf; smaller values are rejected at startup. |

All above parameters can be changed in config file [gnss_poser.param.yaml](./config/gnss_poser.param.yaml "Click here to open config file") .
2 changes: 1 addition & 1 deletion sensing/autoware_gnss_poser/config/gnss_poser.param.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
gnss_base_frame: gnss_base_link
map_frame: map
buff_epoch: 1
use_gnss_ins_orientation: true
orientation_source: none
gnss_pose_pub_method: 0
6 changes: 3 additions & 3 deletions sensing/autoware_gnss_poser/design/GnssPoser.node.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ param_files:
default: config/gnss_poser.param.yaml

param_values:
- name: use_gnss_ins_orientation
type: bool
default: true
- name: orientation_source
type: string
default: none

# processes
processes:
Expand Down
1 change: 1 addition & 0 deletions sensing/autoware_gnss_poser/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<depend>geographiclib</depend>
<depend>geometry_msgs</depend>
<depend>libexpected-dev</depend>
<depend>rcl_interfaces</depend>
<depend>rclcpp</depend>
<depend>rclcpp_components</depend>
<depend>sensor_msgs</depend>
Expand Down
14 changes: 11 additions & 3 deletions sensing/autoware_gnss_poser/schema/gnss_poser.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,15 @@
"default": "map",
"description": "frame id for map_frame"
},
"orientation_source": {
"type": "string",
"enum": ["ins", "motion", "none"],
"default": "none",
"description": "Where the orientation of the pose comes from. ins: the latest autoware_orientation; no pose until the first one arrives. motion: the heading of the displacement between consecutive positions. none: unknown, the identity (heading east) with an rmse of 1.0 rad."
},
"use_gnss_ins_orientation": {
"type": "boolean",
"default": "true",
"description": "use Gnss-Ins orientation"
"description": "Deprecated: set orientation_source instead. Read only when orientation_source is not set: false is read as motion; true keeps what it did, which no orientation_source selects: ins once autoware_orientation has arrived, none until then."
},
"gnss_pose_pub_method": {
"type": "integer",
Expand All @@ -44,9 +49,12 @@
"base_frame",
"gnss_base_frame",
"map_frame",
"use_gnss_ins_orientation",
"gnss_pose_pub_method",
"buff_epoch"
],
"anyOf": [
{ "required": ["orientation_source"] },
{ "required": ["use_gnss_ins_orientation"] }
]
}
},
Expand Down
74 changes: 47 additions & 27 deletions sensing/autoware_gnss_poser/src/gnss_poser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <tf2_geometry_msgs/tf2_geometry_msgs.hpp>

#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <numeric>
Expand Down Expand Up @@ -190,6 +191,14 @@ geometry_msgs::msg::Point get_average_position(
return average_point;
}

std::array<double, 3> squared_rmse(
const autoware_sensing_msgs::msg::GnssInsOrientation & orientation)
{
return {
std::pow(orientation.rmse_rotation_x, 2), std::pow(orientation.rmse_rotation_y, 2),
std::pow(orientation.rmse_rotation_z, 2)};
}

geometry_msgs::msg::Quaternion get_quaternion_by_position_difference(
const geometry_msgs::msg::Point & point, const geometry_msgs::msg::Point & prev_point)
{
Expand All @@ -212,12 +221,6 @@ GnssPoser::GnssPoser(
"buff_epoch must be at least 1, got " + std::to_string(params.buff_epoch));
}
position_buffer_.set_capacity(params.buff_epoch);

// Stand-in until the first INS message arrives (not to publish zero value covariances).
const auto placeholder_rmse = static_cast<float>(covariance_defaults_.ins_placeholder_rmse);
ins_orientation_.rmse_rotation_x = placeholder_rmse;
ins_orientation_.rmse_rotation_y = placeholder_rmse;
ins_orientation_.rmse_rotation_z = placeholder_rmse;
}

void GnssPoser::set_projector_info(const autoware_map_msgs::msg::MapProjectorInfo & projector_info)
Expand All @@ -230,6 +233,7 @@ void GnssPoser::set_ins_orientation(
const autoware_sensing_msgs::msg::GnssInsOrientation & orientation)
{
ins_orientation_ = orientation;
received_ins_orientation_ = true;
}

GnssPoser::Result GnssPoser::input_fix(const sensor_msgs::msg::NavSatFix & fix)
Expand Down Expand Up @@ -272,21 +276,46 @@ GnssPoser::Result GnssPoser::input_fix(const sensor_msgs::msg::NavSatFix & fix)
: get_median_position(position_buffer_);
}

// calc gnss antenna orientation
geometry_msgs::msg::Quaternion orientation;
if (params_.use_gnss_ins_orientation) {
orientation = ins_orientation_.orientation;
} else {
if (!has_prev_position_) {
// calc gnss antenna orientation and its roll, pitch and yaw variances. An unknown orientation is
// the identity (heading east) with the placeholder rmse, so that its variances are not zero.
geometry_msgs::msg::Quaternion & orientation = gnss_antenna_pose.orientation;
const double placeholder_variance = std::pow(covariance_defaults_.ins_placeholder_rmse, 2);
std::array<double, 3> rotation_variances = {
placeholder_variance, placeholder_variance, placeholder_variance};
switch (params_.orientation_source) {
case OrientationSource::Ins:
if (!received_ins_orientation_) {
return {Outcome::NoOrientation, make_gnss_fixed(fix.header.stamp, true)};
}
orientation = ins_orientation_.orientation;
rotation_variances = squared_rmse(ins_orientation_);
break;

case OrientationSource::InsOrNone:
if (received_ins_orientation_) {
orientation = ins_orientation_.orientation;
rotation_variances = squared_rmse(ins_orientation_);
} else {
orientation = tf2::toMsg(tf2::Quaternion::getIdentity());
}
break;

case OrientationSource::None:
orientation = tf2::toMsg(tf2::Quaternion::getIdentity());
break;

case OrientationSource::Motion:
if (!has_prev_position_) {
prev_position_ = gnss_antenna_pose.position;
has_prev_position_ = true;
}
orientation =
get_quaternion_by_position_difference(gnss_antenna_pose.position, prev_position_);
prev_position_ = gnss_antenna_pose.position;
has_prev_position_ = true;
}
orientation = get_quaternion_by_position_difference(gnss_antenna_pose.position, prev_position_);
prev_position_ = gnss_antenna_pose.position;
rotation_variances = covariance_defaults_.motion_rotation_variances;
break;
}

gnss_antenna_pose.orientation = orientation;

// get TF from gnss_antenna to base_link.
const auto transform = lookup_antenna_to_base_link_(fix.header.frame_id);
// Drop this fix if its antenna transform is not available: the fix cannot be expressed as a
Expand All @@ -305,15 +334,6 @@ GnssPoser::Result GnssPoser::input_fix(const sensor_msgs::msg::NavSatFix & fix)
transform_lookup_failed_reported_ = false;
const geometry_msgs::msg::Transform antenna_to_base_link = transform.value();

std::array<double, 3> rotation_variances{};
if (params_.use_gnss_ins_orientation) {
rotation_variances[0] = std::pow(ins_orientation_.rmse_rotation_x, 2);
rotation_variances[1] = std::pow(ins_orientation_.rmse_rotation_y, 2);
rotation_variances[2] = std::pow(ins_orientation_.rmse_rotation_z, 2);
} else {
rotation_variances = covariance_defaults_.motion_rotation_variances;
}

geometry_msgs::msg::PoseWithCovariance gnss_base_pose_with_covariance;
gnss_base_pose_with_covariance.pose =
compose_base_link_pose(gnss_antenna_pose, antenna_to_base_link);
Expand Down
22 changes: 17 additions & 5 deletions sensing/autoware_gnss_poser/src/gnss_poser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,22 @@ namespace autoware::gnss_poser
// average / component-wise median of the last `buff_epoch` ones.
enum class GnssPosePubMethod { Instant = 0, Average = 1, Median = 2 };

/// \brief Where the orientation of the published pose comes from.
enum class OrientationSource {
Ins, ///< the latest INS orientation
Motion, ///< the heading of the displacement between consecutive positions
None, ///< unknown: the identity (heading east) with the placeholder rmse
/// The INS orientation once one has arrived, the identity with the placeholder rmse until then.
/// Selected only by the deprecated use_gnss_ins_orientation = true, and goes away with it.
InsOrNone,
};

/// \brief Configuration of GnssPoser, taken from the node parameters of the same names.
struct GnssPoserParams
{
GnssPosePubMethod gnss_pose_pub_method = GnssPosePubMethod::Instant;
int buff_epoch = 1;
bool use_gnss_ins_orientation = true;
OrientationSource orientation_source = OrientationSource::None;
/// frame_id of the published pose and of the transform to broadcast.
std::string map_frame = "map";
/// child_frame_id of the transform to broadcast.
Expand Down Expand Up @@ -81,8 +91,9 @@ struct GnssPoserCovarianceDefaults
std::array<double, 3> unknown_position_variances = default_unknown_position_variances;
/// Roll, pitch and yaw variances used while the orientation is derived from motion. [rad^2]
std::array<double, 3> motion_rotation_variances = default_motion_rotation_variances;
/// Stand-in rmse per axis until the first INS orientation arrives. It is squared into the
/// rotation variances like a real one, so 1.0 rad becomes 1.0 rad^2. [rad]
/// Rmse per axis claimed for the identity orientation that stands for an unknown one
/// (OrientationSource::None, and InsOrNone before the first INS orientation). It is squared into
/// the rotation variances like a real one, so 1.0 rad becomes 1.0 rad^2. [rad]
double ins_placeholder_rmse = default_ins_placeholder_rmse;
};

Expand Down Expand Up @@ -129,6 +140,7 @@ class GnssPoser
LocalProjector, ///< the map uses a local projector, so a GNSS fix cannot be converted
NotFixed, ///< the receiver reports no fix; its status is known but no pose is computed
Buffering, ///< the position buffer is not full yet (average and median methods)
NoOrientation, ///< orientation_source is ins and no INS orientation has arrived yet
/// TransformLookup gave a TransformLookupError, of either kind.
TransformLookupFailed,
Published, ///< a pose was computed, see Result::gnss_pose
Expand Down Expand Up @@ -160,8 +172,7 @@ class GnssPoser

void set_projector_info(const autoware_map_msgs::msg::MapProjectorInfo & projector_info);

/// \brief Latch the INS orientation used while use_gnss_ins_orientation is true. Until the first
/// call, an identity orientation with an rmse of 1.0 rad per axis stands in for it.
/// \brief Latch the INS orientation, used with OrientationSource::Ins and InsOrNone.
void set_ins_orientation(const autoware_sensing_msgs::msg::GnssInsOrientation & orientation);

/// \brief Process one fix: gate, project, buffer, orient, compose with the antenna transform and
Expand Down Expand Up @@ -189,6 +200,7 @@ class GnssPoser
geometry_msgs::msg::Point prev_position_;
bool has_prev_position_ = false;
autoware_sensing_msgs::msg::GnssInsOrientation ins_orientation_;
bool received_ins_orientation_ = false;
// The header stamp of the first fix, whatever its status, from which the grace period runs. Set
// once, so a rosbag replayed in a loop gets the grace period only on its first pass.
std::optional<std::chrono::nanoseconds> first_fix_stamp_;
Expand Down
Loading
Loading