CARLA
 
载入中...
搜索中...
未找到
LibCarla/source/carla/rss/RssSensor.h
浏览该文件的文档.
1// Copyright (c) 2019-2020 Intel Corporation
2//
3// This work is licensed under the terms of the MIT license.
4// For a copy, see <https://opensource.org/licenses/MIT>.
5
6#pragma once
7
8#include <atomic>
9#include <future>
10#include <list>
11#include <memory>
12#include <mutex>
13#include <vector>
14#include "carla/client/Sensor.h"
15
16namespace ad {
17namespace rss {
18namespace world {
19
20/// forward declaration of the RssDynamics struct
21struct RssDynamics;
22
23} // namespace world
24} // namespace rss
25} // namespace ad
26
27namespace carla {
28
29namespace rss {
30
31/// forward declaration of the RoadBoundariesMode
32enum class RoadBoundariesMode;
33/// forward declaration of the RssCheck class
34class RssCheck;
35/// forward declaration of the ActorContellationResult struct
36struct ActorConstellationResult;
37/// forward declaration of the ActorContellationData struct
38struct ActorConstellationData;
39} // namespace rss
40
41namespace client {
42
43/// The RSS Sensor class implementing the carla::client::Sensor interface
44/// This class is a proxy to the RssCheck class
45class RssSensor : public Sensor {
46public:
47 using Sensor::Sensor;
48
51
52 /// @brief constructor
53 explicit RssSensor(ActorInitializer init);
54
55 /// @brief destructor
56 ~RssSensor();
57
58 /// Register a @a callback to be executed for each actor within each measurement to be processed
59 /// to decide on the operation of the RSS sensor in respect to the ego vehicle to actor constellation
61
62 /// Register a @a callback to be executed each time a new measurement is
63 /// received.
64 ///
65 /// @warning Calling this function on a sensor that is already listening
66 /// steals the data stream from the previously set callback. Note that
67 /// several instances of Sensor (even in different processes) may point to
68 /// the same sensor in the simulator.
69 void Listen(CallbackFunctionType callback) override;
70
71 /// Stop listening for new measurements.
72 /// Be aware: GIL has to be unlocked to be able to wait for callbacks not active.
73 void Stop() override;
74
75 /// Return whether this Sensor instance is currently listening to the
76 /// associated sensor in the simulator.
77 bool IsListening() const override {
78 return _on_tick_register_id != 0u;
79 }
80
81 /// @brief sets the current log level
82 void SetLogLevel(const uint8_t &log_level);
83
84 /// @brief sets the current map log level
85 void SetMapLogLevel(const uint8_t &map_log_level);
86
87 /// @returns the currently used dynamics of the ego vehicle (@see also
88 /// RssCheck::GetEgoVehicleDynamics())
89 const ::ad::rss::world::RssDynamics &GetEgoVehicleDynamics() const;
90 /// @brief sets the ego vehicle dynamics to be used by the ego vehicle (@see
91 /// also RssCheck::SetEgoVehicleDynamics())
92 void SetEgoVehicleDynamics(const ::ad::rss::world::RssDynamics &ego_dynamics);
93
94 /// @returns the currently used dynamics of other vehicles (@see also
95 /// RssCheck::GetOtherVehicleDynamics())
96 const ::ad::rss::world::RssDynamics &GetOtherVehicleDynamics() const;
97 /// @brief sets the ego vehicle dynamics to be used by other vehicles (@see
98 /// also RssCheck::SetOtherVehicleDynamics())
99 void SetOtherVehicleDynamics(const ::ad::rss::world::RssDynamics &other_vehicle_dynamics);
100
101 /// @returns the currently used dynamics of pedestrians (@see also
102 /// RssCheck::GetPedestrianDynamics())
103 const ::ad::rss::world::RssDynamics &GetPedestrianDynamics() const;
104 /// @brief sets the ego vehicle dynamics to be used by pedestrians (@see
105 /// also RssCheck::SetPedestrianDynamics())
106 void SetPedestrianDynamics(const ::ad::rss::world::RssDynamics &pedestrian_dynamics);
107
108 /// @returns the current mode for respecting the road boundaries (@see also
109 /// RssCheck::GetRoadBoundariesMode())
110 const ::carla::rss::RoadBoundariesMode &GetRoadBoundariesMode() const;
111 /// @brief sets the current mode for respecting the road boundaries (@see also
112 /// RssCheck::SetRoadBoundariesMode())
113 void SetRoadBoundariesMode(const ::carla::rss::RoadBoundariesMode &road_boundaries_mode);
114
115 /// @returns the current routing targets (@see also
116 /// RssCheck::GetRoutingTargets())
117 const std::vector<::carla::geom::Transform> GetRoutingTargets() const;
118 /// @brief appends a routing target to the current routing target list (@see
119 /// also RssCheck::AppendRoutingTarget())
120 void AppendRoutingTarget(const ::carla::geom::Transform &routing_target);
121 /// @brief resets the current routing target (@see also
122 /// RssCheck::ResetRoutingTargets())
123 void ResetRoutingTargets();
124
125 /// @brief drop the current route (@see also RssCheck::DropRoute())
126 void DropRoute();
127
128private:
129 /// the acutal sensor tick callback function
130 void TickRssSensor(const client::Timestamp &timestamp, CallbackFunctionType callback);
132 CallbackFunctionType callback);
133
134 //// the object actually performing the RSS processing
135 std::shared_ptr<::carla::rss::RssCheck> _rss_check;
136
137 /// the id got when registering for the on tick event
139
140 /// the mutex to protect the actual RSS processing and in case it takes too long to process ever frame
142
143 /// the future for the async ticking thread
144 std::future<void> _tick_future;
145
146 /// some debug timings
147 std::list<double> _rss_check_timings;
148
149 //// the rss actor constellation callback function
151
152 /// reqired to store DropRoute() requests until next sensor tick
154
155 /// last processed frame
157
158 static std::atomic_uint _global_map_initialization_counter_;
159};
160
161} // namespace client
162} // namespace carla
Used to initialize Actor classes.
The RSS Sensor class implementing the carla::client::Sensor interface This class is a proxy to the Rs...
std::size_t _last_processed_frame
last processed frame
std::future< void > _tick_future
the future for the async ticking thread
void ResetRoutingTargets()
resets the current routing target (
std::size_t _on_tick_register_id
the id got when registering for the on tick event
bool IsListening() const override
Return whether this Sensor instance is currently listening to the associated sensor in the simulator.
const ::ad::rss::world::RssDynamics & GetOtherVehicleDynamics() const
void SetLogLevel(const uint8_t &log_level)
sets the current log level
void SetEgoVehicleDynamics(const ::ad::rss::world::RssDynamics &ego_dynamics)
sets the ego vehicle dynamics to be used by the ego vehicle (
std::shared_ptr<::carla::rss::RssCheck > _rss_check
static std::atomic_uint _global_map_initialization_counter_
void SetPedestrianDynamics(const ::ad::rss::world::RssDynamics &pedestrian_dynamics)
sets the ego vehicle dynamics to be used by pedestrians (
void RegisterActorConstellationCallback(ActorConstellationCallbackFunctionType callback)
Register a callback to be executed for each actor within each measurement to be processed to decide o...
std::function<::carla::rss::ActorConstellationResult(carla::SharedPtr<::carla::rss::ActorConstellationData >)> ActorConstellationCallbackFunctionType
void Stop() override
Stop listening for new measurements.
const ::ad::rss::world::RssDynamics & GetPedestrianDynamics() const
void TickRssSensor(const client::Timestamp &timestamp, CallbackFunctionType callback)
the acutal sensor tick callback function
void SetOtherVehicleDynamics(const ::ad::rss::world::RssDynamics &other_vehicle_dynamics)
sets the ego vehicle dynamics to be used by other vehicles (
void SetMapLogLevel(const uint8_t &map_log_level)
sets the current map log level
std::list< double > _rss_check_timings
some debug timings
const ::ad::rss::world::RssDynamics & GetEgoVehicleDynamics() const
RssSensor(ActorInitializer init)
constructor
void AppendRoutingTarget(const ::carla::geom::Transform &routing_target)
appends a routing target to the current routing target list (
std::mutex _processing_lock
the mutex to protect the actual RSS processing and in case it takes too long to process ever frame
void SetRoadBoundariesMode(const ::carla::rss::RoadBoundariesMode &road_boundaries_mode)
sets the current mode for respecting the road boundaries (
ActorConstellationCallbackFunctionType _rss_actor_constellation_callback
const ::carla::rss::RoadBoundariesMode & GetRoadBoundariesMode() const
const std::vector<::carla::geom::Transform > GetRoutingTargets() const
void Listen(CallbackFunctionType callback) override
Register a callback to be executed each time a new measurement is received.
bool _drop_route
reqired to store DropRoute() requests until next sensor tick
void TickRssSensorThreadLocked(const client::Timestamp &timestamp, SharedPtr< carla::client::ActorList > actors, CallbackFunctionType callback)
std::function< void(SharedPtr< sensor::SensorData >)> CallbackFunctionType
RoadBoundariesMode
struct defining the different supported handling of road boundaries
Definition RssCheck.h:28
This file contains definitions of common data structures used in traffic manager.
Definition Carla.cpp:133
boost::shared_ptr< T > SharedPtr
Use this SharedPtr (boost::shared_ptr) to keep compatibility with boost::python, but it would be nice...
Definition Memory.h:20
Struct defining the configuration for RSS processing of a given actor
Definition RssCheck.h:96