scenario_simulator_v2 C++ API
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Public Member Functions | List of all members
traffic_simulator::API Class Reference

#include <api.hpp>

Public Member Functions

template<typename NodeT , typename AllocatorT = std::allocator<void>, typename... Ts>
 API (NodeT &&node, const Configuration &configuration, Ts &&... xs)
 
template<typename ParameterT , typename... Ts>
auto getROS2Parameter (Ts &&... xs) const -> decltype(auto)
 
auto init () -> bool
 
auto setVerbose (const bool verbose) -> void
 
auto setSimulationStepTime (const double step_time) -> bool
 
auto startNpcLogic () -> void
 
auto isNpcLogicStarted () const -> bool
 
auto getCurrentTime () const noexcept -> double
 
auto closeZMQConnection () -> void
 
auto updateFrame () -> bool
 
template<typename PoseType , typename ParamsType , typename = std::enable_if_t<std::disjunction_v< std::is_same<std::decay_t<ParamsType>, traffic_simulator_msgs::msg::VehicleParameters>, std::is_same<std::decay_t<ParamsType>, traffic_simulator_msgs::msg::PedestrianParameters>, std::is_same<std::decay_t<ParamsType>, traffic_simulator_msgs::msg::MiscObjectParameters>>>>
auto spawn (const std::string &name, const PoseType &pose, const ParamsType &parameters, const std::string &behavior="", const std::string &model3d="") -> entity::EntityBase &
 
auto attachImuSensor (const std::string &, const simulation_api_schema::ImuSensorConfiguration &configuration) -> bool
 
auto attachPseudoTrafficLightDetector (const simulation_api_schema::PseudoTrafficLightDetectorConfiguration &) -> bool
 
auto attachLidarSensor (const simulation_api_schema::LidarConfiguration &) -> bool
 
auto attachLidarSensor (const std::string &, const double lidar_sensor_delay, const helper::LidarType=helper::LidarType::VLP16) -> bool
 
auto attachDetectionSensor (const simulation_api_schema::DetectionSensorConfiguration &) -> bool
 
auto attachDetectionSensor (const std::string &, double detection_sensor_range, bool detect_all_objects_in_range, double pos_noise_stddev, int random_seed, double probability_of_lost, double object_recognition_delay) -> bool
 
auto attachOccupancyGridSensor (const simulation_api_schema::OccupancyGridSensorConfiguration &) -> bool
 
auto getFirstEgoName () const -> std::optional< std::string >
 
auto getEgoEntity (const std::string &name) -> entity::EgoEntity &
 
auto getEgoEntity (const std::string &name) const -> const entity::EgoEntity &
 
auto isEntityExist (const std::string &name) const -> bool
 
auto getEntityNames () const -> std::vector< std::string >
 
auto getEntity (const std::string &name) -> entity::EntityBase &
 
auto getEntity (const std::string &name) const -> const entity::EntityBase &
 
auto getEntityPointer (const std::string &name) const -> std::shared_ptr< entity::EntityBase >
 
auto resetBehaviorPlugin (const std::string &name, const std::string &behavior_plugin_name) -> void
 
auto respawn (const std::string &name, const geometry_msgs::msg::PoseWithCovarianceStamped &new_pose, const geometry_msgs::msg::PoseStamped &goal_pose) -> void
 
auto despawn (const std::string &name) -> bool
 
auto despawnEntities () -> bool
 
auto checkCollision (const std::string &first_entity_name, const std::string &second_entity_name) const -> bool
 
auto getHdmapUtils () const -> const std::shared_ptr< hdmap_utils::HdMapUtils > &
 
auto getV2ITrafficLights () const -> std::shared_ptr< V2ITrafficLights >
 
auto getConventionalTrafficLights () const -> std::shared_ptr< ConventionalTrafficLights >
 
