CARLA
Loading...
Searching...
No Matches
DVSCamera.h
Go to the documentation of this file.
1// Copyright (c) 2020 Robotics and Perception Group (GPR)
2// University of Zurich and ETH Zurich
3//
4// This work is licensed under the terms of the MIT license.
5// For a copy, see <https://opensource.org/licenses/MIT>.
6
7#pragma once
8
11
15
16#include "DVSCamera.generated.h"
17
18namespace dvs
19{
20 /// DVS Configuration structure
21 struct Config
22 {
23 float Cp;
24 float Cm;
25 float sigma_Cp;
26 float sigma_Cm;
27 std::uint64_t refractory_period_ns;
28 bool use_log;
29 float log_eps;
30 };
31
32 inline constexpr std::int64_t secToNanosec(double seconds)
33 {
34 return static_cast<std::int64_t>(seconds * 1e9);
35 }
36
37 inline constexpr double nanosecToSecTrunc(std::int64_t nanoseconds)
38 {
39 return static_cast<double>(nanoseconds) / 1e9;
40 }
41
42} // namespace dvs
43
44/// Sensor that produce Dynamic Vision Events
45UCLASS()
46class CARLA_API ADVSCamera : public AShaderBasedSensor
47{
48 GENERATED_BODY()
49 using DVSEventArray = std::vector<::carla::sensor::data::DVSEvent>;
50
51public:
52 ADVSCamera(const FObjectInitializer &ObjectInitializer);
53 static FActorDefinition GetSensorDefinition();
54 void Set(const FActorDescription &ActorDescription) override;
55
56protected:
57 virtual void PostPhysTick(UWorld *World, ELevelTick TickType, float DeltaTime) override;
58 void ImageToGray(const TArray<FColor> &image);
59 void ImageToLogGray(const TArray<FColor> &image);
60 ADVSCamera::DVSEventArray Simulation (float DeltaTime);
61
62private:
63 /// Images containing last (current) and previous image
64 TArray<float> last_image, prev_image;
65
66 /// Image containing the last reference value to trigger event
67 TArray<float> ref_values;
68
69 /// Image containing time of last event in seconds
70 TArray<double> last_event_timestamp;
71
72 /// Current time in nanoseconds
73 std::int64_t current_time;
74
75 /// DVS simulation configuration
76 dvs::Config config;
77};
Sensor that produce Dynamic Vision Events.
Definition DVSCamera.h:47
std::vector<::carla::sensor::data::DVSEvent > DVSEventArray
Definition DVSCamera.h:49
A sensor that produces data by applying post-process materials (shaders) to a scene capture image.
This file contains definitions of common data structures used in traffic manager.
constexpr std::int64_t secToNanosec(double seconds)
Definition DVSCamera.h:32
constexpr double nanosecToSecTrunc(std::int64_t nanoseconds)
Definition DVSCamera.h:37
A definition of a Carla Actor with all the variation and attributes.
A description of a Carla Actor with all its variation.
DVS Configuration structure.
Definition DVSCamera.h:22
float sigma_Cp
Definition DVSCamera.h:25
std::uint64_t refractory_period_ns
Definition DVSCamera.h:27
bool use_log
Definition DVSCamera.h:28
float log_eps
Definition DVSCamera.h:29
float sigma_Cm
Definition DVSCamera.h:26