Minor fixes and code style adaptation

This commit is contained in:
Marc Garcia Puig 2020-04-28 18:12:22 +02:00
parent c45614c983
commit 87ac3b9a6d
8 changed files with 44 additions and 40 deletions

View File

@ -6,6 +6,7 @@
* Fixed missing include directive in file **WheelPhysicsControl.h**
* Fixed gravity measurement bug from IMU sensor
* OpenDRIVE ingestion bugfixes
* Added Dynamic Vision Sensor (DVS) camera based on ESIM simulation http://rpg.ifi.uzh.ch/esim.html
## CARLA 0.9.9

View File

@ -15,6 +15,7 @@
// 1. Include the serializer here.
#include "carla/sensor/s11n/CollisionEventSerializer.h"
#include "carla/sensor/s11n/DVSEventArraySerializer.h"
#include "carla/sensor/s11n/EpisodeStateSerializer.h"
#include "carla/sensor/s11n/GnssSerializer.h"
#include "carla/sensor/s11n/ImageSerializer.h"
@ -23,7 +24,6 @@
#include "carla/sensor/s11n/NoopSerializer.h"
#include "carla/sensor/s11n/ObstacleDetectionEventSerializer.h"
#include "carla/sensor/s11n/RadarSerializer.h"
#include "carla/sensor/s11n/DVSEventArraySerializer.h"
// 2. Add a forward-declaration of the sensor here.
class ACollisionSensor;

View File

