simple_planner v1.4.0
Loading...
Searching...
No Matches
simple_planner Namespace Reference

Namespace for simple_planner package. More...

Classes

struct  ConflictSample
 
struct  is_vector
 
struct  is_vector< std::vector< T, A > >
 
struct  ObjectTrajectory
 
struct  OrientedBox2D
 
struct  SimplePath
 
struct  SimplePathPoint
 
class  SimplePlannerNode
 
struct  TimedBox2D
 
struct  TopicDiagnosticConfig
 Configuration parameters for topic diagnostics. More...
 

Functions

double wrap_angle_rad (double angle_rad)
 Wraps an angle to the range [-pi, pi].
 
Eigen::Vector2d rotate (const Eigen::Vector2d &vec, double yaw)
 Rotates a 2D vector by the given yaw angle.
 
double getStateRelativeTime (const perception_msgs::msg::ObjectState &state, const std_msgs::msg::Header &fallback_header, const rclcpp::Time &planning_stamp)
 Computes an object state's time relative to the planning stamp.
 
OrientedBox2D buildOrientedBox (const Eigen::Vector2d &center, double yaw, double length, double width)
 Builds an oriented 2D bounding box from center pose and dimensions.
 
OrientedBox2D expandBoxWithSafetyMargins (const OrientedBox2D &box, double longitudinal_safety_distance, double lateral_safety_distance)
 Expands a box by the given safety margins.
 
std::array< Eigen::Vector2d, 4 > getBoxCorners (const OrientedBox2D &box)
 Returns the corners of an oriented box.
 
geometry_msgs::msg::Pose toPose (const OrientedBox2D &box)
 Converts an oriented box center and heading to a ROS pose.
 
TimedBox2D interpolateTimedBox (const TimedBox2D &lhs, const TimedBox2D &rhs, double t)
 Interpolates a timed box sample at the requested relative time.
 
bool overlaps (const OrientedBox2D &first_box, const OrientedBox2D &second_box)
 Checks whether two oriented boxes overlap.
 
TimedBox2D buildObjectSample (const perception_msgs::msg::ObjectState &state, const std_msgs::msg::Header &fallback_header, const rclcpp::Time &stamp, double length, double width)
 Builds a timed bounding-box sample for a single object state.
 

Variables

template<typename C >
constexpr bool is_vector_v = is_vector<C>::value
 

Detailed Description

Namespace for simple_planner package.

Function Documentation

◆ buildObjectSample()

TimedBox2D simple_planner::buildObjectSample ( const perception_msgs::msg::ObjectState & state,
const std_msgs::msg::Header & fallback_header,
const rclcpp::Time & stamp,
double length,
double width )
inline

Builds a timed bounding-box sample for a single object state.

Parameters
[in]stateObject state in the vehicle frame.
[in]fallback_headerHeader used if the state has no own stamp.
[in]stampPlanning stamp used as relative time reference.
[in]lengthObject length.
[in]widthObject width.
Returns
Timed box sample for the object state.

Definition at line 224 of file object_geometry.hpp.

228 {
229 const auto center_msg = perception_msgs::object_access::getCenterPosition(state);
230 TimedBox2D sample;
231 sample.yaw = perception_msgs::object_access::getYaw(state);
232 sample.length = length;
233 sample.width = width;
234 sample.box = buildOrientedBox(Eigen::Vector2d(center_msg.x, center_msg.y), sample.yaw, length, width);
235 sample.t = getStateRelativeTime(state, fallback_header, stamp);
236 return sample;
237}
OrientedBox2D buildOrientedBox(const Eigen::Vector2d &center, double yaw, double length, double width)
Builds an oriented 2D bounding box from center pose and dimensions.
double getStateRelativeTime(const perception_msgs::msg::ObjectState &state, const std_msgs::msg::Header &fallback_header, const rclcpp::Time &planning_stamp)
Computes an object state's time relative to the planning stamp.

◆ buildOrientedBox()

OrientedBox2D simple_planner::buildOrientedBox ( const Eigen::Vector2d & center,
double yaw,
double length,
double width )
inline