auto addTrafficSource (const double radius, const double rate, const double speed, const geometry_msgs::msg::Pose &position, const traffic::TrafficSource::Distribution &distribution, const bool allow_spawn_outside_lane=false, const bool require_footprint_fitting=false, const bool random_orientation=false, std::optional< int > random_seed=std::nullopt) -> void
 Add a traffic source to the simulation. More...
 

Constructor & Destructor Documentation

◆ API()

template<typename NodeT , typename AllocatorT = std::allocator<void>, typename... Ts>
traffic_simulator::API::API ( NodeT &&  node,
const Configuration configuration,
Ts &&...  xs 
)
inlineexplicit

Member Function Documentation

◆ addTrafficSource()

auto traffic_simulator::API::addTrafficSource ( const double  radius,
const double  rate,
const double  speed,
const geometry_msgs::msg::Pose &  position,
const traffic::TrafficSource::Distribution distribution,
const bool  allow_spawn_outside_lane = false,
const bool  require_footprint_fitting = false,
const bool  random_orientation = false,
std::optional< int >  random_seed = std::nullopt 
) -> void

Add a traffic source to the simulation.

Parameters
radiusThe radius defining the area on which entities will be spawned
rateThe rate at which entities will be spawned [Hz]
speedThe speed of the spawned entities
positionThe center of the area on which entities will be spawned (includes orientation)
distributionThe parameters of the spawned entities with their respective weights for random distribution For each entity there are 4 parameters in a tuple:
  • VehicleParameters or PedestrianParameters - parameters of entity
  • std::string - name of behavior to be used when spawning
  • std::string - name of 3D model to be used when spawning
  • double - weight of entity for random distribution
allow_spawn_outside_laneWhether entities can be spawned outside the lane
require_footprint_fittingWhether entities are required to fit inside lanelet polygon when spawned (allow_spawn_outside_lane has higher priority)
random_orientationWhether entities should have their orientation randomized before lane matching
random_seed[Optional] The seed for the random number generator

◆ attachDetectionSensor() [1/2]

auto traffic_simulator::API::attachDetectionSensor ( const simulation_api_schema::DetectionSensorConfiguration &  sensor_configuration) -> bool

◆ attachDetectionSensor() [2/2]

auto traffic_simulator::API::attachDetectionSensor ( const std::string &  entity_name,
double  detection_sensor_range,
bool  detect_all_objects_in_range,
double  pos_noise_stddev,
int  random_seed,
double  probability_of_lost,
double  object_recognition_delay 
) -> bool

◆ attachImuSensor()

auto traffic_simulator::API::attachImuSensor ( const std::string &  ,
const simulation_api_schema::ImuSensorConfiguration &  configuration 
) -> bool

◆ attachLidarSensor() [1/2]

auto traffic_simulator::API::attachLidarSensor ( const simulation_api_schema::LidarConfiguration &  lidar_configuration) -> bool

◆ attachLidarSensor() [2/2]

auto traffic_simulator::API::attachLidarSensor ( const std::string &  entity_name,
const double  lidar_sensor_delay,
const helper::LidarType  lidar_type = helper::LidarType::VLP16 
) -> bool

◆ attachOccupancyGridSensor()

auto traffic_simulator::API::attachOccupancyGridSensor ( const simulation_api_schema::OccupancyGridSensorConfiguration &  sensor_configuration) -> bool

◆ attachPseudoTrafficLightDetector()

auto traffic_simulator::API::attachPseudoTrafficLightDetector ( const simulation_api_schema::PseudoTrafficLightDetectorConfiguration &  configuration) -> bool

◆ checkCollision()

auto traffic_simulator::API::checkCollision ( const std::string &  first_entity_name,
const std::string &  second_entity_name 
) const -> bool

◆ closeZMQConnection()

auto traffic_simulator::API::closeZMQConnection ( ) -> void

◆ despawn()

auto traffic_simulator::API::despawn ( const std::string &  name) -> bool

◆ despawnEntities()

auto traffic_simulator::API::despawnEntities ( ) -> bool

