Carma-platform v4.2.0
CARMA Platform is built on robot operating system (ROS) and utilizes open source software (OSS) that enables Cooperative Driving Automation (CDA) features to allow Automated Driving Systems to interact and cooperate with infrastructure and other vehicles through communication.
|
geometry namespace contains utility geometry functions which do not require the map or route provided by an active world model More...
Functions | |
TrackPos | trackPos (const lanelet::ConstLanelet &lanelet, const lanelet::BasicPoint2d &point) |
Returns the TrackPos, computed in 2d, of the provided point relative to the centerline of the provided lanelet. Positive crosstrack will be to the right. Points occuring before the segment will have negative downtrack. See the matchSegment function for a description of the edge cases associated with the max_crosstrack parameter. More... | |
TrackPos | trackPos (const lanelet::BasicPoint2d &p, const lanelet::BasicPoint2d &seg_start, const lanelet::BasicPoint2d &seg_end) |
Return the track position of a point relative to a line segment defined by two other points. Positive crosstrack will be to the right. Points occuring before the segment will have negative downtrack. More... | |
std::tuple< TrackPos, lanelet::BasicSegment2d > | matchSegment (const lanelet::BasicPoint2d &p, const lanelet::BasicLineString2d &line_string) |
Get the TrackPos of the provided point along the linestring and the segment of the line string which the provided point should be considered in. More... | |
std::vector< double > | local_curvatures (const lanelet::BasicLineString2d ¢erline_points) |
Returns a list of local (computed by discrete derivative) curvatures for the input centerlines. The list of returned curvatures matches 1-to-1 with with list of points in the input centerlines. More... | |
std::vector< double > | local_curvatures (const std::vector< lanelet::BasicPoint2d > ¢erline_points) |
std::vector< double > | local_curvatures (const std::vector< lanelet::ConstLanelet > &lanelets) |
Specialized overload of the centerline local_curvatures method but for lanelets. More... | |
lanelet::BasicLineString2d | concatenate_line_strings (const lanelet::BasicLineString2d &l1, const lanelet::BasicLineString2d &l2) |
Helper function to concatenate 2 linestrings together and return the result. Neither LineString is modified in this function. More... | |
lanelet::BasicLineString2d | concatenate_lanelets (const std::vector< lanelet::ConstLanelet > &lanelets) |
Helper function to a list of lanelets together and return the result. Neither LineString is modified in this function. More... | |
std::vector< Eigen::Vector2d > | compute_finite_differences (const lanelet::BasicLineString2d &data) |
Use finite differences methods to compute the derivative of the input data set with respect to index Compute the finite differences using the forward finite difference for the first point, centered finite differences for the middle points and backwards finite difference for the final point. This will result in the middle points being a better approximation of the actual derivative than the endpoints. More... | |
std::vector< Eigen::Vector2d > | compute_finite_differences (const std::vector< lanelet::BasicPoint2d > &data) |
std::vector< double > | compute_finite_differences (const std::vector< double > &data) |
Use finite differences methods to compute the derivative of the input data set with respect to index Compute the finite differences using the forward finite difference for the first point, centered finite differences for the middle points and backwards finite difference for the final point. This will result in the middle points being a better approximation of the actual derivative than the endpoints. More... | |
std::vector< Eigen::Vector2d > | compute_finite_differences (const std::vector< Eigen::Vector2d > &x, const std::vector< double > &y) |
Use finite differences methods to compute the derivative of the input data set with respect to the second paramter. More... | |
std::vector< double > | compute_arc_lengths (const std::vector< lanelet::BasicPoint2d > &data) |
Compute the arc length at each point around the curve. More... | |
std::vector< double > | compute_arc_lengths (const lanelet::BasicLineString2d &data) |
Compute the arc length at each point around the curve. More... | |
double | compute_euclidean_distance (const Eigen::Vector2d &a, const Eigen::Vector2d &b) |
Compute the Euclidean distance between the two points. More... | |
std::vector< Eigen::Vector2d > | normalize_vectors (const std::vector< Eigen::Vector2d > &vectors) |
Normalize the vectors in the input list such that their magnitudes = 1. More... | |
std::vector< double > | compute_magnitude_of_vectors (const std::vector< Eigen::Vector2d > &vectors) |
Compute the magnitude of each vector in the input list. More... | |
double | computeCurvature (const lanelet::BasicPoint2d &p1, const lanelet::BasicPoint2d &p2, const lanelet::BasicPoint2d &p3) |
Function for computing curvature from 3 points. More... | |
double | safeAcos (double x) |
acos method that caps the input x value for 1 or -1 to avoid undefined output. This is meant to prevent issues with floating point approximations. The user should still make sure the input data is expected to be within the [-1, 1] range for this method to give accurate results. More... | |
double | safeAsin (double x) |
asin method that caps the input x value for 1 or -1 to avoid undefined output. This is meant to prevent issues with floating point approximations. The user should still make sure the input data is expected to be within the [-1, 1] range for this method to give accurate results. More... | |
double | getAngleBetweenVectors (const Eigen::Vector2d &vec1, const Eigen::Vector2d &vec2) |
Calculates the angle between two vectors. More... | |
lanelet::BasicPolygon2d | objectToMapPolygon (const geometry_msgs::msg::Pose &pose, const geometry_msgs::msg::Vector3 &size) |
Uses the provided pose and size vector of an ExternalObject to compute what the polygon would be of that object would be if viewed from the same frame as the pose is defined relative to. More... | |
void | rpyFromQuaternion (const tf2::Quaternion &q, double &roll, double &pitch, double &yaw) |
Extract extrinsic roll-pitch-yaw from quaternion. More... | |
void | rpyFromQuaternion (const geometry_msgs::msg::Quaternion &q_msg, double &roll, double &pitch, double &yaw) |
Extract extrinsic roll-pitch-yaw from quaternion. More... | |
std::vector< double > | compute_tangent_orientations (const lanelet::BasicLineString2d ¢erline) |
Compute an approximate orientation for the vehicle at each point along the provided centerline. More... | |
std::vector< double > | compute_tangent_orientations (const std::vector< lanelet::BasicPoint2d > ¢erline) |
Eigen::Isometry2d | build2dEigenTransform (const Eigen::Vector2d &position, const Eigen::Rotation2Dd &rotation) |
Builds a 2D Eigen coordinate frame transform with not applied scaling (only translation and rotation) based on the provided position and rotation parameters. More... | |
Eigen::Isometry3d | build3dEigenTransform (const Eigen::Vector3d &position, const Eigen::Quaterniond &rotation) |
Builds a 3D Eigen coordinate frame transform with not applied scaling (only translation and rotation) based on the provided position and rotation parameters. More... | |
Eigen::Isometry3d | build3dEigenTransform (const Eigen::Vector3d &position, const Eigen::AngleAxisd &rotation) |
double | point_to_point_yaw (const lanelet::BasicPoint2d &cur_point, const lanelet::BasicPoint2d &next_point) |
Computes the 2d orientation of the vector from the provided start point to end point. More... | |
double | circular_arc_curvature (const lanelet::BasicPoint2d &cur_point, const lanelet::BasicPoint2d &next_point) |
Computes the curvature of a circular arc that passes through the two provided points. If the two points lie on a curve then larger distances between them will result in less accurate, but also less noisy curvature calculations. More... | |
std::vector< double > | local_circular_arc_curvatures (const std::vector< lanelet::BasicPoint2d > &points, int lookahead) |
Computes the curvature of each point in the provided list by calling circular_arc_curvature using that point and the point at index current point index + lookahead. In this way the curvature of a path is effectively low pass filtered by the size of the lookahead value. More... | |
bool | selectFirstSegment (const TrackPos &first_seg_trackPos, const TrackPos &second_seg_trackPos, double first_seg_length, double second_seg_length) |
Helper function to identify whether to select the preceeding or succeeding segment of a linstring point that is nearest an external point when trying to find the TrackPos of the external point. Of the 3 points comprising the 2 segment linestirng the external point must be closest to the midpoint for this function to be valid. More... | |
template<class P , class A > | |
std::vector< double > | templated_local_curvatures (const std::vector< P, A > ¢erline_points) |
template<class P , class A > | |
std::vector< Eigen::Vector2d > | compute_templated_finite_differences (const std::vector< P, A > &data) |
template<class P , class A > | |
std::vector< double > | compute_templated_arc_lengths (const std::vector< P, A > &data) |
template<class P , class A > | |
std::vector< double > | compute_templated_tangent_orientations (const std::vector< P, A > ¢erline) |
Variables | |
constexpr double | SPATIAL_EPSILON_M = 0.05 |
geometry namespace contains utility geometry functions which do not require the map or route provided by an active world model
Eigen::Isometry2d carma_wm::geometry::build2dEigenTransform | ( | const Eigen::Vector2d & | position, |
const Eigen::Rotation2Dd & | rotation | ||
) |
Builds a 2D Eigen coordinate frame transform with not applied scaling (only translation and rotation) based on the provided position and rotation parameters.
position | The origin of the child coordinate frame in the parent frame |
rotation | The rotation of the child coordinate frame in the parent frame |
Definition at line 570 of file Geometry.cpp.
Referenced by basic_autonomy::waypoint_generation::compute_heading_frame().
Eigen::Isometry3d carma_wm::geometry::build3dEigenTransform | ( | const Eigen::Vector3d & | position, |
const Eigen::AngleAxisd & | rotation | ||
) |
Definition at line 582 of file Geometry.cpp.
Eigen::Isometry3d carma_wm::geometry::build3dEigenTransform | ( | const Eigen::Vector3d & | position, |
const Eigen::Quaterniond & | rotation | ||
) |
Builds a 3D Eigen coordinate frame transform with not applied scaling (only translation and rotation) based on the provided position and rotation parameters.
position | The origin of the child coordinate frame in the parent frame |
rotation | The rotation of the child coordinate frame in the parent frame |
Definition at line 576 of file Geometry.cpp.
double carma_wm::geometry::circular_arc_curvature | ( | const lanelet::BasicPoint2d & | cur_point, |
const lanelet::BasicPoint2d & | next_point | ||
) |
Computes the curvature of a circular arc that passes through the two provided points. If the two points lie on a curve then larger distances between them will result in less accurate, but also less noisy curvature calculations.
cur_point | The first point |
next_point | The second point |
Definition at line 596 of file Geometry.cpp.
References point_to_point_yaw().
Referenced by local_circular_arc_curvatures().
std::vector< double > carma_wm::geometry::compute_arc_lengths | ( | const lanelet::BasicLineString2d & | data | ) |
Compute the arc length at each point around the curve.
Definition at line 493 of file Geometry.cpp.
References compute_templated_arc_lengths(), and process_traj_logs::data.
std::vector< double > carma_wm::geometry::compute_arc_lengths | ( | const std::vector< lanelet::BasicPoint2d > & | data | ) |
Compute the arc length at each point around the curve.
Definition at line 498 of file Geometry.cpp.
References compute_templated_arc_lengths(), and process_traj_logs::data.
Referenced by basic_autonomy::waypoint_generation::compose_lanechange_trajectory_from_path(), basic_autonomy::waypoint_generation::compose_lanefollow_trajectory_from_path(), stop_controlled_intersection_tactical_plugin::StopControlledIntersectionTacticalPlugin::compose_trajectory_from_centerline(), basic_autonomy::waypoint_generation::constrain_to_time_boundary(), basic_autonomy::waypoint_generation::resample_linestring_pair_to_same_size(), and templated_local_curvatures().
double carma_wm::geometry::compute_euclidean_distance | ( | const Eigen::Vector2d & | a, |
const Eigen::Vector2d & | b | ||
) |
Compute the Euclidean distance between the two points.
Definition at line 504 of file Geometry.cpp.
Referenced by compute_templated_arc_lengths(), and concatenate_line_strings().
std::vector< Eigen::Vector2d > carma_wm::geometry::compute_finite_differences | ( | const lanelet::BasicLineString2d & | data | ) |
Use finite differences methods to compute the derivative of the input data set with respect to index Compute the finite differences using the forward finite difference for the first point, centered finite differences for the middle points and backwards finite difference for the final point. This will result in the middle points being a better approximation of the actual derivative than the endpoints.
data | The data to differentiate over |
Definition at line 419 of file Geometry.cpp.
References compute_templated_finite_differences(), and process_traj_logs::data.
Referenced by templated_local_curvatures().
std::vector< double > carma_wm::geometry::compute_finite_differences | ( | const std::vector< double > & | data | ) |
Use finite differences methods to compute the derivative of the input data set with respect to index Compute the finite differences using the forward finite difference for the first point, centered finite differences for the middle points and backwards finite difference for the final point. This will result in the middle points being a better approximation of the actual derivative than the endpoints.
data | The data to differentiate over |
Definition at line 429 of file Geometry.cpp.
References process_traj_logs::data, and process_bag::i.
std::vector< Eigen::Vector2d > carma_wm::geometry::compute_finite_differences | ( | const std::vector< Eigen::Vector2d > & | x, |
const std::vector< double > & | y | ||
) |
Use finite differences methods to compute the derivative of the input data set with respect to the second paramter.
Input x and y must be the same length. Compute the finite differences using the forward finite difference for the first point, centered finite differences for the middle points and backwards finite difference for the final point. This will result in the middle points being a better approximation of the actual derivative than the endpoints.
x | The x value of the derivative dx/dy |
y | The y value of the derivative dx/dy |
Definition at line 450 of file Geometry.cpp.
References process_bag::i, process_traj_logs::x, and process_traj_logs::y.
std::vector< Eigen::Vector2d > carma_wm::geometry::compute_finite_differences | ( | const std::vector< lanelet::BasicPoint2d > & | data | ) |
Definition at line 424 of file Geometry.cpp.
References compute_templated_finite_differences(), and process_traj_logs::data.
std::vector< double > carma_wm::geometry::compute_magnitude_of_vectors | ( | const std::vector< Eigen::Vector2d > & | vectors | ) |
Compute the magnitude of each vector in the input list.
Definition at line 520 of file Geometry.cpp.
Referenced by templated_local_curvatures().
std::vector< double > carma_wm::geometry::compute_tangent_orientations | ( | const lanelet::BasicLineString2d & | centerline | ) |
Compute an approximate orientation for the vehicle at each point along the provided centerline.
!
Uses the tangent vectors along the centerline to estimate vehicle pose in the yaw dimension. Roll and pitch are not considered.
centerline | centerline represented as BasicLinestring2d to compute the orientation |
Definition at line 559 of file Geometry.cpp.
References compute_templated_tangent_orientations().
Referenced by basic_autonomy::waypoint_generation::compose_lanechange_trajectory_from_path(), basic_autonomy::waypoint_generation::compose_lanefollow_trajectory_from_path(), stop_controlled_intersection_tactical_plugin::StopControlledIntersectionTacticalPlugin::compose_trajectory_from_centerline(), and stop_and_wait_plugin::StopandWait::compose_trajectory_from_centerline().
std::vector< double > carma_wm::geometry::compute_tangent_orientations | ( | const std::vector< lanelet::BasicPoint2d > & | centerline | ) |
Definition at line 565 of file Geometry.cpp.
References compute_templated_tangent_orientations().
std::vector< double > carma_wm::geometry::compute_templated_arc_lengths | ( | const std::vector< P, A > & | data | ) |
Definition at line 475 of file Geometry.cpp.
References compute_euclidean_distance(), process_traj_logs::data, and process_bag::i.
Referenced by compute_arc_lengths().
std::vector< Eigen::Vector2d > carma_wm::geometry::compute_templated_finite_differences | ( | const std::vector< P, A > & | data | ) |
Definition at line 391 of file Geometry.cpp.
References process_traj_logs::data, and process_bag::i.
Referenced by compute_finite_differences(), and compute_templated_tangent_orientations().
std::vector< double > carma_wm::geometry::compute_templated_tangent_orientations | ( | const std::vector< P, A > & | centerline | ) |
Definition at line 532 of file Geometry.cpp.
References compute_templated_finite_differences().
Referenced by compute_tangent_orientations().
double carma_wm::geometry::computeCurvature | ( | const lanelet::BasicPoint2d & | p1, |
const lanelet::BasicPoint2d & | p2, | ||
const lanelet::BasicPoint2d & | p3 | ||
) |
Function for computing curvature from 3 points.
This function is a direct copy of the function by the same name found in the lanelet2_validation package which was not exposed for use The original function can be found here https://github.com/fzi-forschungszentrum-informatik/Lanelet2/blob/master/lanelet2_validation/src/validators/CurvatureTooBig.cpp The source function is copyrighted under BSD 3-Clause "New" or "Revised" License a copy of that notice has been included with this package
p1 | The first point |
p2 | The second point |
p3 | The third point |
Definition at line 276 of file Geometry.cpp.
lanelet::BasicLineString2d carma_wm::geometry::concatenate_lanelets | ( | const std::vector< lanelet::ConstLanelet > & | lanelets | ) |
Helper function to a list of lanelets together and return the result. Neither LineString is modified in this function.
Definition at line 316 of file Geometry.cpp.
References concatenate_line_strings(), and process_bag::i.
Referenced by local_curvatures().
lanelet::BasicLineString2d carma_wm::geometry::concatenate_line_strings | ( | const lanelet::BasicLineString2d & | l1, |
const lanelet::BasicLineString2d & | l2 | ||
) |
Helper function to concatenate 2 linestrings together and return the result. Neither LineString is modified in this function.
Definition at line 373 of file Geometry.cpp.
References compute_euclidean_distance(), and SPATIAL_EPSILON_M.
Referenced by concatenate_lanelets(), and basic_autonomy::waypoint_generation::create_lanefollow_geometry().
double carma_wm::geometry::getAngleBetweenVectors | ( | const Eigen::Vector2d & | vec1, |
const Eigen::Vector2d & | vec2 | ||
) |
Calculates the angle between two vectors.
vec1 | the first vector |
vec2 | the second vector |
Definition at line 65 of file Geometry.cpp.
References safeAcos().
Referenced by carma_wm::query::getAffectedLaneletOrAreas(), and trackPos().
std::vector< double > carma_wm::geometry::local_circular_arc_curvatures | ( | const std::vector< lanelet::BasicPoint2d > & | points, |
int | lookahead | ||
) |
Computes the curvature of each point in the provided list by calling circular_arc_curvature using that point and the point at index current point index + lookahead. In this way the curvature of a path is effectively low pass filtered by the size of the lookahead value.
points | The points to compute the curvature for |
lookahead | The lookahead index distance to use for computing the curvature at each point |
Definition at line 610 of file Geometry.cpp.
References circular_arc_curvature(), and process_bag::i.
std::vector< double > carma_wm::geometry::local_curvatures | ( | const lanelet::BasicLineString2d & | centerline_points | ) |
Returns a list of local (computed by discrete derivative) curvatures for the input centerlines. The list of returned curvatures matches 1-to-1 with with list of points in the input centerlines.
The numerical accuracy of this method is greatly increased by using larger collections of points as inputs as the first 2 and final 2 points in the list must be computed using alternative differentiation methods from all the others resulting in greater error. It is also important for this function to yield useful results that all points in the input lanelet's centerline are actually on the centerline of the lanelet (i.e. none to minimal linear interpolation of points) as this results in "flat" spots on an otherwise smooth curve that causes 0 curvature to be computed.
NOTE: The accuracy of this method is very susceptable to input noise. Consider using local_circular_arc_curvatures for calculations using noisy data
centerline_points | The list of points to compute curvatures for |
std::invalid_argument | If one of the provided lanelets cannot have its centerline computed |
Definition at line 356 of file Geometry.cpp.
References templated_local_curvatures().
Referenced by local_curvatures().
std::vector< double > carma_wm::geometry::local_curvatures | ( | const std::vector< lanelet::BasicPoint2d > & | centerline_points | ) |
Definition at line 362 of file Geometry.cpp.
References templated_local_curvatures().
std::vector< double > carma_wm::geometry::local_curvatures | ( | const std::vector< lanelet::ConstLanelet > & | lanelets | ) |
Specialized overload of the centerline local_curvatures method but for lanelets.
lanelets | The list of points to compute curvatures for |
std::invalid_argument | If one of the provided lanelets cannot have its centerline computed |
Definition at line 368 of file Geometry.cpp.
References concatenate_lanelets(), and local_curvatures().
std::tuple< TrackPos, lanelet::BasicSegment2d > carma_wm::geometry::matchSegment | ( | const lanelet::BasicPoint2d & | p, |
const lanelet::BasicLineString2d & | line_string | ||
) |
Get the TrackPos of the provided point along the linestring and the segment of the line string which the provided point should be considered in.
This function iterates over the provided linestring from front to back. First the nearest vertex point on the linestring to the external point is found Once the nearest point has been found next step is to determine which segment it should go with using the following rules. If the minimum point is the first point then use the first segment If the minimum point is the last point then use the last segment If the minimum point is within the downtrack bounds of one segment but not the other then use the one it is within If the minimum point is within the downtrack bounds of both segments then use the one with the smallest crosstrack distance If the minimum point is within the downtrack bounds of both segments and has exactly equal crosstrack bounds with each segment then use the first one
point | The 2d point to match with a segment |
line_string | The line_string to match against |
std::invalid_argument | if line string contains only one point |
Definition at line 187 of file Geometry.cpp.
References carma_wm::TrackPos::downtrack, process_bag::i, selectFirstSegment(), and trackPos().
Referenced by carma_wm::CARMAWorldModel::routeTrackPos(), and trackPos().
std::vector< Eigen::Vector2d > carma_wm::geometry::normalize_vectors | ( | const std::vector< Eigen::Vector2d > & | vectors | ) |
Normalize the vectors in the input list such that their magnitudes = 1.
Definition at line 510 of file Geometry.cpp.
Referenced by templated_local_curvatures().
lanelet::BasicPolygon2d carma_wm::geometry::objectToMapPolygon | ( | const geometry_msgs::msg::Pose & | pose, |
const geometry_msgs::msg::Vector3 & | size | ||
) |
Uses the provided pose and size vector of an ExternalObject to compute what the polygon would be of that object would be if viewed from the same frame as the pose is defined relative to.
pose | the pose of an external object |
size | The size vector of an external object |
Definition at line 289 of file Geometry.cpp.
Referenced by carma_wm::CARMAWorldModel::distToNearestObjInLane(), carma_wm::CARMAWorldModel::getInLaneObjects(), carma_wm::CARMAWorldModel::getIntersectingLanelet(), and carma_wm::CARMAWorldModel::toRoadwayObstacle().
double carma_wm::geometry::point_to_point_yaw | ( | const lanelet::BasicPoint2d & | cur_point, |
const lanelet::BasicPoint2d & | next_point | ||
) |
Computes the 2d orientation of the vector from the provided start point to end point.
cur_point | The start point of the orientation vector. Units m |
next_point | The end point of the orientation vector. Units m |
Definition at line 588 of file Geometry.cpp.
Referenced by circular_arc_curvature(), and carma_wm::CARMAWorldModel::pointFromRouteTrackPos().
void carma_wm::geometry::rpyFromQuaternion | ( | const geometry_msgs::msg::Quaternion & | q_msg, |
double & | roll, | ||
double & | pitch, | ||
double & | yaw | ||
) |
Extract extrinsic roll-pitch-yaw from quaternion.
q | The quaternion message to convert |
roll | The output variable for roll units will be radians |
pitch | The output variable for pitch units will be radians |
yaw | The output variable for yaw units will be radians |
Definition at line 58 of file Geometry.cpp.
References motion_computation::conversion::convert(), and rpyFromQuaternion().
void carma_wm::geometry::rpyFromQuaternion | ( | const tf2::Quaternion & | q, |
double & | roll, | ||
double & | pitch, | ||
double & | yaw | ||
) |
Extract extrinsic roll-pitch-yaw from quaternion.
q | The quaternion to convert |
roll | The output variable for roll units will be radians |
pitch | The output variable for pitch units will be radians |
yaw | The output variable for yaw units will be radians |
Definition at line 52 of file Geometry.cpp.
Referenced by plan_delegator::PlanDelegator::composePlanTrajectoryRequest(), and rpyFromQuaternion().
double carma_wm::geometry::safeAcos | ( | double | x | ) |
acos method that caps the input x value for 1 or -1 to avoid undefined output. This is meant to prevent issues with floating point approximations. The user should still make sure the input data is expected to be within the [-1, 1] range for this method to give accurate results.
x | The angle in radians |
Definition at line 34 of file Geometry.cpp.
References process_traj_logs::x.
Referenced by getAngleBetweenVectors().
double carma_wm::geometry::safeAsin | ( | double | x | ) |
asin method that caps the input x value for 1 or -1 to avoid undefined output. This is meant to prevent issues with floating point approximations. The user should still make sure the input data is expected to be within the [-1, 1] range for this method to give accurate results.
x | The angle in radians |
Definition at line 45 of file Geometry.cpp.
References process_traj_logs::x.
bool carma_wm::geometry::selectFirstSegment | ( | const TrackPos & | first_seg_trackPos, |
const TrackPos & | second_seg_trackPos, | ||
double | first_seg_length, | ||
double | second_seg_length | ||
) |
Helper function to identify whether to select the preceeding or succeeding segment of a linstring point that is nearest an external point when trying to find the TrackPos of the external point. Of the 3 points comprising the 2 segment linestirng the external point must be closest to the midpoint for this function to be valid.
ASSUMPTION: Of the 3 points comprising the 2 segment linestirng the external point is closest to the midpoint
Meant to be called in the matchSegment method. Logic is as follows If the external point is within the downtrack bounds of one segment but not the other then use the one it is within If the external point is within the downtrack bounds of both segments then use the one with the smallest crosstrack distance If the external point is within the downtrack bounds of both segments and has exactly equal crosstrack bounds with each segment then use the preceeding segment If the external point is outside the downtrack bounds of both segments then assign to the first segment as it will always have positive downtrack in this case while the second segment will always have negative downtrack
first_seg_trackPos | The TrackPos of the external point relative to the preceeding segment |
second_seg_trackPos | The TrackPos of the succeeding segment |
first_seg_length | The length of the preceeding segment |
second_seg_length | The length of the succeeding segment |
Definition at line 156 of file Geometry.cpp.
References carma_wm::TrackPos::crosstrack, and carma_wm::TrackPos::downtrack.
Referenced by matchSegment().
std::vector< double > carma_wm::geometry::templated_local_curvatures | ( | const std::vector< P, A > & | centerline_points | ) |
Definition at line 333 of file Geometry.cpp.
References compute_arc_lengths(), compute_finite_differences(), compute_magnitude_of_vectors(), and normalize_vectors().
Referenced by local_curvatures().
TrackPos carma_wm::geometry::trackPos | ( | const lanelet::BasicPoint2d & | p, |
const lanelet::BasicPoint2d & | seg_start, | ||
const lanelet::BasicPoint2d & | seg_end | ||
) |
Return the track position of a point relative to a line segment defined by two other points. Positive crosstrack will be to the right. Points occuring before the segment will have negative downtrack.
p | The point to find the TrackPos of |
seg_start | The starting point of a line segment |
seg_end | The ending point of a line segment |
Calculate the sign of the crosstrack distance by projecting the points to 2d d = (p_x - s_x)(e_y - s_y) - (p_y - s_y)(e_x - s_x) Equivalent to d = (start_to_p.x * start_to_end.y) - (start_to_p.y * start_to_end.x)
Code below based on math equation described at https://math.stackexchange.com/questions/274712/calculate-on-which-side-of-a-straight-line-is-a-given-point-located Question asked by user Ritvars (https://math.stackexchange.com/users/56723/ritvars) and answered by user Shard (https://math.stackexchange.com/users/55608/shard) Attribution here is in line with Stack Overflow's Attribution policy cc-by-sa found here: https://stackoverflow.blog/2009/06/25/attribution-required/
Calculate the sign of the crosstrack distance by projecting the points to 2d d = (p_x - s_x)(e_y - s_y) - (p_y - s_y)(e_x - s_x) Equivalent to d = (start_to_p.x * start_to_end.y) - (start_to_p.y * start_to_end.x)
Code below based on math equation described at https://math.stackexchange.com/questions/274712/calculate-on-which-side-of-a-straight-line-is-a-given-point-located Question asked by user Ritvars (https://math.stackexchange.com/users/56723/ritvars) and answered by user Shard (https://math.stackexchange.com/users/55608/shard) Attribution here is in line with Stack Overflow's Attribution policy cc-by-sa found here: https://stackoverflow.blog/2009/06/25/attribution-required/
Definition at line 76 of file Geometry.cpp.
References getAngleBetweenVectors().
TrackPos carma_wm::geometry::trackPos | ( | const lanelet::ConstLanelet & | lanelet, |
const lanelet::BasicPoint2d & | point | ||
) |
Returns the TrackPos, computed in 2d, of the provided point relative to the centerline of the provided lanelet. Positive crosstrack will be to the right. Points occuring before the segment will have negative downtrack. See the matchSegment function for a description of the edge cases associated with the max_crosstrack parameter.
lanelet | The lanelet whose centerline will serve as the TrackPos reference line |
point | The lanelet2 point which will have its distance computed |
max_crosstrack | The maximum crosstrack distance allowed for a perfect centerline segment match. See the matchSegment function for details |
std::invalid_argument | If the lanelet centerline cannot be found |
Definition at line 120 of file Geometry.cpp.
References matchSegment(), and process_traj_logs::point.
Referenced by route::RouteGeneratorWorker::bumperPoseCb(), route::RouteGeneratorWorker::composeRouteMarkerMsg(), carma_wm_ctrl::WMBroadcaster::distToNearestActiveGeofence(), carma_wm::query::getAffectedLaneletOrAreas(), carma_wm::CARMAWorldModel::getNearestObjInLane(), matchSegment(), carma_wm::query::nonConnectedAdjacentLeft(), carma_wm::CARMAWorldModel::routeTrackPos(), carma_wm_ctrl::WMBroadcaster::splitLaneletWithPoint(), carma_wm_ctrl::WMBroadcaster::splitOppositeLaneletWithPoint(), and carma_wm::CARMAWorldModel::toRoadwayObstacle().
|
constexpr |
Definition at line 28 of file Geometry.cpp.
Referenced by concatenate_line_strings().