Builds an oriented 2D bounding box from center pose and dimensions.

Parameters
[in]centerBox center in the target frame.
[in]yawBox heading in radians.
[in]lengthBox length.
[in]widthBox width.
Returns
Oriented bounding box.

Definition at line 110 of file object_geometry.hpp.

110 {
111 OrientedBox2D box;
112 box.center = center;
113 box.axis_x = rotate(Eigen::Vector2d::UnitX(), yaw);
114 box.axis_y = rotate(Eigen::Vector2d::UnitY(), yaw);
115 box.half_length = std::max(length, 0.0) / 2.0;
116 box.half_width = std::max(width, 0.0) / 2.0;
117 return box;
118}
Eigen::Vector2d rotate(const Eigen::Vector2d &vec, double yaw)
Rotates a 2D vector by the given yaw angle.

◆ expandBoxWithSafetyMargins()

OrientedBox2D simple_planner::expandBoxWithSafetyMargins ( const OrientedBox2D & box,
double longitudinal_safety_distance,
double lateral_safety_distance )
inline

Expands a box by the given safety margins.

Parameters
[in]boxBox to expand.
[in]longitudinal_safety_distanceLongitudinal safety margin.
[in]lateral_safety_distanceLateral safety margin.
Returns
Expanded box.

Definition at line 128 of file object_geometry.hpp.

130 {
131 OrientedBox2D expanded_box = box;
132 const double longitudinal_margin = std::max(longitudinal_safety_distance, -2.0 * box.half_length);
133 const double lateral_margin = std::max(lateral_safety_distance, -box.half_width);
134 expanded_box.center += 0.5 * longitudinal_margin * box.axis_x;
135 expanded_box.half_length += 0.5 * longitudinal_margin;
136 expanded_box.half_width += lateral_margin;
137 return expanded_box;
138}

◆ getBoxCorners()

std::array< Eigen::Vector2d, 4 > simple_planner::getBoxCorners ( const OrientedBox2D & box)
inline

Returns the corners of an oriented box.

Parameters
[in]boxBox whose corners should be returned.
Returns
Box corners.

Definition at line 146 of file object_geometry.hpp.

146 {
147 return {box.center + box.half_length * box.axis_x + box.half_width * box.axis_y,
148 box.center + box.half_length * box.axis_x - box.half_width * box.axis_y,
149 box.center - box.half_length * box.axis_x - box.half_width * box.axis_y,
150 box.center - box.half_length * box.axis_x + box.half_width * box.axis_y};
151}

◆ getStateRelativeTime()

double simple_planner::getStateRelativeTime ( const perception_msgs::msg::ObjectState & state,
const std_msgs::msg::Header & fallback_header,
const rclcpp::Time & planning_stamp )
inline

Computes an object state's time relative to the planning stamp.

Parameters
[in]stateObject state whose stamp should be used if available.
[in]fallback_headerHeader used when the state has no own stamp.
[in]planning_stampReference time of the planning cycle.
Returns
Relative time in seconds.

Definition at line 93 of file object_geometry.hpp.

95 {
96 const bool has_state_stamp = state.header.stamp.sec != 0 || state.header.stamp.nanosec != 0;
97 const auto& source_header = has_state_stamp ? state.header : fallback_header;
98 return (rclcpp::Time(source_header.stamp) - planning_stamp).seconds();
99}

◆ interpolateTimedBox()

TimedBox2D simple_planner::interpolateTimedBox ( const TimedBox2D & lhs,
const TimedBox2D & rhs,
double t )
inline

Interpolates a timed box sample at the requested relative time.

Parameters
[in]lhsEarlier or first sample.
[in]rhsLater or second sample.
[in]tRelative time to sample.
Returns
Interpolated timed box.

Definition at line 178 of file object_geometry.hpp.

