20#include <carma_planning_msgs/msg/plugin.hpp>
21#include <carma_ros2_utils/carma_lifecycle_node.hpp>
22#include <geometry_msgs/msg/pose_stamped.hpp>
23#include <geometry_msgs/msg/twist_stamped.hpp>
26#include <carma_planning_msgs/srv/plan_maneuvers.hpp>
27#include <carma_planning_msgs/msg/trajectory_plan.hpp>
28#include <gtest/gtest_prod.h>
29#include <tf2_ros/transform_listener.h>
30#include <tf2/LinearMath/Transform.h>
31#include <tf2_geometry_msgs/tf2_geometry_msgs.h>
32#include <unordered_set>
42#define GET_MANEUVER_PROPERTY(mvr, property)\
43 (((mvr).type == carma_planning_msgs::msg::Maneuver::INTERSECTION_TRANSIT_LEFT_TURN ? (mvr).intersection_transit_left_turn_maneuver.property :\
44 ((mvr).type == carma_planning_msgs::msg::Maneuver::INTERSECTION_TRANSIT_RIGHT_TURN ? (mvr).intersection_transit_right_turn_maneuver.property :\
45 ((mvr).type == carma_planning_msgs::msg::Maneuver::INTERSECTION_TRANSIT_STRAIGHT ? (mvr).intersection_transit_straight_maneuver.property :\
46 ((mvr).type == carma_planning_msgs::msg::Maneuver::LANE_CHANGE ? (mvr).lane_change_maneuver.property :\
47 ((mvr).type == carma_planning_msgs::msg::Maneuver::LANE_FOLLOWING ? (mvr).lane_following_maneuver.property :\
48 ((mvr).type == carma_planning_msgs::msg::Maneuver::STOP_AND_WAIT ? (mvr).stop_and_wait_maneuver.property :\
49 throw std::invalid_argument("GET_MANEUVER_PROPERTY (property) called on maneuver with invalid type id " + std::to_string((mvr).type)))))))))
51#define SET_MANEUVER_PROPERTY(mvr, property, value)\
52 (((mvr).type == carma_planning_msgs::msg::Maneuver::INTERSECTION_TRANSIT_LEFT_TURN ? (mvr).intersection_transit_left_turn_maneuver.property = (value) :\
53 ((mvr).type == carma_planning_msgs::msg::Maneuver::INTERSECTION_TRANSIT_RIGHT_TURN ? (mvr).intersection_transit_right_turn_maneuver.property = (value) :\
54 ((mvr).type == carma_planning_msgs::msg::Maneuver::INTERSECTION_TRANSIT_STRAIGHT ? (mvr).intersection_transit_straight_maneuver.property = (value) :\
55 ((mvr).type == carma_planning_msgs::msg::Maneuver::LANE_CHANGE ? (mvr).lane_change_maneuver.property = (value) :\
56 ((mvr).type == carma_planning_msgs::msg::Maneuver::STOP_AND_WAIT ? (mvr).stop_and_wait_maneuver.property = (value) :\
57 ((mvr).type == carma_planning_msgs::msg::Maneuver::LANE_FOLLOWING ? (mvr).lane_following_maneuver.property = (value) :\
58 throw std::invalid_argument("SET_MANEUVER_PROPERTY (property) called on maneuver with invalid type id " + std::to_string((mvr).type)))))))))
76 std::shared_ptr<carma_wm::WMListener>
wml_;
93 carma_planning_msgs::msg::Maneuver
composeLaneFollowingManeuverMessage(
double start_dist,
double end_dist,
double start_speed,
double target_speed,
const std::vector<lanelet::Id>& lane_ids)
const;
106 carma_planning_msgs::msg::Maneuver
composeLaneChangeManeuverMessage(
double start_dist,
double end_dist,
double start_speed,
double target_speed, lanelet::Id starting_lane_id,lanelet::Id ending_lane_id)
const;
119 carma_planning_msgs::msg::Maneuver
composeStopAndWaitManeuverMessage(
double start_dist,
double end_dist,
double start_speed, lanelet::Id starting_lane_id, lanelet::Id ending_lane_id,
double stopping_accel)
const;
127 bool isLaneChangeNeeded(lanelet::routing::LaneletRelations relations, lanelet::Id target_id)
const;
134 void setManeuverStartDist(carma_planning_msgs::msg::Maneuver& maneuver,
double start_dist)
const;
141 void updateTimeProgress(std::vector<carma_planning_msgs::msg::Maneuver>& maneuvers, rclcpp::Time start_time)
const;
147 void updateStartingSpeed(carma_planning_msgs::msg::Maneuver& maneuver,
double start_speed)
const;
157 std::shared_ptr<rmw_request_id_t> srv_header,
158 carma_planning_msgs::srv::PlanManeuvers::Request::SharedPtr req,
159 carma_planning_msgs::srv::PlanManeuvers::Response::SharedPtr resp);
172 std::vector<carma_planning_msgs::msg::Maneuver>
routeCb(
const lanelet::routing::LaneletPath& route_shortest_path);
196 const std::vector<carma_planning_msgs::msg::Maneuver>& input_maneuvers,
197 double route_end_downtrack,
double stopping_entry_speed,
double stopping_logitudinal_accel,
198 double lateral_accel_limit,
double min_maneuver_length
229 carma_ros2_utils::SubPtr<geometry_msgs::msg::TwistStamped>
twist_sub_;
275 void twist_cb(geometry_msgs::msg::TwistStamped::UniquePtr msg);
291 rclcpp::Duration
getManeuverDuration(carma_planning_msgs::msg::Maneuver &maneuver,
double epsilon)
const;
298 geometry_msgs::msg::TransformStamped
tf_;
308 FRIEND_TEST(RouteFollowingPluginTest, testComposeManeuverMessage);
StrategicPlugin base class which can be extended by user provided plugins which wish to implement the...
FRIEND_TEST(RouteFollowingPlugin, TestReturnToShortestPath)
carma_ros2_utils::CallbackReturn on_configure_plugin()
Method which is triggered when this plugin is moved from the UNCONFIGURED to INACTIVE states....
FRIEND_TEST(StopAndWaitTestFixture, CaseThree)
std::string get_version_id()
Returns the version id of this plugin.
FRIEND_TEST(StopAndWaitTestFixture, CaseSix)
void initializeBumperTransformLookup()
Initialize transform lookup from front bumper to map.
static constexpr double MAX_LANE_WIDTH
std::vector< carma_planning_msgs::msg::Maneuver > latest_maneuver_plan_
std::string lane_change_plugin_
std::unordered_set< lanelet::Id > shortest_path_set_
FRIEND_TEST(RouteFollowingPlugin, TestHelperfunctions)
FRIEND_TEST(RouteFollowingPluginTest, testComposeManeuverMessage)
std::unique_ptr< tf2_ros::TransformListener > tf2_listener_
std::string stop_and_wait_plugin_
tf2::Stamped< tf2::Transform > frontbumper_transform_
void updateTimeProgress(std::vector< carma_planning_msgs::msg::Maneuver > &maneuvers, rclcpp::Time start_time) const
Given an array of maneuvers update the starting time for each.
carma_planning_msgs::msg::Maneuver composeLaneChangeManeuverMessage(double start_dist, double end_dist, double start_speed, double target_speed, lanelet::Id starting_lane_id, lanelet::Id ending_lane_id) const
Compose a lane change maneuver message based on input params NOTE: The start and stop time are not se...
std::string getNewManeuverId() const
This method returns a new UUID as a string for assignment to a Maneuver message.
FRIEND_TEST(RouteFollowingPlugin, TestAssociateSpeedLimit)
lanelet::BasicPoint2d current_loc_
std::string lanefollow_planning_tactical_plugin_
bool maneuverWithBufferStartsAfterDowntrack(const carma_planning_msgs::msg::Maneuver &maneuver, double downtrack, double lateral_accel, double min_maneuver_length) const
Identifies if a maneuver starts after the provided downtrack with compensation for a dynamic buffer s...
geometry_msgs::msg::PoseStamped pose_msg_
std::vector< carma_planning_msgs::msg::Maneuver > routeCb(const lanelet::routing::LaneletPath &route_shortest_path)
Calculate maneuver plan for remaining route. This callback is triggered when a new route has been rec...
FRIEND_TEST(StopAndWaitTestFixture, CaseSeven)
carma_planning_msgs::msg::Maneuver composeLaneFollowingManeuverMessage(double start_dist, double end_dist, double start_speed, double target_speed, const std::vector< lanelet::Id > &lane_ids) const
Compose a lane keeping maneuver message based on input params.
FRIEND_TEST(StopAndWaitTestFixture, CaseFour)
void setManeuverStartDist(carma_planning_msgs::msg::Maneuver &maneuver, double start_dist) const
Set the start distance of a maneuver based on the progress along the route.
carma_planning_msgs::msg::ManeuverPlan::UniquePtr current_maneuver_plan_
void bumper_pose_cb()
Callback for the front bumper pose transform.
void updateStartingSpeed(carma_planning_msgs::msg::Maneuver &maneuver, double start_speed) const
Given an maneuver update the starting speed.
rclcpp::TimerBase::SharedPtr bumper_pose_timer_
FRIEND_TEST(StopAndWaitTestFixture, CaseTwo)
void current_maneuver_plan_cb(carma_planning_msgs::msg::ManeuverPlan::UniquePtr msg)
Callback for the ManeuverPlan subscriber, will store the current maneuver plan received locally....
void twist_cb(geometry_msgs::msg::TwistStamped::UniquePtr msg)
Callback for the twist subscriber, which will store latest twist locally.
void plan_maneuvers_callback(std::shared_ptr< rmw_request_id_t > srv_header, carma_planning_msgs::srv::PlanManeuvers::Request::SharedPtr req, carma_planning_msgs::srv::PlanManeuvers::Response::SharedPtr resp)
Service callback for arbitrator maneuver planning.
double findSpeedLimit(const lanelet::ConstLanelet &llt)
Given a Lanelet, find it's associated Speed Limit.
bool isLaneChangeNeeded(lanelet::routing::LaneletRelations relations, lanelet::Id target_id) const
Given a LaneletRelations and ID of the next lanelet in the shortest path.
carma_ros2_utils::SubPtr< carma_planning_msgs::msg::ManeuverPlan > current_maneuver_plan_sub_
carma_ros2_utils::CallbackReturn on_activate_plugin()
Method which is triggered when this plugin is moved from the INACTIVE to ACTIVE states....
std::shared_ptr< carma_wm::WMListener > wml_
rclcpp::Duration getManeuverDuration(carma_planning_msgs::msg::Maneuver &maneuver, double epsilon) const
returns duration as ros::Duration required to complete maneuver given its start dist,...
FRIEND_TEST(StopAndWaitTestFixture, CaseEight)
void returnToShortestPath(const lanelet::ConstLanelet ¤t_lanelet)
This method re-routes the vehicle back to the shortest path, if the vehicle has left the shortest pat...
carma_ros2_utils::SubPtr< geometry_msgs::msg::TwistStamped > twist_sub_
std::string planning_strategic_plugin_
RouteFollowingPlugin(const rclcpp::NodeOptions &)
Default constructor for RouteFollowingPlugin class.
FRIEND_TEST(StopAndWaitTestFixture, CaseFive)
carma_planning_msgs::msg::Maneuver composeStopAndWaitManeuverMessage(double start_dist, double end_dist, double start_speed, lanelet::Id starting_lane_id, lanelet::Id ending_lane_id, double stopping_accel) const
Compose a stop and wait maneuver message based on input params. NOTE: The start and stop time are not...
tf2_ros::Buffer tf2_buffer_
FRIEND_TEST(StopAndWaitTestFixture, CaseNine)
FRIEND_TEST(RouteFollowingPlugin, TestAssociateSpeedLimitusingosm)
geometry_msgs::msg::TransformStamped tf_
std::vector< carma_planning_msgs::msg::Maneuver > addStopAndWaitAtRouteEnd(const std::vector< carma_planning_msgs::msg::Maneuver > &input_maneuvers, double route_end_downtrack, double stopping_entry_speed, double stopping_logitudinal_accel, double lateral_accel_limit, double min_maneuver_length) const
Adds a StopAndWait maneuver to the end of a maneuver set stopping at the provided downtrack value NOT...
bool get_availability()
Get the availability status of this plugin based on the current operating environment....
FRIEND_TEST(StopAndWaitTestFixture, CaseTen)
FRIEND_TEST(StopAndWaitTestFixture, CaseOne)
carma_wm::WorldModelConstPtr wm_
FRIEND_TEST(RouteFollowingPluginTest, testIdentifyLaneChange)
std::shared_ptr< const WorldModel > WorldModelConstPtr
Struct containing config values values for route_following_plugin.