@ -14,32 +14,36 @@ namespace data {
#pragma pack(push, 1)
struct DVSEvent {
/** Default constructor **/
/// Default constructor
DVSEvent() = default;
/** Copy Constructor **/
/// Copy Constructor
DVSEvent(const DVSEvent &arg)
:x(arg.x), y(arg.y), t(arg.t), pol(arg.pol){}
/** Moving constructor **/
/// Moving constructor
DVSEvent(const DVSEvent &&arg)
:x(std::move(arg.x)), y(std::move(arg.y)), t(std::move(arg.t)), pol(std::move(arg.pol)){}
/** Constructor **/
/// Constructor
DVSEvent(std::uint16_t x, std::uint16_t y, std::int64_t t, bool pol)
: x(x), y(y), t(t), pol(pol) {}
/** Assignement operator **/
DVSEvent &operator=(const DVSEvent &other)
{
x = other.x; y = other.y; t = other.t; pol = other.pol;
/// Assignement operator
DVSEvent &operator=(const DVSEvent &other) {
x = other.x;
y = other.y;
t = other.t;
pol = other.pol;
return *this;
}
/** Move Assignement operator **/
DVSEvent &operator=(const DVSEvent &&other)
{
x = std::move(other.x); y = std::move(other.y); t = std::move(other.t); pol = std::move(other.pol);
/// Move Assignement operator
DVSEvent &operator=(const DVSEvent &&other) {
x = std::move(other.x);
y = std::move(other.y);
t = std::move(other.t);
pol = std::move(other.pol);
return *this;
}

View File

@ -54,19 +54,18 @@ namespace s11n {
sensor.GetFOVAngle(),
};
/** Reset the output buffer **/
/// Reset the output buffer
output.reset(sizeof(DVSHeader) + (events.size() * sizeof(data::DVSEvent)));
/** Pointer to data in buffer **/
/// Pointer to data in buffer
unsigned char *it = output.data();
/** Copy the header into the output buffer **/
/// Copy the header into the output buffer
std::memcpy(it, reinterpret_cast<const void *>(&header), sizeof(header));
it += sizeof(DVSHeader);
/** Copy the events into the output buffer **/
for (auto e : events)
{
/// Copy the events into the output buffer
for (auto e : events) {
std::memcpy(it, reinterpret_cast<const void *>(&e), sizeof(data::DVSEvent));
it += sizeof(data::DVSEvent);
}

View File

@ -99,18 +99,18 @@ namespace data {
}
std::ostream &operator<<(std::ostream &out, const DVSEvent &event) {
out << "Event(" << event.x
<< ',' << event.y
<< ',' << event.t
<< ',' << event.pol << ')';
out << "Event(x=" << std::to_string(event.x)
<< ", y=" << std::to_string(event.y)
<< ", t=" << std::to_string(event.t)
<< ", pol=" << std::to_string(event.pol) << ')';
return out;
}
std::ostream &operator<<(std::ostream &out, const DVSEventArray &events) {
out << "EventArray(frame=" << events.GetFrame()
<< ", timestamp=" << events.GetTimestamp()
<< ", dimensions=" << events.GetWidth() << 'x' << events.GetHeight()
<< ", number_of_events=" << events.size()
out << "EventArray(frame=" << std::to_string(events.GetFrame())
<< ", timestamp=" << std::to_string(events.GetTimestamp())
<< ", dimensions=" << std::to_string(events.GetWidth()) << 'x' << std::to_string(events.GetHeight())
<< ", number_of_events=" << std::to_string(events.size())
<< ')';
return out;
}
@ -350,7 +350,7 @@ void export_sensor_data() {
.add_property("pol", &csd::DVSEvent::pol)
.def(self_ns::str(self_ns::self))
;
class_<csd::DVSEventArray, bases<cs::SensorData>, boost::noncopyable, boost::shared_ptr<csd::DVSEventArray>>("DVSEventArray", no_init)
.add_property("width", &csd::DVSEventArray::GetWidth)
.add_property("height", &csd::DVSEventArray::GetHeight)

View File

@ -900,7 +900,6 @@ class CameraManager(object):
self.transform_index = 1
self.sensors = [
['sensor.camera.rgb', cc.Raw, 'Camera RGB', {}],
['sensor.camera.dvs', cc.Raw, 'Dynamic Vision Sensor', {}],
['sensor.camera.depth', cc.Raw, 'Camera Depth (Raw)', {}],
['sensor.camera.depth', cc.Depth, 'Camera Depth (Gray Scale)', {}],
['sensor.camera.depth', cc.LogarithmicDepth, 'Camera Depth (Logarithmic Gray Scale)', {}],
@ -908,6 +907,7 @@ class CameraManager(object):
['sensor.camera.semantic_segmentation', cc.CityScapesPalette,
'Camera Semantic Segmentation (CityScapes Palette)', {}],
['sensor.lidar.ray_cast', None, 'Lidar (Ray-Cast)', {}],
['sensor.camera.dvs', cc.Raw, 'Dynamic Vision Sensor', {}],
['sensor.camera.rgb', cc.Raw, 'Camera RGB Distorted',
{'lens_circle_multiplier': '3.0',
'lens_circle_falloff': '3.0',
@ -983,7 +983,7 @@ class CameraManager(object):
lidar_img = np.zeros((lidar_img_size), dtype = int)
lidar_img[tuple(lidar_data.T)] = (255, 255, 255)
self.surface = pygame.surfarray.make_surface(lidar_img)
if self.sensors[self.index][0].startswith('sensor.camera.dvs'):
elif self.sensors[self.index][0].startswith('sensor.camera.dvs'):
array = np.frombuffer(image.to_image().raw_data, dtype=np.dtype("uint8"))
array = np.reshape(array, (image.height, image.width, 4))
array = array[:, :, :3]

View File

@ -253,7 +253,7 @@ ADVSCamera::DVSEventArray ADVSCamera::simulation (float DeltaTime)
}
else
{
/** Dropping event because time since last event < refractory_period_ns **/
/** Dropping event because time since last event < refractory_period_ns **/
}
this->ref_values[i] = curr_cross;
}
@ -285,4 +285,4 @@ template<typename T> T ADVSCamera::sampleNormalDistribution(bool deterministic,
static std::mt19937 gen_deterministic(0);
auto dist = std::normal_distribution<T>(mean, sigma);
return deterministic ? dist(gen_deterministic) : dist(gen_nondeterministic);
}
}

View File

@ -13,7 +13,7 @@
namespace dvs
{
/** DVS Configuration structure **/
/// DVS Configuration structure
struct Config
{
float Cp;
@ -35,7 +35,7 @@ namespace dvs
return static_cast<double>(nanoseconds) / 1e9;
}
}//namespace dvs
} // namespace dvs
/// Sensor that produce Dynamic Vision Events
UCLASS()
@ -56,22 +56,22 @@ protected:
ADVSCamera::DVSEventArray simulation (float DeltaTime);
private:
//! @return Sample from normal distribution (real-valued).
/// @return Sample from normal distribution (real-valued).
template<typename T> T sampleNormalDistribution( bool deterministic, T mean, T sigma);
private:
/** Images containing last (current) and previous image **/
/// Images containing last (current) and previous image
TArray<float> last_image, prev_image;
/** Image containing the last reference vaklue to trigger event **/
/// Image containing the last reference vaklue to trigger event
TArray<float> ref_values;
/** Image containing time of last event in seconds **/
/// Image containing time of last event in seconds
TArray<double> last_event_timestamp;
/** Current time in nanoseconds **/
/// Current time in nanoseconds
std::int64_t current_time;
/** DVS simulation configuration **/
/// DVS simulation configuration
dvs::Config config;
};