178 {
179 const double duration = rhs.t - lhs.t;
180 const double alpha = std::abs(duration) > 1e-6 ? std::clamp((t - lhs.t) / duration, 0.0, 1.0) : 0.0;
181 TimedBox2D sample;
182 sample.t = t;
183 sample.yaw = wrap_angle_rad(lhs.yaw + alpha * wrap_angle_rad(rhs.yaw - lhs.yaw));
184 sample.length = lhs.length + alpha * (rhs.length - lhs.length);
185 sample.width = lhs.width + alpha * (rhs.width - lhs.width);
186 const Eigen::Vector2d center = lhs.box.center + alpha * (rhs.box.center - lhs.box.center);
187 sample.box = buildOrientedBox(center, sample.yaw, sample.length, sample.width);
188 return sample;
189}
double wrap_angle_rad(double angle_rad)
Wraps an angle to the range [-pi, pi].

◆ overlaps()

bool simple_planner::overlaps ( const OrientedBox2D & first_box,
const OrientedBox2D & second_box )
inline

Checks whether two oriented boxes overlap.

Parameters
[in]first_boxFirst bounding box.
[in]second_boxSecond bounding box.
Returns
true if the boxes overlap.
false if a separating axis exists.

Definition at line 199 of file object_geometry.hpp.

199 {
200 const Eigen::Vector2d center_delta = second_box.center - first_box.center;
201 const std::array<Eigen::Vector2d, 4> axes = {first_box.axis_x, first_box.axis_y, second_box.axis_x, second_box.axis_y};
202 for (const auto& axis : axes) {
203 const double first_extent = first_box.half_length * std::abs(axis.dot(first_box.axis_x)) +
204 first_box.half_width * std::abs(axis.dot(first_box.axis_y));
205 const double second_extent = second_box.half_length * std::abs(axis.dot(second_box.axis_x)) +
206 second_box.half_width * std::abs(axis.dot(second_box.axis_y));
207 if (std::abs(axis.dot(center_delta)) > first_extent + second_extent + 1e-6) {
208 return false;
209 }
210 }
211 return true;
212}

◆ rotate()

Eigen::Vector2d simple_planner::rotate ( const Eigen::Vector2d & vec,
double yaw )
inline

Rotates a 2D vector by the given yaw angle.

Parameters
[in]vecVector to rotate.
[in]yawRotation angle in radians.
Returns
Rotated vector.

Definition at line 79 of file object_geometry.hpp.

79 {
80 const double c = std::cos(yaw);
81 const double s = std::sin(yaw);
82 return Eigen::Vector2d(c * vec.x() - s * vec.y(), s * vec.x() + c * vec.y());
83}

◆ toPose()

geometry_msgs::msg::Pose simple_planner::toPose ( const OrientedBox2D & box)
inline

Converts an oriented box center and heading to a ROS pose.

Parameters
[in]boxBox to convert.
Returns
Pose at the box center with the box heading.

Definition at line 159 of file object_geometry.hpp.

159 {
160 geometry_msgs::msg::Pose pose;
161 pose.position.x = box.center.x();
162 pose.position.y = box.center.y();
163 pose.position.z = 0.0;
164 const double yaw = std::atan2(box.axis_x.y(), box.axis_x.x());
165 pose.orientation.z = std::sin(yaw / 2.0);
166 pose.orientation.w = std::cos(yaw / 2.0);
167 return pose;
168}

◆ wrap_angle_rad()

double simple_planner::wrap_angle_rad ( double angle_rad)
inline

Wraps an angle to the range [-pi, pi].

Parameters
[in]angle_radAngle in radians.
Returns
Wrapped angle in radians.

Definition at line 65 of file object_geometry.hpp.

65 {
66 double capped_angle_rad = angle_rad;
67 while (capped_angle_rad > M_PI) capped_angle_rad -= 2 * M_PI;
68 while (capped_angle_rad < -M_PI) capped_angle_rad += 2 * M_PI;
69 return capped_angle_rad;
70}

Variable Documentation

◆ is_vector_v

template<typename C >
bool simple_planner::is_vector_v = is_vector<C>::value
inlineconstexpr

Definition at line 49 of file simple_planner.hpp.