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.
stop_and_wait_plugin.hpp
Go to the documentation of this file.
1#pragma once
2/*
3 * Copyright (C) 2019-2022 LEIDOS.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
6 * use this file except in compliance with the License. You may obtain a copy of
7 * the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14 * License for the specific language governing permissions and limitations under
15 * the License.
16 */
17
18#include <vector>
19#include <carma_planning_msgs/msg/trajectory_plan_point.hpp>
20#include <carma_planning_msgs/msg/trajectory_plan.hpp>
21#include <boost/optional.hpp>
25#include <boost/shared_ptr.hpp>
28#include <functional>
29#include <lanelet2_core/primitives/Lanelet.h>
30#include <lanelet2_core/geometry/LineString.h>
31#include <carma_wm/Geometry.hpp>
32#include <carma_ros2_utils/carma_lifecycle_node.hpp>
33#include <boost/geometry.hpp>
34#include <geometry_msgs/msg/pose_stamped.hpp>
35#include <geometry_msgs/msg/twist_stamped.hpp>
36#include <carma_planning_msgs/srv/plan_trajectory.hpp>
37#include <carma_planning_msgs/msg/plugin.hpp>
38
40{
45{
46 lanelet::BasicPoint2d point;
47 double speed = 0;
48};
49
51{
52public:
56 StopandWait(std::shared_ptr<carma_ros2_utils::CarmaLifecycleNode> nh,
58 const StopandWaitConfig& config,
59 const std::string& plugin_name,
60 const std::string& version_id);
61
70 bool plan_trajectory_cb(carma_planning_msgs::srv::PlanTrajectory::Request::SharedPtr req, carma_planning_msgs::srv::PlanTrajectory::Response::SharedPtr resp);
71
85 std::vector<PointSpeedPair> maneuvers_to_points(const std::vector<carma_planning_msgs::msg::Maneuver>& maneuvers,
87 const carma_planning_msgs::msg::VehicleState& state);
98 std::vector<carma_planning_msgs::msg::TrajectoryPlanPoint> compose_trajectory_from_centerline(
99 const std::vector<PointSpeedPair>& points, double starting_downtrack, double starting_speed, double stop_location,
100 double stop_location_buffer, rclcpp::Time start_time, double stopping_acceleration, double& initial_speed);
101
105 void splitPointSpeedPairs(const std::vector<PointSpeedPair>& points, std::vector<lanelet::BasicPoint2d>* basic_points,
106 std::vector<double>* speeds) const;
107
108 std::vector<carma_planning_msgs::msg::TrajectoryPlanPoint> trajectory_from_points_times_orientations(
109 const std::vector<lanelet::BasicPoint2d>& points, const std::vector<double>& times,
110 const std::vector<double>& yaws, rclcpp::Time startTime);
111
117 void set_yield_client(carma_ros2_utils::ClientPtr<carma_planning_msgs::srv::PlanTrajectory> client);
118
119private:
120
121 double epsilon_ = 0.001; //small constant to compare double
122
123 // pointer to the actual wm object
124 std::string plugin_name_;
125 std::string version_id_;
128 std::shared_ptr<carma_ros2_utils::CarmaLifecycleNode> nh_;
129 // Service Clients
130 carma_ros2_utils::ClientPtr<carma_planning_msgs::srv::PlanTrajectory> yield_client_;
131
132};
133} // namespace stop_and_wait_plugin
carma_wm::WorldModelConstPtr wm_
void splitPointSpeedPairs(const std::vector< PointSpeedPair > &points, std::vector< lanelet::BasicPoint2d > *basic_points, std::vector< double > *speeds) const
Helper method to split a list of PointSpeedPair into separate point and speed lists.
void set_yield_client(carma_ros2_utils::ClientPtr< carma_planning_msgs::srv::PlanTrajectory > client)
set the yield service
std::vector< PointSpeedPair > maneuvers_to_points(const std::vector< carma_planning_msgs::msg::Maneuver > &maneuvers, const carma_wm::WorldModelConstPtr &wm, const carma_planning_msgs::msg::VehicleState &state)
Converts a set of requested STOP_AND_WAIT maneuvers to point speed limit pairs.
bool plan_trajectory_cb(carma_planning_msgs::srv::PlanTrajectory::Request::SharedPtr req, carma_planning_msgs::srv::PlanTrajectory::Response::SharedPtr resp)
Service callback for trajectory planning.
std::vector< carma_planning_msgs::msg::TrajectoryPlanPoint > compose_trajectory_from_centerline(const std::vector< PointSpeedPair > &points, double starting_downtrack, double starting_speed, double stop_location, double stop_location_buffer, rclcpp::Time start_time, double stopping_acceleration, double &initial_speed)
Method converts a list of lanelet centerline points and current vehicle state into a usable list of t...
StopandWait(std::shared_ptr< carma_ros2_utils::CarmaLifecycleNode > nh, carma_wm::WorldModelConstPtr wm, const StopandWaitConfig &config, const std::string &plugin_name, const std::string &version_id)
Constructor.
std::shared_ptr< carma_ros2_utils::CarmaLifecycleNode > nh_
carma_ros2_utils::ClientPtr< carma_planning_msgs::srv::PlanTrajectory > yield_client_
std::vector< carma_planning_msgs::msg::TrajectoryPlanPoint > trajectory_from_points_times_orientations(const std::vector< lanelet::BasicPoint2d > &points, const std::vector< double > &times, const std::vector< double > &yaws, rclcpp::Time startTime)
std::shared_ptr< const WorldModel > WorldModelConstPtr
Definition: WorldModel.hpp:452
string version_id
Stuct containing the algorithm configuration values for the stop_and_wait_plugin.
Convenience class for pairing 2d points with speeds.