Merge branch 'master' into update_carla_settings

This commit is contained in:
Aidan Clear 2019-03-13 19:24:30 +01:00 committed by GitHub
commit 01bbdc54fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
33 changed files with 356 additions and 144 deletions

View File

@ -1,5 +1,6 @@
## Latest Changes
* Allow user to disable rendering and set the server timeout from the command line
* Add timestamp to SensorData
* Allow usage of hostname for carla::Client and resolve them to IP address
* Added `map.transform_to_geolocation` to transform Location to GNSS GeoLocation
* Added `id` property to waypoints, uniquely identifying waypoints up to half centimetre precision

View File

@ -30,10 +30,13 @@ sensor.listen(lambda data: do_something(data))
```
Note that each sensor has a different set of attributes and produces different
type of data. However, the data produced by a sensor comes always tagged with a
**frame number** and a **transform**. The frame number is used to identify the
frame at which the measurement took place, the transform gives you the
transformation in world coordinates of the sensor at that same frame.
type of data. However, the data produced by a sensor comes always tagged with:
| Sensor data attribute | Type | Description |
| --------------------- | ------ | ----------- |
| `frame_number` | int | Frame number when the measurement took place |
| `timestamp` | double | Timestamp of the measurement in simulation seconds since the beginning of the epispode |
| `transform` | carla.Transform | Transform in world coordinates of the sensor at the time of the measurement |
Most sensor data objects, like images and lidar measurements, have a function
for saving the measurements to disk.
@ -81,7 +84,8 @@ objects.
| Sensor data attribute | Type | Description |
| --------------------- | ---- | ----------- |
| `frame_number` | int | Frame count when the measurement took place |
| `frame_number` | int | Frame number when the measurement took place |
| `timestamp` | double | Timestamp of the measurement in simulation seconds since the beginning of the epispode |
| `transform` | carla.Transform | Transform in world coordinates of the sensor at the time of the measurement |
| `width` | int | Image width in pixels |
| `height` | int | Image height in pixels |
@ -108,7 +112,8 @@ objects.
| Sensor data attribute | Type | Description |
| --------------------- | ---- | ----------- |
| `frame_number` | int | Frame count when the measurement took place |
| `frame_number` | int | Frame number when the measurement took place |
| `timestamp` | double | Timestamp of the measurement in simulation seconds since the beginning of the epispode |
| `transform` | carla.Transform | Transform in world coordinates of the sensor at the time of the measurement |
| `width` | int | Image width in pixels |
| `height` | int | Image height in pixels |
@ -146,7 +151,8 @@ objects.
| Sensor data attribute | Type | Description |
| --------------------- | ---- | ----------- |
| `frame_number` | int | Frame count when the measurement took place |
| `frame_number` | int | Frame number when the measurement took place |
| `timestamp` | double | Timestamp of the measurement in simulation seconds since the beginning of the epispode |
| `transform` | carla.Transform | Transform in world coordinates of the sensor at the time of the measurement |
| `width` | int | Image width in pixels |
| `height` | int | Image height in pixels |
@ -213,7 +219,8 @@ objects.
| Sensor data attribute | Type | Description |
| -------------------------- | ---------- | ----------- |
| `frame_number` | int | Frame count when the measurement took place |
| `frame_number` | int | Frame number when the measurement took place |
| `timestamp` | double | Timestamp of the measurement in simulation seconds since the beginning of the epispode |
| `transform` | carla.Transform | Transform in world coordinates of the sensor at the time of the measurement |
| `horizontal_angle` | float | Angle in XY plane of the lidar this frame (in degrees) |
| `channels` | int | Number of channels (lasers) of the lidar |
@ -251,7 +258,8 @@ object for each collision registered
| Sensor data attribute | Type | Description |
| ---------------------- | ----------- | ----------- |
| `frame_number` | int | Frame count when the measurement took place |
| `frame_number` | int | Frame number when the measurement took place |
| `timestamp` | double | Timestamp of the measurement in simulation seconds since the beginning of the epispode |
| `transform` | carla.Transform | Transform in world coordinates of the sensor at the time of the measurement |
| `actor` | carla.Actor | Actor that measured the collision ("self" actor) |
| `other_actor` | carla.Actor | Actor against whom we collide |
@ -282,7 +290,8 @@ object for each lane marking crossed by the actor
| Sensor data attribute | Type | Description |
| ----------------------- | ----------- | ----------- |
| `frame_number` | int | Frame count when the measurement took place |
| `frame_number` | int | Frame number when the measurement took place |
| `timestamp` | double | Timestamp of the measurement in simulation seconds since the beginning of the epispode |
| `transform` | carla.Transform | Transform in world coordinates of the sensor at the time of the measurement |
| `actor` | carla.Actor | Actor that invaded another lane ("self" actor) |
| `crossed_lane_markings` | carla.LaneMarking list | List of lane markings that have been crossed |
@ -300,7 +309,8 @@ objects.
| Sensor data attribute | Type | Description |
| ---------------------- | ----------- | ----------- |
| `frame_number` | int | Frame count when the measurement took place |
| `frame_number` | int | Frame number when the measurement took place |
| `timestamp` | double | Timestamp of the measurement in simulation seconds since the beginning of the epispode |
| `transform` | carla.Transform | Transform in world coordinates of the sensor at the time of the measurement |
| `latitude` | double | Latitude position of the actor |
| `longitude` | double | Longitude position of the actor |

View File

@ -159,6 +159,7 @@
## `carla.SensorData`
- `frame_number`
- `timestamp`
- `transform`
## `carla.Image(carla.SensorData)`

View File

@ -1,13 +1,21 @@
cmake_minimum_required(VERSION 3.5.1)
project(libcarla)
message(STATUS "Building ${PROJECT_NAME} version ${CARLA_VERSION}")
option(LIBCARLA_BUILD_DEBUG "Build debug configuration" ON)
option(LIBCARLA_BUILD_RELEASE "Build release configuration" ON)
option(LIBCARLA_BUILD_TEST "Build unit tests" ON)
message(STATUS "Build debug: ${LIBCARLA_BUILD_DEBUG}")
message(STATUS "Build release: ${LIBCARLA_BUILD_RELEASE}")
message(STATUS "Build test: ${LIBCARLA_BUILD_TEST}")
set(libcarla_source_path "${PROJECT_SOURCE_DIR}/../source")
include_directories(${libcarla_source_path})
configure_file(${libcarla_source_path}/carla/Version.h.in ${libcarla_source_path}/carla/Version.h)
if (CARLA_VERSION)
configure_file(${libcarla_source_path}/carla/Version.h.in ${libcarla_source_path}/carla/Version.h)
endif()
if (CMAKE_BUILD_TYPE STREQUAL "Client")
add_subdirectory("client")
@ -18,6 +26,10 @@ else ()
endif ()
# GTest is not compiled on Windows.
if (NOT WIN32)
if ((LIBCARLA_BUILD_TEST) AND (NOT WIN32))
add_subdirectory("test")
endif()
unset(LIBCARLA_BUILD_TEST CACHE)
unset(LIBCARLA_BUILD_RELEASE CACHE)
unset(LIBCARLA_BUILD_DEBUG CACHE)

View File

@ -84,11 +84,9 @@ file(GLOB libcarla_carla_pointcloud_sources
set(libcarla_sources "${libcarla_sources};${libcarla_carla_pointcloud_sources}")
install(FILES ${libcarla_carla_pointcloud_sources} DESTINATION include/carla/pointcloud)
file(GLOB libcarla_carla_profiler_sources
"${libcarla_source_path}/carla/profiler/*.cpp"
file(GLOB libcarla_carla_profiler_headers
"${libcarla_source_path}/carla/profiler/*.h")
set(libcarla_sources "${libcarla_sources};${libcarla_carla_profiler_sources}")
install(FILES ${libcarla_carla_profiler_sources} DESTINATION include/carla/profiler)
install(FILES ${libcarla_carla_profiler_headers} DESTINATION include/carla/profiler)
file(GLOB libcarla_carla_road_sources
"${libcarla_source_path}/carla/road/*.cpp"
@ -165,23 +163,35 @@ install(FILES ${libcarla_moodycamel_sources} DESTINATION include/moodycamel)
# Create targets for debug and release in the same build type.
# ==============================================================================
foreach(target carla_client_debug carla_client)
add_library(${target} STATIC ${libcarla_sources})
if (LIBCARLA_BUILD_RELEASE)
target_include_directories(${target} PRIVATE
add_library(carla_client STATIC ${libcarla_sources})
target_include_directories(carla_client PRIVATE
"${BOOST_INCLUDE_PATH}"
"${RPCLIB_INCLUDE_PATH}")
install(TARGETS ${target} DESTINATION lib)
endforeach(target)
install(TARGETS carla_client DESTINATION lib)
# Specific options for debug.
set_target_properties(carla_client_debug PROPERTIES COMPILE_FLAGS ${CMAKE_CXX_FLAGS_DEBUG})
target_compile_definitions(carla_client_debug PUBLIC -DBOOST_ASIO_ENABLE_BUFFER_DEBUGGING)
if (WIN32) # @todo Fix PythonAPI build on Windows.
set_target_properties(carla_client PROPERTIES COMPILE_FLAGS ${CMAKE_CXX_FLAGS_RELEASE})
else ()
set_target_properties(carla_client PROPERTIES COMPILE_FLAGS ${CMAKE_CXX_FLAGS_RELEASE_CLIENT})
endif (WIN32)
# Specific options for release.
if (WIN32) # @todo Fix PythonAPI build on Windows.
set_target_properties(carla_client PROPERTIES COMPILE_FLAGS ${CMAKE_CXX_FLAGS_RELEASE})
else ()
set_target_properties(carla_client PROPERTIES COMPILE_FLAGS ${CMAKE_CXX_FLAGS_RELEASE_CLIENT})
endif (WIN32)
endif()
if (LIBCARLA_BUILD_DEBUG)
add_library(carla_client_debug STATIC ${libcarla_sources})
target_include_directories(carla_client_debug PRIVATE
"${BOOST_INCLUDE_PATH}"
"${RPCLIB_INCLUDE_PATH}")
install(TARGETS carla_client_debug DESTINATION lib)
set_target_properties(carla_client_debug PROPERTIES COMPILE_FLAGS ${CMAKE_CXX_FLAGS_DEBUG})
target_compile_definitions(carla_client_debug PUBLIC -DBOOST_ASIO_ENABLE_BUFFER_DEBUGGING)
endif()

View File

@ -107,20 +107,35 @@ file(GLOB libcarla_server_sources
"${libcarla_source_path}/carla/streaming/detail/tcp/*.h"
"${libcarla_source_path}/carla/streaming/low_level/*.h")
# ==============================================================================
# Create targets for debug and release in the same build type.
foreach(target carla_server_debug carla_server)
add_library(${target} STATIC ${libcarla_server_sources})
# ==============================================================================
target_include_directories(${target} PRIVATE
if (LIBCARLA_BUILD_RELEASE)
add_library(carla_server STATIC ${libcarla_server_sources})
target_include_directories(carla_server PRIVATE
"${BOOST_INCLUDE_PATH}"
"${RPCLIB_INCLUDE_PATH}")
install(TARGETS ${target} DESTINATION lib)
endforeach(target)
install(TARGETS carla_server DESTINATION lib OPTIONAL)
# Specific options for debug.
set_target_properties(carla_server_debug PROPERTIES COMPILE_FLAGS ${CMAKE_CXX_FLAGS_DEBUG})
target_compile_definitions(carla_server_debug PUBLIC -DBOOST_ASIO_ENABLE_BUFFER_DEBUGGING)
set_target_properties(carla_server PROPERTIES COMPILE_FLAGS ${CMAKE_CXX_FLAGS_RELEASE})
# Specific options for release.
set_target_properties(carla_server PROPERTIES COMPILE_FLAGS ${CMAKE_CXX_FLAGS_RELEASE})
endif()
if (LIBCARLA_BUILD_DEBUG)
add_library(carla_server_debug STATIC ${libcarla_server_sources})
target_include_directories(carla_server_debug PRIVATE
"${BOOST_INCLUDE_PATH}"
"${RPCLIB_INCLUDE_PATH}")
install(TARGETS carla_server_debug DESTINATION lib OPTIONAL)
set_target_properties(carla_server_debug PROPERTIES COMPILE_FLAGS ${CMAKE_CXX_FLAGS_DEBUG})
target_compile_definitions(carla_server_debug PUBLIC -DBOOST_ASIO_ENABLE_BUFFER_DEBUGGING)
endif()

View File

@ -23,38 +23,51 @@ file(GLOB libcarla_test_sources
file(GLOB libcarla_test_client_sources "")
if (LIBCARLA_BUILD_DEBUG)
list(APPEND build_targets libcarla_test_${carla_config}_debug)
endif()
if (LIBCARLA_BUILD_RELEASE)
list(APPEND build_targets libcarla_test_${carla_config}_release)
endif()
# Create targets for debug and release in the same build type.
foreach(target libcarla_test_${carla_config}_debug libcarla_test_${carla_config}_release)
add_executable(${target} ${libcarla_test_sources})
foreach(target ${build_targets})
target_compile_definitions(${target} PUBLIC
-DLIBCARLA_ENABLE_PROFILER
-DLIBCARLA_WITH_GTEST)
add_executable(${target} ${libcarla_test_sources})
target_include_directories(${target} PRIVATE
"${BOOST_INCLUDE_PATH}"
"${RPCLIB_INCLUDE_PATH}"
"${GTEST_INCLUDE_PATH}"
"${libcarla_source_path}/test")
target_compile_definitions(${target} PUBLIC
-DLIBCARLA_ENABLE_PROFILER
-DLIBCARLA_WITH_GTEST)
if (WIN32)
target_link_libraries(${target} "gtest_main.lib")
target_link_libraries(${target} "gtest.lib")
target_link_libraries(${target} "rpc.lib")
else()
target_link_libraries(${target} "-lrpc")
target_link_libraries(${target} "-lgtest_main")
target_link_libraries(${target} "-lgtest")
endif()
target_include_directories(${target} PRIVATE
"${BOOST_INCLUDE_PATH}"
"${RPCLIB_INCLUDE_PATH}"
"${GTEST_INCLUDE_PATH}"
"${libcarla_source_path}/test")
install(TARGETS ${target} DESTINATION test)
if (WIN32)
target_link_libraries(${target} "gtest_main.lib")
target_link_libraries(${target} "gtest.lib")
target_link_libraries(${target} "rpc.lib")
else()
target_link_libraries(${target} "-lrpc")
target_link_libraries(${target} "-lgtest_main")
target_link_libraries(${target} "-lgtest")
endif()
install(TARGETS ${target} DESTINATION test OPTIONAL)
endforeach(target)
# Specific options for debug.
set_target_properties(libcarla_test_${carla_config}_debug PROPERTIES COMPILE_FLAGS ${CMAKE_CXX_FLAGS_DEBUG})
target_link_libraries(libcarla_test_${carla_config}_debug "carla_${carla_config}_debug")
target_compile_definitions(libcarla_test_${carla_config}_debug PUBLIC -DBOOST_ASIO_ENABLE_BUFFER_DEBUGGING)
if (LIBCARLA_BUILD_DEBUG)
# Specific options for debug.
set_target_properties(libcarla_test_${carla_config}_debug PROPERTIES COMPILE_FLAGS ${CMAKE_CXX_FLAGS_DEBUG})
target_link_libraries(libcarla_test_${carla_config}_debug "carla_${carla_config}_debug")
target_compile_definitions(libcarla_test_${carla_config}_debug PUBLIC -DBOOST_ASIO_ENABLE_BUFFER_DEBUGGING)
endif()
# Specific options for release.
set_target_properties(libcarla_test_${carla_config}_release PROPERTIES COMPILE_FLAGS ${CMAKE_CXX_FLAGS_RELEASE})
target_link_libraries(libcarla_test_${carla_config}_release "carla_${carla_config}")
if (LIBCARLA_BUILD_RELEASE)
# Specific options for release.
set_target_properties(libcarla_test_${carla_config}_release PROPERTIES COMPILE_FLAGS ${CMAKE_CXX_FLAGS_RELEASE})
target_link_libraries(libcarla_test_${carla_config}_release "carla_${carla_config}")
endif()

View File

@ -6,6 +6,7 @@
#pragma once
#include "carla/Debug.h"
#include "carla/NonCopyable.h"
#include <thread>

View File

@ -55,6 +55,7 @@ namespace client {
try {
return MakeShared<sensor::data::GnssEvent>(
timestamp.frame_count,
timestamp.elapsed_seconds,
GetTransform(),
_geo_reference.Transform(GetLocation()));
} catch (const std::exception &e) {

View File

@ -92,6 +92,7 @@ namespace client {
nullptr :
MakeShared<sensor::data::LaneInvasionEvent>(
timestamp.frame_count,
timestamp.elapsed_seconds,
_vehicle->GetTransform(),
_vehicle,
crossed_lanes);

View File

@ -9,7 +9,6 @@
#include "carla/Debug.h"
#include "carla/Memory.h"
#include "carla/NonCopyable.h"
#include "carla/Version.h"
#include "carla/client/Actor.h"
#include "carla/client/GarbageCollectionPolicy.h"
#include "carla/client/TrafficLight.h"

View File

@ -37,6 +37,11 @@ namespace sensor {
return GetHeader().frame_number;
}
/// Timestamp when the data was generated.
double GetTimestamp() const {
return GetHeader().timestamp;
}
/// Sensor's transform when the data was generated.
const rpc::Transform &GetSensorTransform() const {
return GetHeader().sensor_transform;

View File

@ -23,12 +23,13 @@ namespace sensor {
private NonCopyable {
protected:
SensorData(size_t frame_number, const rpc::Transform &sensor_transform)
SensorData(size_t frame_number, double timestamp, const rpc::Transform &sensor_transform)
: _frame_number(frame_number),
_timestamp(timestamp),
_sensor_transform(sensor_transform) {}
explicit SensorData(const RawData &data)
: SensorData(data.GetFrameNumber(), data.GetSensorTransform()) {}
: SensorData(data.GetFrameNumber(), data.GetTimestamp(), data.GetSensorTransform()) {}
public:
@ -39,6 +40,11 @@ namespace sensor {
return _frame_number;
}
/// Time the data was generated.
double GetTimestamp() const {
return _timestamp;
}
/// Sensor's transform when the data was generated.
const rpc::Transform &GetSensorTransform() const {
return _sensor_transform;
@ -58,6 +64,8 @@ namespace sensor {
const size_t _frame_number;
const double _timestamp;
const rpc::Transform _sensor_transform;
};

View File

@ -18,9 +18,10 @@ namespace data {
explicit GnssEvent(
size_t frame_number,
double timestamp,
const rpc::Transform &sensor_transform,
const geom::GeoLocation &geo_location)
: SensorData(frame_number, sensor_transform),
: SensorData(frame_number, timestamp, sensor_transform),
_geo_location(geo_location) {}
const geom::GeoLocation &GetGeoLocation() const {

View File

@ -23,10 +23,11 @@ namespace data {
explicit LaneInvasionEvent(
size_t frame_number,
double timestamp,
const rpc::Transform &sensor_transform,
SharedPtr<client::Actor> self_actor,
std::vector<LaneMarking> crossed_lane_markings)
: SensorData(frame_number, sensor_transform),
: SensorData(frame_number, timestamp, sensor_transform),
_self_actor(std::move(self_actor)),
_crossed_lane_markings(std::move(crossed_lane_markings)) {}

View File

@ -13,7 +13,7 @@ namespace sensor {
namespace s11n {
static_assert(
SensorHeaderSerializer::header_offset == 2u * 8u + 6u * 4u,
SensorHeaderSerializer::header_offset == 3u * 8u + 6u * 4u,
"Header size missmatch");
static Buffer PopBufferFromPool() {
@ -24,10 +24,12 @@ namespace s11n {
Buffer SensorHeaderSerializer::Serialize(
const uint64_t index,
const uint64_t frame,
double timestamp,
const rpc::Transform transform) {
Header h;
h.sensor_type = index;
h.frame_number = frame;
h.timestamp = timestamp;
h.sensor_transform = transform;
auto buffer = PopBufferFromPool();
buffer.copy_from(reinterpret_cast<const unsigned char *>(&h), sizeof(h));

View File

@ -21,13 +21,14 @@ namespace s11n {
struct Header {
uint64_t sensor_type;
uint64_t frame_number;
double timestamp;
rpc::Transform sensor_transform;
};
#pragma pack(pop)
constexpr static auto header_offset = sizeof(Header);
static Buffer Serialize(uint64_t index, uint64_t frame, rpc::Transform transform);
static Buffer Serialize(uint64_t index, uint64_t frame, double timestamp, rpc::Transform transform);
static const Header &Deserialize(const Buffer &message) {
return *reinterpret_cast<const Header *>(message.data());

View File

@ -38,8 +38,7 @@ def get_libcarla_extensions():
os.path.join(pwd, 'dependencies/lib', pylib)]
extra_compile_args = [
'-fPIC', '-std=c++14', '-Wno-missing-braces',
'-DBOOST_ERROR_CODE_HEADER_ONLY', '-DLIBCARLA_WITH_PYTHON_SUPPORT',
'-DLIBCARLA_ENABLE_LIFETIME_PROFILER',
'-DBOOST_ERROR_CODE_HEADER_ONLY', '-DLIBCARLA_WITH_PYTHON_SUPPORT'
]
if 'TRAVIS' in os.environ and os.environ['TRAVIS'] == 'true':
print('Travis CI build detected: disabling PNG support.')

View File

@ -28,6 +28,7 @@ namespace data {
std::ostream &operator<<(std::ostream &out, const Image &image) {
out << "Image(frame=" << image.GetFrameNumber()
<< ", timestamp=" << image.GetTimestamp()
<< ", size=" << image.GetWidth() << 'x' << image.GetHeight()
<< ')';
return out;
@ -35,6 +36,7 @@ namespace data {
std::ostream &operator<<(std::ostream &out, const LidarMeasurement &meas) {
out << "LidarMeasurement(frame=" << meas.GetFrameNumber()
<< ", timestamp=" << meas.GetTimestamp()
<< ", number_of_points=" << meas.size()
<< ')';
return out;
@ -42,6 +44,7 @@ namespace data {
std::ostream &operator<<(std::ostream &out, const CollisionEvent &meas) {
out << "CollisionEvent(frame=" << meas.GetFrameNumber()
<< ", timestamp=" << meas.GetTimestamp()
<< ", other_actor=" << meas.GetOtherActor()
<< ')';
return out;
@ -49,18 +52,22 @@ namespace data {
std::ostream &operator<<(std::ostream &out, const ObstacleDetectionEvent &meas) {
out << "ObstacleDetectionEvent(frame=" << meas.GetFrameNumber()
<< ", timestamp=" << meas.GetTimestamp()
<< ", other_actor=" << meas.GetOtherActor()
<< ')';
return out;
}
std::ostream &operator<<(std::ostream &out, const LaneInvasionEvent &meas) {
out << "LaneInvasionEvent(frame=" << meas.GetFrameNumber() << ')';
out << "LaneInvasionEvent(frame=" << meas.GetFrameNumber()
<< ", timestamp=" << meas.GetTimestamp()
<< ')';
return out;
}
std::ostream &operator<<(std::ostream &out, const GnssEvent &meas) {
out << "GnssEvent(frame=" << meas.GetFrameNumber()
<< ", timestamp=" << meas.GetTimestamp()
<< ", lat=" << meas.GetLatitude()
<< ", lon=" << meas.GetLongitude()
<< ", alt=" << meas.GetAltitude()
@ -156,6 +163,7 @@ void export_sensor_data() {
class_<cs::SensorData, boost::noncopyable, boost::shared_ptr<cs::SensorData>>("SensorData", no_init)
.add_property("frame_number", &cs::SensorData::GetFrameNumber)
.add_property("timestamp", &cs::SensorData::GetTimestamp)
.add_property("transform", CALL_RETURNING_COPY(cs::SensorData, GetSensorTransform))
;

View File

@ -63,7 +63,7 @@ private:
/// @pre This functions needs to be called in the game-thread.
template <typename SensorT>
explicit FAsyncDataStreamTmpl(const SensorT &InSensor, StreamType InStream);
explicit FAsyncDataStreamTmpl(const SensorT &InSensor, float Timepoint, StreamType InStream);
StreamType Stream;
@ -95,13 +95,15 @@ template <typename T>
template <typename SensorT>
inline FAsyncDataStreamTmpl<T>::FAsyncDataStreamTmpl(
const SensorT &Sensor,
float Timepoint,
StreamType InStream)
: Stream(std::move(InStream)),
Header([&Sensor]() {
Header([&Sensor, Timepoint]() {
check(IsInGameThread());
using Serializer = carla::sensor::s11n::SensorHeaderSerializer;
return Serializer::Serialize(
carla::sensor::SensorRegistry::template get<SensorT*>::index,
GFrameCounter,
Timepoint,
Sensor.GetActorTransform());
}()) {}

View File

@ -62,7 +62,7 @@ void ACollisionSensor::OnCollisionEvent(
{
constexpr float TO_METERS = 1e-2;
NormalImpulse *= TO_METERS;
GetDataStream(*this).Send(
GetDataStream(*this, Actor->GetWorld()->GetTimeSeconds()).Send(
*this,
Episode->SerializeActor(Episode->FindOrFakeActor(Actor)),
Episode->SerializeActor(Episode->FindOrFakeActor(OtherActor)),

View File

@ -37,10 +37,10 @@ public:
///
/// @pre This functions needs to be called in the game-thread.
template <typename SensorT>
auto MakeAsyncDataStream(const SensorT &Sensor)
auto MakeAsyncDataStream(const SensorT &Sensor, float Timestamp)
{
check(Stream.has_value());
return FAsyncDataStreamTmpl<T>{Sensor, *Stream};
return FAsyncDataStreamTmpl<T>{Sensor, Timestamp, *Stream};
}
/// Return the token that allows subscribing to this stream.

View File

@ -134,7 +134,7 @@ void AObstacleDetectionSensor::Tick(float DeltaSeconds)
if (isHitReturned)
{
OnObstacleDetectionEvent(this, HitOut.Actor.Get(), HitOut.Distance, HitOut);
OnObstacleDetectionEvent(this, HitOut.Actor.Get(), HitOut.Distance, HitOut, currentWorld->GetTimeSeconds());
}
}
@ -142,11 +142,12 @@ void AObstacleDetectionSensor::OnObstacleDetectionEvent(
AActor *Actor,
AActor *OtherActor,
float HitDistance,
const FHitResult &Hit)
const FHitResult &Hit,
float Timestamp)
{
if ((Episode != nullptr) && (Actor != nullptr) && (OtherActor != nullptr))
{
GetDataStream(*this).Send(*this,
GetDataStream(*this, Timestamp).Send(*this,
Episode->SerializeActor(Episode->FindOrFakeActor(Actor)),
Episode->SerializeActor(Episode->FindOrFakeActor(OtherActor)),
HitRadius);

View File

@ -38,7 +38,8 @@ private:
AActor *Actor,
AActor *OtherActor,
float Distance,
const FHitResult &Hit);
const FHitResult &Hit,
float Timestamp);
UPROPERTY()
const UCarlaEpisode *Episode = nullptr;

View File

@ -87,7 +87,7 @@ void FPixelReader::SendPixelsInRenderThread(TSensor &Sensor)
// First we create the message header (needs to be created in the
// game-thread).
auto AsyncStream = Sensor.GetDataStream(Sensor);
auto AsyncStream = Sensor.GetDataStream(Sensor, Sensor.GetWorld()->GetTimeSeconds());
// We need a shared ptr here because UE4 macros do not move the arguments -_-
auto StreamPtr = std::make_shared<decltype(AsyncStream)>(std::move(AsyncStream));

View File

@ -69,7 +69,7 @@ void ARayCastLidar::Tick(const float DeltaTime)
ReadPoints(DeltaTime);
auto DataStream = GetDataStream(*this);
auto DataStream = GetDataStream(*this, GetWorld()->GetTimeSeconds());
DataStream.Send(*this, LidarMeasurement, DataStream.PopBufferFromPool());
}

View File

@ -47,9 +47,9 @@ protected:
/// You need to provide a reference to self, this is necessary for template
/// deduction.
template <typename SensorT>
FAsyncDataStream GetDataStream(const SensorT &Self)
FAsyncDataStream GetDataStream(const SensorT &Self, float Timestamp)
{
return Stream.MakeAsyncDataStream(Self);
return Stream.MakeAsyncDataStream(Self, Timestamp);
}
private:

View File

@ -150,7 +150,7 @@ static carla::Buffer FWorldObserver_Serialize(
void FWorldObserver::BroadcastTick(const UCarlaEpisode &Episode, float DeltaSeconds)
{
auto AsyncStream = Stream.MakeAsyncDataStream(*this);
auto AsyncStream = Stream.MakeAsyncDataStream(*this, Episode.GetWorld()->GetTimeSeconds());
auto buffer = FWorldObserver_Serialize(
AsyncStream.PopBufferFromPool(),

View File

@ -8,13 +8,34 @@ source $(dirname "$0")/Environment.sh
DOC_STRING="Build LibCarla."
USAGE_STRING="Usage: $0 [-h|--help] [--rebuild] [--server] [--client] [--clean]"
USAGE_STRING=$(cat <<- END
Usage: $0 [-h|--help]
Choose one or more build configurations
[--server] Build server-side configuration.
[--client] Build client-side configuration.
and choose one or more build options
[--debug] Build debug targets.
[--release] Build release targets.
Other commands
[--clean] Clean intermediate files.
[--rebuild] Clean and rebuild both configurations.
END
)
REMOVE_INTERMEDIATE=false
BUILD_SERVER=false
BUILD_CLIENT=false
BUILD_OPTION_DEBUG=false
BUILD_OPTION_RELEASE=false
BUILD_OPTION_DUMMY=false
OPTS=`getopt -o h --long help,rebuild,server,client,clean -n 'parse-options' -- "$@"`
OPTS=`getopt -o h --long help,rebuild,server,client,clean,debug,release -n 'parse-options' -- "$@"`
if [ $? != 0 ] ; then echo "$USAGE_STRING" ; exit 2 ; fi
@ -26,6 +47,8 @@ while true; do
REMOVE_INTERMEDIATE=true;
BUILD_SERVER=true;
BUILD_CLIENT=true;
BUILD_OPTION_DEBUG=true;
BUILD_OPTION_RELEASE=true;
shift ;;
--server )
BUILD_SERVER=true;
@ -35,6 +58,13 @@ while true; do
shift ;;
--clean )
REMOVE_INTERMEDIATE=true;
BUILD_OPTION_DUMMY=true;
shift ;;
--debug )
BUILD_OPTION_DEBUG=true;
shift ;;
--release )
BUILD_OPTION_RELEASE=true;
shift ;;
-h | --help )
echo "$DOC_STRING"
@ -50,6 +80,10 @@ if ! { ${REMOVE_INTERMEDIATE} || ${BUILD_SERVER} || ${BUILD_CLIENT}; }; then
fatal_error "Nothing selected to be done."
fi
if ! { ${BUILD_OPTION_DUMMY} || ${BUILD_OPTION_DEBUG} || ${BUILD_OPTION_RELEASE} ; }; then
fatal_error "Choose --debug and/or --release."
fi
# ==============================================================================
# -- Clean intermediate files --------------------------------------------------
# ==============================================================================
@ -58,30 +92,57 @@ if ${REMOVE_INTERMEDIATE} ; then
log "Cleaning intermediate files and folders."
rm -Rf ${LIBCARLA_BUILD_SERVER_FOLDER} ${LIBCARLA_BUILD_CLIENT_FOLDER}
rm -Rf ${LIBCARLA_BUILD_SERVER_FOLDER}* ${LIBCARLA_BUILD_CLIENT_FOLDER}*
rm -Rf ${LIBCARLA_INSTALL_SERVER_FOLDER} ${LIBCARLA_INSTALL_CLIENT_FOLDER}
rm -f ${LIBCARLA_ROOT_FOLDER}/source/carla/Version.h
fi
# ==============================================================================
# -- Build Server configuration ------------------------------------------------
# -- Define build function -----------------------------------------------------
# ==============================================================================
if ${BUILD_SERVER} ; then
# Build LibCarla for the given configuration.
#
# usage: build_libcarla {Server,Client} {Debug,Release}
#
function build_libcarla {
log "Building LibCarla \"Server\" configuration."
if [ $1 == Server ] ; then
M_TOOLCHAIN=${LIBCPP_TOOLCHAIN_FILE}
M_BUILD_FOLDER=${LIBCARLA_BUILD_SERVER_FOLDER}.$(echo "$2" | tr '[:upper:]' '[:lower:]')
M_INSTALL_FOLDER=${LIBCARLA_INSTALL_SERVER_FOLDER}
elif [ $1 == Client ] ; then
M_TOOLCHAIN=${LIBSTDCPP_TOOLCHAIN_FILE}
M_BUILD_FOLDER=${LIBCARLA_BUILD_CLIENT_FOLDER}.$(echo "$2" | tr '[:upper:]' '[:lower:]')
M_INSTALL_FOLDER=${LIBCARLA_INSTALL_CLIENT_FOLDER}
else
fatal_error "Invalid build configuration \"$1\""
fi
mkdir -p ${LIBCARLA_BUILD_SERVER_FOLDER}
pushd "${LIBCARLA_BUILD_SERVER_FOLDER}" >/dev/null
if [ $2 == Debug ] ; then
M_DEBUG=ON
M_RELEASE=OFF
elif [ $2 == Release ] ; then
M_DEBUG=OFF
M_RELEASE=ON
else
fatal_error "Invalid build option \"$2\""
fi
log "Building LibCarla \"$1.$2\" configuration."
mkdir -p ${M_BUILD_FOLDER}
pushd "${M_BUILD_FOLDER}" >/dev/null
if [ ! -f "build.ninja" ]; then
cmake \
-G "Ninja" \
-DCMAKE_BUILD_TYPE=Server \
-DCMAKE_TOOLCHAIN_FILE=${LIBCPP_TOOLCHAIN_FILE} \
-DCMAKE_INSTALL_PREFIX=${LIBCARLA_INSTALL_SERVER_FOLDER} \
-DCMAKE_BUILD_TYPE=$1 \
-DLIBCARLA_BUILD_DEBUG=${M_DEBUG} \
-DLIBCARLA_BUILD_RELEASE=${M_RELEASE} \
-DCMAKE_TOOLCHAIN_FILE=${M_TOOLCHAIN} \
-DCMAKE_INSTALL_PREFIX=${M_INSTALL_FOLDER} \
-DCMAKE_EXPORT_COMPILE_COMMANDS=1 \
${CARLA_ROOT_FOLDER}
@ -92,37 +153,33 @@ if ${BUILD_SERVER} ; then
ninja install | grep -v "Up-to-date:"
popd >/dev/null
}
# ==============================================================================
# -- Build all possible configurations -----------------------------------------
# ==============================================================================
if { ${BUILD_SERVER} && ${BUILD_OPTION_DEBUG}; }; then
build_libcarla Server Debug
fi
# ==============================================================================
# -- Build Client configuration ------------------------------------------------
# ==============================================================================
if { ${BUILD_SERVER} && ${BUILD_OPTION_RELEASE}; }; then
if ${BUILD_CLIENT} ; then
build_libcarla Server Release
log "Building LibCarla \"Client\" configuration."
fi
mkdir -p ${LIBCARLA_BUILD_CLIENT_FOLDER}
pushd "${LIBCARLA_BUILD_CLIENT_FOLDER}" >/dev/null
if { ${BUILD_CLIENT} && ${BUILD_OPTION_DEBUG}; }; then
if [ ! -f "build.ninja" ]; then
build_libcarla Client Debug
cmake \
-G "Ninja" \
-DCMAKE_BUILD_TYPE=Client \
-DCMAKE_TOOLCHAIN_FILE=${LIBSTDCPP_TOOLCHAIN_FILE} \
-DCMAKE_INSTALL_PREFIX=${LIBCARLA_INSTALL_CLIENT_FOLDER} \
-DCMAKE_EXPORT_COMPILE_COMMANDS=1 \
${CARLA_ROOT_FOLDER}
fi
fi
if { ${BUILD_CLIENT} && ${BUILD_OPTION_RELEASE}; }; then
ninja
ninja install | grep -v "Up-to-date:"
popd >/dev/null
build_libcarla Client Release
fi

View File

@ -3,7 +3,7 @@ default: help
help:
@less ${CARLA_BUILD_TOOLS_FOLDER}/Linux.mk.help
launch: LibCarla.server
launch: LibCarla.server.release
@${CARLA_BUILD_TOOLS_FOLDER}/BuildCarlaUE4.sh --build --launch
launch-only:
@ -41,10 +41,10 @@ check: LibCarla PythonAPI
check.LibCarla: LibCarla
@${CARLA_BUILD_TOOLS_FOLDER}/Check.sh --libcarla-debug --libcarla-release $(ARGS)
check.LibCarla.debug: LibCarla
check.LibCarla.debug: LibCarla.debug
@${CARLA_BUILD_TOOLS_FOLDER}/Check.sh --libcarla-debug $(ARGS)
check.LibCarla.release: LibCarla
check.LibCarla.release: LibCarla.release
@${CARLA_BUILD_TOOLS_FOLDER}/Check.sh --libcarla-release $(ARGS)
check.PythonAPI: PythonAPI
@ -56,31 +56,40 @@ check.PythonAPI.2: PythonAPI.2
check.PythonAPI.3: PythonAPI.3
@${CARLA_BUILD_TOOLS_FOLDER}/Check.sh --python-api-3 $(ARGS)
benchmark: LibCarla.server
benchmark: LibCarla.release
@${CARLA_BUILD_TOOLS_FOLDER}/Check.sh --benchmark $(ARGS)
@cat profiler.csv
CarlaUE4Editor: LibCarla.server
CarlaUE4Editor: LibCarla.server.release
@${CARLA_BUILD_TOOLS_FOLDER}/BuildCarlaUE4.sh --build
.PHONY: PythonAPI
PythonAPI: LibCarla.client
PythonAPI: LibCarla.client.release
@${CARLA_BUILD_TOOLS_FOLDER}/BuildPythonAPI.sh --py2 --py3
PythonAPI.2: LibCarla.client
PythonAPI.2: LibCarla.client.release
@${CARLA_BUILD_TOOLS_FOLDER}/BuildPythonAPI.sh --py2
PythonAPI.3: LibCarla.client
PythonAPI.3: LibCarla.client.release
@${CARLA_BUILD_TOOLS_FOLDER}/BuildPythonAPI.sh --py3
.PHONY: LibCarla
LibCarla: LibCarla.server LibCarla.client
LibCarla.server: setup
@${CARLA_BUILD_TOOLS_FOLDER}/BuildLibCarla.sh --server
LibCarla.debug: LibCarla.server.debug LibCarla.client.debug
LibCarla.release: LibCarla.server.release LibCarla.client.release
LibCarla.client: setup
@${CARLA_BUILD_TOOLS_FOLDER}/BuildLibCarla.sh --client
LibCarla.server: LibCarla.server.debug LibCarla.server.release
LibCarla.server.debug: setup
@${CARLA_BUILD_TOOLS_FOLDER}/BuildLibCarla.sh --server --debug
LibCarla.server.release: setup
@${CARLA_BUILD_TOOLS_FOLDER}/BuildLibCarla.sh --server --release
LibCarla.client: LibCarla.client.debug LibCarla.client.release
LibCarla.client.debug: setup
@${CARLA_BUILD_TOOLS_FOLDER}/BuildLibCarla.sh --client --debug
LibCarla.client.release: setup
@${CARLA_BUILD_TOOLS_FOLDER}/BuildLibCarla.sh --client --release
setup:
@${CARLA_BUILD_TOOLS_FOLDER}/Setup.sh

View File

@ -73,7 +73,7 @@ for developers:
Build and package the Python API module for Python 2 and/or 3.
LibCarla(.server|.client):
LibCarla(.server|.client)(.debug|.release):
Build LibCarla, "Server" and/or "Client" configurations.

View File

@ -280,6 +280,21 @@ fi
unset GTEST_BASENAME
# ==============================================================================
# -- Generate Version.h --------------------------------------------------------
# ==============================================================================
CARLA_VERSION=$(get_carla_version)
log "CARLA version ${CARLA_VERSION}."
VERSION_H_FILE=${LIBCARLA_ROOT_FOLDER}/source/carla/Version.h
VERSION_H_FILE_GEN=${CARLA_BUILD_FOLDER}/Version.h
sed -e "s|\${CARLA_VERSION}|${CARLA_VERSION}|g" ${VERSION_H_FILE}.in > ${VERSION_H_FILE_GEN}
move_if_changed "${VERSION_H_FILE_GEN}" "${VERSION_H_FILE}"
# ==============================================================================
# -- Generate CMake toolchains and config --------------------------------------
# ==============================================================================
@ -298,7 +313,7 @@ set(CMAKE_CXX_FLAGS "\${CMAKE_CXX_FLAGS} -std=c++14 -pthread -fPIC" CACHE STRING
set(CMAKE_CXX_FLAGS "\${CMAKE_CXX_FLAGS} -Werror -Wall -Wextra" CACHE STRING "" FORCE)
# @todo These flags need to be compatible with setup.py compilation.
set(CMAKE_CXX_FLAGS_RELEASE_CLIENT "\${CMAKE_CXX_FLAGS_RELEASE} -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -std=c++14 -Wno-missing-braces -DBOOST_ERROR_CODE_HEADER_ONLY -DLIBCARLA_ENABLE_LIFETIME_PROFILER -DLIBCARLA_WITH_PYTHON_SUPPORT" CACHE STRING "" FORCE)
set(CMAKE_CXX_FLAGS_RELEASE_CLIENT "\${CMAKE_CXX_FLAGS_RELEASE} -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -std=c++14 -Wno-missing-braces -DBOOST_ERROR_CODE_HEADER_ONLY -DLIBCARLA_WITH_PYTHON_SUPPORT" CACHE STRING "" FORCE)
EOL
# -- LIBCPP_TOOLCHAIN_FILE -----------------------------------------------------
@ -320,8 +335,6 @@ EOL
cat >${CMAKE_CONFIG_FILE}.gen <<EOL
# Automatically generated by `basename "$0"`
set(CARLA_VERSION $(get_carla_version))
add_definitions(-DBOOST_ERROR_CODE_HEADER_ONLY)
if (CMAKE_BUILD_TYPE STREQUAL "Server")

View File

@ -77,7 +77,7 @@
}
},
{
"name": "CARLA - make LibCarla (Server)",
"name": "CARLA - make LibCarla (Server All)",
"working_dir": "${project_path}/..",
"file_regex": "^../../([^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"syntax": "Packages/Makefile/Make Output.sublime-syntax",
@ -87,7 +87,27 @@
}
},
{
"name": "CARLA - make LibCarla (Client)",
"name": "CARLA - make LibCarla (Server Debug)",
"working_dir": "${project_path}/..",
"file_regex": "^../../([^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"syntax": "Packages/Makefile/Make Output.sublime-syntax",
"linux":
{
"shell_cmd": "CARLA_BUILD_NO_COLOR=true make LibCarla.server.debug"
}
},
{
"name": "CARLA - make LibCarla (Server Release)",
"working_dir": "${project_path}/..",
"file_regex": "^../../([^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"syntax": "Packages/Makefile/Make Output.sublime-syntax",
"linux":
{
"shell_cmd": "CARLA_BUILD_NO_COLOR=true make LibCarla.server.release"
}
},
{
"name": "CARLA - make LibCarla (Client All)",
"working_dir": "${project_path}/..",
"file_regex": "^../../([^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"syntax": "Packages/Makefile/Make Output.sublime-syntax",
@ -96,6 +116,26 @@
"shell_cmd": "CARLA_BUILD_NO_COLOR=true make LibCarla.client"
}
},
{
"name": "CARLA - make LibCarla (Client Debug)",
"working_dir": "${project_path}/..",
"file_regex": "^../../([^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"syntax": "Packages/Makefile/Make Output.sublime-syntax",
"linux":
{
"shell_cmd": "CARLA_BUILD_NO_COLOR=true make LibCarla.client.debug"
}
},
{
"name": "CARLA - make LibCarla (Client Release)",
"working_dir": "${project_path}/..",
"file_regex": "^../../([^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"syntax": "Packages/Makefile/Make Output.sublime-syntax",
"linux":
{
"shell_cmd": "CARLA_BUILD_NO_COLOR=true make LibCarla.client.release"
}
},
{
"name": "CARLA - make PythonAPI (All)",
"working_dir": "${project_path}/..",