scenario_simulator_v2 C++ API
vehicle_action_node.hpp
Go to the documentation of this file.
1 // Copyright 2015 TIER IV, Inc. All rights reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef BEHAVIOR_TREE_PLUGIN__VEHICLE__VEHICLE_ACTION_NODE_HPP_
16 #define BEHAVIOR_TREE_PLUGIN__VEHICLE__VEHICLE_ACTION_NODE_HPP_
17 
18 #include <behaviortree_cpp_v3/action_node.h>
19 
23 #include <memory>
24 #include <optional>
25 #include <string>
27 #include <traffic_simulator_msgs/msg/behavior_parameter.hpp>
28 #include <traffic_simulator_msgs/msg/obstacle.hpp>
29 #include <traffic_simulator_msgs/msg/vehicle_parameters.hpp>
30 #include <traffic_simulator_msgs/msg/waypoints_array.hpp>
31 #include <vector>
32 
33 namespace entity_behavior
34 {
36 {
37 public:
38  VehicleActionNode(const std::string & name, const BT::NodeConfiguration & config);
39  ~VehicleActionNode() override = default;
40  void getBlackBoardValues();
41  static BT::PortsList providedPorts()
42  {
43  BT::PortsList ports = {
44  // clang-format off
45  BT::InputPort<std::shared_ptr<math::geometry::CatmullRomSpline>>("reference_trajectory"),
46  BT::InputPort<traffic_simulator_msgs::msg::BehaviorParameter>("behavior_parameter"),
47  BT::InputPort<traffic_simulator_msgs::msg::VehicleParameters>("vehicle_parameters"),
48  // clang-format on
49  };
50  BT::PortsList parent_ports = entity_behavior::ActionNode::providedPorts();
51  for (const auto & parent_port : parent_ports) {
52  ports.emplace(parent_port.first, parent_port.second);
53  }
54  return ports;
55  }
59  virtual const traffic_simulator_msgs::msg::WaypointsArray calculateWaypoints() = 0;
60  virtual const std::optional<traffic_simulator_msgs::msg::Obstacle> calculateObstacle(
61  const traffic_simulator_msgs::msg::WaypointsArray & waypoints) = 0;
62 
63 protected:
64  traffic_simulator_msgs::msg::BehaviorParameter behavior_parameter;
65  traffic_simulator_msgs::msg::VehicleParameters vehicle_parameters;
66  std::shared_ptr<math::geometry::CatmullRomSpline> reference_trajectory;
67  std::unique_ptr<math::geometry::CatmullRomSubspline> trajectory;
68 };
69 } // namespace entity_behavior
70 
71 #endif // BEHAVIOR_TREE_PLUGIN__VEHICLE__VEHICLE_ACTION_NODE_HPP_
Definition: action_node.hpp:41
static BT::PortsList providedPorts()
Definition: action_node.hpp:75
std::optional< double > target_speed
Definition: action_node.hpp:120
Definition: vehicle_action_node.hpp:36
virtual const traffic_simulator_msgs::msg::WaypointsArray calculateWaypoints()=0
void getBlackBoardValues()
Definition: vehicle_action_node.cpp:29
static BT::PortsList providedPorts()
Definition: vehicle_action_node.hpp:41
std::shared_ptr< math::geometry::CatmullRomSpline > reference_trajectory
Definition: vehicle_action_node.hpp:66
traffic_simulator_msgs::msg::VehicleParameters vehicle_parameters
Definition: vehicle_action_node.hpp:65
auto calculateUpdatedEntityStatus(double target_speed) const -> traffic_simulator::EntityStatus
Definition: vehicle_action_node.cpp:46
std::unique_ptr< math::geometry::CatmullRomSubspline > trajectory
Definition: vehicle_action_node.hpp:67
VehicleActionNode(const std::string &name, const BT::NodeConfiguration &config)
Definition: vehicle_action_node.cpp:24
auto calculateUpdatedEntityStatusInWorldFrame(double target_speed) const -> traffic_simulator::EntityStatus
Definition: vehicle_action_node.cpp:53
traffic_simulator_msgs::msg::BehaviorParameter behavior_parameter
Definition: vehicle_action_node.hpp:64
virtual const std::optional< traffic_simulator_msgs::msg::Obstacle > calculateObstacle(const traffic_simulator_msgs::msg::WaypointsArray &waypoints)=0
~VehicleActionNode() override=default
Definition: action_node.hpp:39
traffic_simulator_msgs::msg::EntityStatus EntityStatus
Definition: entity_status.hpp:25
std::string string
Definition: junit5.hpp:26