Class OscillationCritic

Nested Relationships

Nested Types

Inheritance Relationships

Base Type

  • public dwb_core::TrajectoryCritic

Class Documentation

class OscillationCritic : public dwb_core::TrajectoryCritic

Checks to see whether the sign of the commanded velocity flips frequently.

This critic figures out if the commanded trajectories are oscillating by seeing if one of the dimensions (x,y,theta) flips from positive to negative and then back (or vice versa) without moving sufficiently far or waiting sufficiently long.

Scenario 1: Robot moves one meter forward, and then two millimeters backward. Another forward motion would be considered oscillating, since the x dimension would then flip from positive to negative and then back to negative. Hence, when scoring different trajectories, positive velocity commands will get the oscillation_score (-5.0, or invalid) and only negative velocity commands will be considered valid.

Scenario 2: Robot moves one meter forward, and then one meter backward. The robot has thus moved one meter since flipping the sign of the x direction, which is greater than our oscillation_reset_dist, so its not considered oscillating, so all trajectories are considered valid.

Note: The critic will only check oscillations in the x dimension while it exceeds a particular value (x_only_threshold_). If it dips below that magnitude, it will also check for oscillations in the y and theta dimensions. If x_only_threshold_ is negative, then the critic will always check all dimensions.

Implementation Details: The critic saves the robot’s current position when it prepares, and what the actual commanded velocity was during the debrief step. Upon debriefing, if the sign of any of dimensions has flipped since the last command, the position is saved as prev_stationary_pose_.

If the linear or angular distance from prev_stationary_pose_ to the current pose exceeds the limits, the oscillation flags are reset so the previous sign change is no longer remembered. This assumes that oscillation_reset_dist_ or oscillation_reset_angle_ are positive. Otherwise, it uses a time based delay reset function.

Public Functions

inline OscillationCritic()
void onInit() override
virtual bool prepare(const geometry_msgs::msg::Pose2D &pose, const nav_2d_msgs::msg::Twist2D &vel, const geometry_msgs::msg::Pose2D &goal, const nav_2d_msgs::msg::Path2D &global_plan) override
virtual double scoreTrajectory(const dwb_msgs::msg::Trajectory2D &traj) override
virtual void reset() override
virtual void debrief(const nav_2d_msgs::msg::Twist2D &cmd_vel) override