◆ getConventionalTrafficLights()

auto traffic_simulator::API::getConventionalTrafficLights ( ) const -> std::shared_ptr<ConventionalTrafficLights>

◆ getCurrentTime()

auto traffic_simulator::API::getCurrentTime ( ) const -> double
noexcept

◆ getEgoEntity() [1/2]

auto traffic_simulator::API::getEgoEntity ( const std::string &  name) -> entity::EgoEntity &

◆ getEgoEntity() [2/2]

auto traffic_simulator::API::getEgoEntity ( const std::string &  name) const -> const entity::EgoEntity &

◆ getEntity() [1/2]

auto traffic_simulator::API::getEntity ( const std::string &  name) -> entity::EntityBase &

◆ getEntity() [2/2]

auto traffic_simulator::API::getEntity ( const std::string &  name) const -> const entity::EntityBase &

◆ getEntityNames()

auto traffic_simulator::API::getEntityNames ( ) const -> std::vector<std::string>

◆ getEntityPointer()

auto traffic_simulator::API::getEntityPointer ( const std::string &  name) const -> std::shared_ptr<entity::EntityBase>

◆ getFirstEgoName()

auto traffic_simulator::API::getFirstEgoName ( ) const -> std::optional<std::string>

◆ getHdmapUtils()

auto traffic_simulator::API::getHdmapUtils ( ) const -> const std::shared_ptr<hdmap_utils::HdMapUtils> &

◆ getROS2Parameter()

template<typename ParameterT , typename... Ts>
auto traffic_simulator::API::getROS2Parameter ( Ts &&...  xs) const -> decltype(auto)
inline

◆ getV2ITrafficLights()

auto traffic_simulator::API::getV2ITrafficLights ( ) const -> std::shared_ptr<V2ITrafficLights>

◆ init()

auto traffic_simulator::API::init ( ) -> bool

◆ isEntityExist()

auto traffic_simulator::API::isEntityExist ( const std::string &  name) const -> bool

◆ isNpcLogicStarted()

auto traffic_simulator::API::isNpcLogicStarted ( ) const -> bool

◆ resetBehaviorPlugin()

auto traffic_simulator::API::resetBehaviorPlugin ( const std::string &  name,
const std::string &  behavior_plugin_name 
) -> void

◆ respawn()

auto traffic_simulator::API::respawn ( const std::string &  name,
const geometry_msgs::msg::PoseWithCovarianceStamped &  new_pose,
const geometry_msgs::msg::PoseStamped &  goal_pose 
) -> void

◆ setSimulationStepTime()

auto traffic_simulator::API::setSimulationStepTime ( const double  step_time) -> bool
Note
Pausing the simulation by setting the realtime_factor_ value to 0 is not supported and causes the simulation crash. For that reason, before performing the action, it needs to be ensured that the incoming request data is a positive number.

◆ setVerbose()

auto traffic_simulator::API::setVerbose ( const bool  verbose) -> void

◆ spawn()

template<typename PoseType , typename ParamsType , typename = std::enable_if_t<std::disjunction_v< std::is_same<std::decay_t<ParamsType>, traffic_simulator_msgs::msg::VehicleParameters>, std::is_same<std::decay_t<ParamsType>, traffic_simulator_msgs::msg::PedestrianParameters>, std::is_same<std::decay_t<ParamsType>, traffic_simulator_msgs::msg::MiscObjectParameters>>>>
auto traffic_simulator::API::spawn ( const std::string &  name,
const PoseType &  pose,
const ParamsType &  parameters,
const std::string &  behavior = "",
const std::string &  model3d = "" 
) -> entity::EntityBase &
inline
Todo:
Should be filled from function API

◆ startNpcLogic()

auto traffic_simulator::API::startNpcLogic ( ) -> void

◆ updateFrame()

auto traffic_simulator::API::updateFrame ( ) -> bool

The documentation for this class was generated from the following files: