From dd0de88fbd631c92466c6b1d7d69909cf2b81e15 Mon Sep 17 00:00:00 2001 From: nsubiron Date: Wed, 3 Oct 2018 11:33:18 +0200 Subject: [PATCH] Add namespaces for road classes and opendrive --- LibCarla/cmake/client/CMakeLists.txt | 164 +++++++++++-------- LibCarla/cmake/server/CMakeLists.txt | 3 + LibCarla/source/carla/{rpc => }/MsgPack.h | 0 LibCarla/source/carla/client/Transform.h | 8 +- LibCarla/source/carla/geom/Location.h | 91 ++++++++++ LibCarla/source/carla/geom/Transform.h | 75 +++++++++ LibCarla/source/carla/opendrive/OpenDrive.h | 26 +++ LibCarla/source/carla/road/Map.h | 19 +++ LibCarla/source/carla/road/MapBuilder.h | 21 +++ LibCarla/source/carla/rpc/ActorAttribute.h | 2 +- LibCarla/source/carla/rpc/ActorDefinition.h | 2 +- LibCarla/source/carla/rpc/ActorDescription.h | 2 +- LibCarla/source/carla/rpc/Location.h | 78 +-------- LibCarla/source/carla/rpc/Transform.h | 62 +------ LibCarla/source/carla/rpc/VehicleControl.h | 2 +- LibCarla/source/carla/streaming/Token.h | 2 +- PythonAPI/source/libcarla/Transform.cpp | 32 ++-- 17 files changed, 358 insertions(+), 231 deletions(-) rename LibCarla/source/carla/{rpc => }/MsgPack.h (100%) create mode 100644 LibCarla/source/carla/geom/Location.h create mode 100644 LibCarla/source/carla/geom/Transform.h create mode 100644 LibCarla/source/carla/opendrive/OpenDrive.h create mode 100644 LibCarla/source/carla/road/Map.h create mode 100644 LibCarla/source/carla/road/MapBuilder.h diff --git a/LibCarla/cmake/client/CMakeLists.txt b/LibCarla/cmake/client/CMakeLists.txt index 7aae3ea30..9ccfdfffb 100644 --- a/LibCarla/cmake/client/CMakeLists.txt +++ b/LibCarla/cmake/client/CMakeLists.txt @@ -6,21 +6,104 @@ install(DIRECTORY "${RPCLIB_INCLUDE_PATH}/rpc" DESTINATION include) file(GLOB libcarla_carla_rpclib "${RPCLIB_LIB_PATH}/*.*") install(FILES ${libcarla_carla_rpclib} DESTINATION lib) -file(GLOB libcarla_sources - "${libcarla_source_path}/carla/*.h" - "${libcarla_source_path}/carla/*.cpp") +# Install boost headers. -file(GLOB_RECURSE libcarla_client_sources - "${libcarla_source_path}/carla/client/*.h" +install(DIRECTORY "${BOOST_INCLUDE_PATH}/boost" DESTINATION include) + +file(GLOB boost_libraries "${BOOST_LIB_PATH}/*") +install(FILES ${boost_libraries} DESTINATION lib) + +# Add sources. + +file(GLOB libcarla_carla_sources + "${libcarla_source_path}/carla/*.cpp" + "${libcarla_source_path}/carla/*.h") +set(libcarla_sources "${libcarla_sources};${libcarla_carla_sources}") +install(FILES ${libcarla_carla_sources} DESTINATION include/carla) + +file(GLOB libcarla_carla_client_sources "${libcarla_source_path}/carla/client/*.cpp" - "${libcarla_source_path}/carla/rpc/*.h" - "${libcarla_source_path}/carla/rpc/*.cpp" - "${libcarla_source_path}/carla/streaming/*.h" - "${libcarla_source_path}/carla/streaming/*.cpp") + "${libcarla_source_path}/carla/client/*.h") +set(libcarla_sources "${libcarla_sources};${libcarla_carla_client_sources}") +install(FILES ${libcarla_carla_client_sources} DESTINATION include/carla/client) +file(GLOB libcarla_carla_geom_sources + "${libcarla_source_path}/carla/geom/*.cpp" + "${libcarla_source_path}/carla/geom/*.h") +set(libcarla_sources "${libcarla_sources};${libcarla_carla_geom_sources}") +install(FILES ${libcarla_carla_geom_sources} DESTINATION include/carla/geom) + +file(GLOB libcarla_carla_opendrive_sources + "${libcarla_source_path}/carla/opendrive/*.cpp" + "${libcarla_source_path}/carla/opendrive/*.h") +set(libcarla_sources "${libcarla_sources};${libcarla_carla_opendrive_sources}") +install(FILES ${libcarla_carla_opendrive_sources} DESTINATION include/carla/opendrive) + +file(GLOB libcarla_carla_road_sources + "${libcarla_source_path}/carla/road/*.cpp" + "${libcarla_source_path}/carla/road/*.h") +set(libcarla_sources "${libcarla_sources};${libcarla_carla_road_sources}") +install(FILES ${libcarla_carla_road_sources} DESTINATION include/carla/road) + +file(GLOB libcarla_carla_rpc_sources + "${libcarla_source_path}/carla/rpc/*.cpp" + "${libcarla_source_path}/carla/rpc/*.h") +set(libcarla_sources "${libcarla_sources};${libcarla_carla_rpc_sources}") +install(FILES ${libcarla_carla_rpc_sources} DESTINATION include/carla/rpc) + +file(GLOB libcarla_carla_sensor_sources + "${libcarla_source_path}/carla/sensor/*.cpp" + "${libcarla_source_path}/carla/sensor/*.h") +set(libcarla_sources "${libcarla_sources};${libcarla_carla_sensor_sources}") +install(FILES ${libcarla_carla_sensor_sources} DESTINATION include/carla/sensor) + +file(GLOB libcarla_carla_sensor_data_sources + "${libcarla_source_path}/carla/sensor/data/*.cpp" + "${libcarla_source_path}/carla/sensor/data/*.h") +set(libcarla_sources "${libcarla_sources};${libcarla_carla_sensor_data_sources}") +install(FILES ${libcarla_carla_sensor_data_sources} DESTINATION include/carla/sensor/data) + +file(GLOB libcarla_carla_sensor_s11n_sources + "${libcarla_source_path}/carla/sensor/s11n/*.cpp" + "${libcarla_source_path}/carla/sensor/s11n/*.h") +set(libcarla_sources "${libcarla_sources};${libcarla_carla_sensor_s11n_sources}") +install(FILES ${libcarla_carla_sensor_s11n_sources} DESTINATION include/carla/sensor/s11n) + +file(GLOB libcarla_carla_streaming_sources + "${libcarla_source_path}/carla/streaming/*.cpp" + "${libcarla_source_path}/carla/streaming/*.h") +set(libcarla_sources "${libcarla_sources};${libcarla_carla_streaming_sources}") +install(FILES ${libcarla_carla_streaming_sources} DESTINATION include/carla/streaming) + +file(GLOB libcarla_carla_streaming_detail_sources + "${libcarla_source_path}/carla/streaming/detail/*.cpp" + "${libcarla_source_path}/carla/streaming/detail/*.h") +set(libcarla_sources "${libcarla_sources};${libcarla_carla_streaming_detail_sources}") +install(FILES ${libcarla_carla_streaming_detail_sources} DESTINATION include/carla/streaming/detail) + +file(GLOB libcarla_carla_streaming_detail_tcp_sources + "${libcarla_source_path}/carla/streaming/detail/tcp/*.cpp" + "${libcarla_source_path}/carla/streaming/detail/tcp/*.h") +set(libcarla_sources "${libcarla_sources};${libcarla_carla_streaming_detail_tcp_sources}") +install(FILES ${libcarla_carla_streaming_detail_tcp_sources} DESTINATION include/carla/streaming/detail/tcp) + +file(GLOB libcarla_carla_streaming_low_level_sources + "${libcarla_source_path}/carla/streaming/low_level/*.cpp" + "${libcarla_source_path}/carla/streaming/low_level/*.h") +set(libcarla_sources "${libcarla_sources};${libcarla_carla_streaming_low_level_sources}") +install(FILES ${libcarla_carla_streaming_low_level_sources} DESTINATION include/carla/streaming/low_level) + +file(GLOB libcarla_moodycamel_sources + "${libcarla_source_path}/moodycamel/*.h") +set(libcarla_sources "${libcarla_sources};${libcarla_moodycamel_sources}") +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_client_sources} ${libcarla_sources}) + add_library(${target} STATIC ${libcarla_sources}) target_include_directories(${target} PRIVATE "${BOOST_INCLUDE_PATH}" @@ -36,64 +119,3 @@ target_compile_definitions(carla_client_debug PUBLIC -DBOOST_ASIO_ENABLE_BUFFER_ # Specific options for release. set_target_properties(carla_client PROPERTIES COMPILE_FLAGS ${CMAKE_CXX_FLAGS_RELEASE}) - -# Install headers. - -install(DIRECTORY "${BOOST_INCLUDE_PATH}/boost" DESTINATION include) - -file(GLOB boost_libraries "${BOOST_LIB_PATH}/*") -install(FILES ${boost_libraries} DESTINATION lib) - -file(GLOB libcarla_carla_headers - "${libcarla_source_path}/carla/*.cpp" - "${libcarla_source_path}/carla/*.h") -install(FILES ${libcarla_carla_headers} DESTINATION include/carla) - -file(GLOB libcarla_moodycamel_headers - "${libcarla_source_path}/moodycamel/*.h") -install(FILES ${libcarla_moodycamel_headers} DESTINATION include/moodycamel) - -file(GLOB libcarla_carla_client_headers - "${libcarla_source_path}/carla/client/*.cpp" - "${libcarla_source_path}/carla/client/*.h") -install(FILES ${libcarla_carla_client_headers} DESTINATION include/carla/client) - -file(GLOB libcarla_carla_rpc_headers - "${libcarla_source_path}/carla/rpc/*.cpp" - "${libcarla_source_path}/carla/rpc/*.h") -install(FILES ${libcarla_carla_rpc_headers} DESTINATION include/carla/rpc) - -file(GLOB libcarla_carla_sensor_headers - "${libcarla_source_path}/carla/sensor/*.cpp" - "${libcarla_source_path}/carla/sensor/*.h") -install(FILES ${libcarla_carla_sensor_headers} DESTINATION include/carla/sensor) - -file(GLOB libcarla_carla_sensor_data_headers - "${libcarla_source_path}/carla/sensor/data/*.cpp" - "${libcarla_source_path}/carla/sensor/data/*.h") -install(FILES ${libcarla_carla_sensor_data_headers} DESTINATION include/carla/sensor/data) - -file(GLOB libcarla_carla_sensor_s11n_headers - "${libcarla_source_path}/carla/sensor/s11n/*.cpp" - "${libcarla_source_path}/carla/sensor/s11n/*.h") -install(FILES ${libcarla_carla_sensor_s11n_headers} DESTINATION include/carla/sensor/s11n) - -file(GLOB libcarla_carla_streaming_headers - "${libcarla_source_path}/carla/streaming/*.cpp" - "${libcarla_source_path}/carla/streaming/*.h") -install(FILES ${libcarla_carla_streaming_headers} DESTINATION include/carla/streaming) - -file(GLOB libcarla_carla_streaming_detail_headers - "${libcarla_source_path}/carla/streaming/detail/*.cpp" - "${libcarla_source_path}/carla/streaming/detail/*.h") -install(FILES ${libcarla_carla_streaming_detail_headers} DESTINATION include/carla/streaming/detail) - -file(GLOB libcarla_carla_streaming_detail_tcp_headers - "${libcarla_source_path}/carla/streaming/detail/tcp/*.cpp" - "${libcarla_source_path}/carla/streaming/detail/tcp/*.h") -install(FILES ${libcarla_carla_streaming_detail_tcp_headers} DESTINATION include/carla/streaming/detail/tcp) - -file(GLOB libcarla_carla_streaming_low_level_headers - "${libcarla_source_path}/carla/streaming/low_level/*.cpp" - "${libcarla_source_path}/carla/streaming/low_level/*.h") -install(FILES ${libcarla_carla_streaming_low_level_headers} DESTINATION include/carla/streaming/low_level) diff --git a/LibCarla/cmake/server/CMakeLists.txt b/LibCarla/cmake/server/CMakeLists.txt index 4f2db7cd1..420952108 100644 --- a/LibCarla/cmake/server/CMakeLists.txt +++ b/LibCarla/cmake/server/CMakeLists.txt @@ -17,6 +17,9 @@ install(DIRECTORY "${libcarla_source_path}/compiler" DESTINATION include) file(GLOB libcarla_carla_headers "${libcarla_source_path}/carla/*.h") install(FILES ${libcarla_carla_headers} DESTINATION include/carla) +file(GLOB libcarla_carla_geom_headers "${libcarla_source_path}/carla/geom/*.h") +install(FILES ${libcarla_carla_geom_headers} DESTINATION include/carla/geom) + file(GLOB libcarla_carla_rpc_headers "${libcarla_source_path}/carla/rpc/*.h") install(FILES ${libcarla_carla_rpc_headers} DESTINATION include/carla/rpc) diff --git a/LibCarla/source/carla/rpc/MsgPack.h b/LibCarla/source/carla/MsgPack.h similarity index 100% rename from LibCarla/source/carla/rpc/MsgPack.h rename to LibCarla/source/carla/MsgPack.h diff --git a/LibCarla/source/carla/client/Transform.h b/LibCarla/source/carla/client/Transform.h index a1259796d..a7dcd924e 100644 --- a/LibCarla/source/carla/client/Transform.h +++ b/LibCarla/source/carla/client/Transform.h @@ -6,14 +6,14 @@ #pragma once -#include "carla/rpc/Transform.h" +#include "carla/geom/Transform.h" namespace carla { namespace client { - using Location = carla::rpc::Location; - using Rotation = carla::rpc::Rotation; - using Transform = carla::rpc::Transform; + using Location = carla::geom::Location; + using Rotation = carla::geom::Rotation; + using Transform = carla::geom::Transform; } // namespace client } // namespace carla diff --git a/LibCarla/source/carla/geom/Location.h b/LibCarla/source/carla/geom/Location.h new file mode 100644 index 000000000..0ab681256 --- /dev/null +++ b/LibCarla/source/carla/geom/Location.h @@ -0,0 +1,91 @@ +// Copyright (c) 2017 Computer Vision Center (CVC) at the Universitat Autonoma +// de Barcelona (UAB). +// +// This work is licensed under the terms of the MIT license. +// For a copy, see . + +#pragma once + +#include "carla/MsgPack.h" + +#ifdef LIBCARLA_INCLUDED_FROM_UE4 +# include "Math/Vector.h" +#endif // LIBCARLA_INCLUDED_FROM_UE4 + +namespace carla { +namespace geom { + + class Location { + public: + + float x = 0.0f; + float y = 0.0f; + float z = 0.0f; + + Location() = default; + + Location(float ix, float iy, float iz) + : x(ix), + y(iy), + z(iz) {} + + Location &operator+=(const Location &rhs) { + x += rhs.x; + y += rhs.y; + z += rhs.z; + return *this; + } + + friend Location operator+(Location lhs, const Location &rhs) { + lhs += rhs; + return lhs; + } + + Location &operator-=(const Location &rhs) { + x -= rhs.x; + y -= rhs.y; + z -= rhs.z; + return *this; + } + + friend Location operator-(Location lhs, const Location &rhs) { + lhs -= rhs; + return lhs; + } + +#ifdef LIBCARLA_INCLUDED_FROM_UE4 + + Location(const FVector &vector) // from centimeters to meters. + : Location(1e-2f * vector.X, 1e-2f * vector.Y, 1e-2f * vector.Z) {} + + operator FVector() const { + return FVector{1e2f * x, 1e2f * y, 1e2f * z}; // from meters to centimeters. + } + +#endif // LIBCARLA_INCLUDED_FROM_UE4 + + // ========================================================================= + /// @todo The following is copy-pasted from MSGPACK_DEFINE_ARRAY. + /// This is a workaround for an issue in msgpack library. The + /// MSGPACK_DEFINE_ARRAY macro is shadowing our `z` variable. + /// https://github.com/msgpack/msgpack-c/issues/709 + // ========================================================================= + template + void msgpack_pack(Packer& pk) const + { + clmdep_msgpack::type::make_define_array(x, y, z).msgpack_pack(pk); + } + void msgpack_unpack(clmdep_msgpack::object const& o) + { + clmdep_msgpack::type::make_define_array(x, y, z).msgpack_unpack(o); + } + template + void msgpack_object(MSGPACK_OBJECT* o, clmdep_msgpack::zone& sneaky_variable_that_shadows_z) const + { + clmdep_msgpack::type::make_define_array(x, y, z).msgpack_object(o, sneaky_variable_that_shadows_z); + } + // ========================================================================= + }; + +} // namespace geom +} // namespace carla diff --git a/LibCarla/source/carla/geom/Transform.h b/LibCarla/source/carla/geom/Transform.h new file mode 100644 index 000000000..af57cd58f --- /dev/null +++ b/LibCarla/source/carla/geom/Transform.h @@ -0,0 +1,75 @@ +// Copyright (c) 2017 Computer Vision Center (CVC) at the Universitat Autonoma +// de Barcelona (UAB). +// +// This work is licensed under the terms of the MIT license. +// For a copy, see . + +#pragma once + +#include "carla/MsgPack.h" +#include "carla/geom/Location.h" + +#ifdef LIBCARLA_INCLUDED_FROM_UE4 +# include "Transform.h" +#endif // LIBCARLA_INCLUDED_FROM_UE4 + +namespace carla { +namespace geom { + + class Rotation { + public: + + Rotation() = default; + + Rotation(float p, float y, float r) + : pitch(p), + yaw(y), + roll(r) {} + + float pitch = 0.0f; + float yaw = 0.0f; + float roll = 0.0f; + +#ifdef LIBCARLA_INCLUDED_FROM_UE4 + + Rotation(const FRotator &rotator) + : Rotation(rotator.Pitch, rotator.Yaw, rotator.Roll) {} + + operator FRotator() const { + return FRotator{pitch, yaw, roll}; + } + +#endif // LIBCARLA_INCLUDED_FROM_UE4 + + MSGPACK_DEFINE_ARRAY(pitch, yaw, roll); + }; + + class Transform { + public: + + Transform() = default; + + Transform(const Location &in_location, const Rotation &in_rotation) + : location(in_location), + rotation(in_rotation) {} + + Location location; + Rotation rotation; + +#ifdef LIBCARLA_INCLUDED_FROM_UE4 + + Transform(const FTransform &transform) + : Transform(Location(transform.GetLocation()), Rotation(transform.Rotator())) {} + + operator FTransform() const { + const FVector scale{1.0f, 1.0f, 1.0f}; + return FTransform{FRotator(rotation), FVector(location), scale}; + } + +#endif // LIBCARLA_INCLUDED_FROM_UE4 + + MSGPACK_DEFINE_ARRAY(location, rotation); + }; + +} // namespace geom +} // namespace carla diff --git a/LibCarla/source/carla/opendrive/OpenDrive.h b/LibCarla/source/carla/opendrive/OpenDrive.h new file mode 100644 index 000000000..ec803318d --- /dev/null +++ b/LibCarla/source/carla/opendrive/OpenDrive.h @@ -0,0 +1,26 @@ +// Copyright (c) 2017 Computer Vision Center (CVC) at the Universitat Autonoma +// de Barcelona (UAB). +// +// This work is licensed under the terms of the MIT license. +// For a copy, see . + +#pragma once + +#include "carla/road/Map.h" + +#include +#include + +namespace carla { +namespace opendrive { + + class OpenDrive { + public: + + static road::Map Load(std::istream &input); + + static void Dump(const road::Map &map, std::ostream &output); + }; + +} // namespace opendrive +} // namespace carla diff --git a/LibCarla/source/carla/road/Map.h b/LibCarla/source/carla/road/Map.h new file mode 100644 index 000000000..401d842e5 --- /dev/null +++ b/LibCarla/source/carla/road/Map.h @@ -0,0 +1,19 @@ +// Copyright (c) 2017 Computer Vision Center (CVC) at the Universitat Autonoma +// de Barcelona (UAB). +// +// This work is licensed under the terms of the MIT license. +// For a copy, see . + +#pragma once + +namespace carla { +namespace road { + + class Map { + public: + + + }; + +} // namespace road +} // namespace carla diff --git a/LibCarla/source/carla/road/MapBuilder.h b/LibCarla/source/carla/road/MapBuilder.h new file mode 100644 index 000000000..fa55cff24 --- /dev/null +++ b/LibCarla/source/carla/road/MapBuilder.h @@ -0,0 +1,21 @@ +// Copyright (c) 2017 Computer Vision Center (CVC) at the Universitat Autonoma +// de Barcelona (UAB). +// +// This work is licensed under the terms of the MIT license. +// For a copy, see . + +#pragma once + +namespace carla { +namespace road { + + class MapBuilder { + public: + + + + + }; + +} // namespace road +} // namespace carla diff --git a/LibCarla/source/carla/rpc/ActorAttribute.h b/LibCarla/source/carla/rpc/ActorAttribute.h index f20515658..2bf9f9f05 100644 --- a/LibCarla/source/carla/rpc/ActorAttribute.h +++ b/LibCarla/source/carla/rpc/ActorAttribute.h @@ -6,8 +6,8 @@ #pragma once +#include "carla/MsgPack.h" #include "carla/rpc/ActorAttributeType.h" -#include "carla/rpc/MsgPack.h" #include "carla/rpc/String.h" #include diff --git a/LibCarla/source/carla/rpc/ActorDefinition.h b/LibCarla/source/carla/rpc/ActorDefinition.h index 9dd86c365..cac5036cf 100644 --- a/LibCarla/source/carla/rpc/ActorDefinition.h +++ b/LibCarla/source/carla/rpc/ActorDefinition.h @@ -6,8 +6,8 @@ #pragma once +#include "carla/MsgPack.h" #include "carla/rpc/ActorAttribute.h" -#include "carla/rpc/MsgPack.h" #include "carla/rpc/String.h" #include diff --git a/LibCarla/source/carla/rpc/ActorDescription.h b/LibCarla/source/carla/rpc/ActorDescription.h index 21dff5008..84173040d 100644 --- a/LibCarla/source/carla/rpc/ActorDescription.h +++ b/LibCarla/source/carla/rpc/ActorDescription.h @@ -6,8 +6,8 @@ #pragma once +#include "carla/MsgPack.h" #include "carla/rpc/ActorAttribute.h" -#include "carla/rpc/MsgPack.h" #include "carla/rpc/String.h" #include diff --git a/LibCarla/source/carla/rpc/Location.h b/LibCarla/source/carla/rpc/Location.h index 90e82a981..b6de3df51 100644 --- a/LibCarla/source/carla/rpc/Location.h +++ b/LibCarla/source/carla/rpc/Location.h @@ -6,86 +6,12 @@ #pragma once -#include "carla/rpc/MsgPack.h" - -#ifdef LIBCARLA_INCLUDED_FROM_UE4 -# include "Math/Vector.h" -#endif // LIBCARLA_INCLUDED_FROM_UE4 +#include "carla/geom/Location.h" namespace carla { namespace rpc { - class Location { - public: - - float x = 0.0f; - float y = 0.0f; - float z = 0.0f; - - Location() = default; - - Location(float ix, float iy, float iz) - : x(ix), - y(iy), - z(iz) {} - - Location &operator+=(const Location &rhs) { - x += rhs.x; - y += rhs.y; - z += rhs.z; - return *this; - } - - friend Location operator+(Location lhs, const Location &rhs) { - lhs += rhs; - return lhs; - } - - Location &operator-=(const Location &rhs) { - x -= rhs.x; - y -= rhs.y; - z -= rhs.z; - return *this; - } - - friend Location operator-(Location lhs, const Location &rhs) { - lhs -= rhs; - return lhs; - } - -#ifdef LIBCARLA_INCLUDED_FROM_UE4 - - Location(const FVector &vector) // from centimeters to meters. - : Location(1e-2f * vector.X, 1e-2f * vector.Y, 1e-2f * vector.Z) {} - - operator FVector() const { - return FVector{1e2f * x, 1e2f * y, 1e2f * z}; // from meters to centimeters. - } - -#endif // LIBCARLA_INCLUDED_FROM_UE4 - - // ========================================================================= - /// @todo The following is copy-pasted from MSGPACK_DEFINE_ARRAY. - /// This is a workaround for an issue in msgpack library. The - /// MSGPACK_DEFINE_ARRAY macro is shadowing our `z` variable. - /// https://github.com/msgpack/msgpack-c/issues/709 - // ========================================================================= - template - void msgpack_pack(Packer& pk) const - { - clmdep_msgpack::type::make_define_array(x, y, z).msgpack_pack(pk); - } - void msgpack_unpack(clmdep_msgpack::object const& o) - { - clmdep_msgpack::type::make_define_array(x, y, z).msgpack_unpack(o); - } - template - void msgpack_object(MSGPACK_OBJECT* o, clmdep_msgpack::zone& sneaky_variable_that_shadows_z) const - { - clmdep_msgpack::type::make_define_array(x, y, z).msgpack_object(o, sneaky_variable_that_shadows_z); - } - // ========================================================================= - }; + using Location = geom::Location; } // namespace rpc } // namespace carla diff --git a/LibCarla/source/carla/rpc/Transform.h b/LibCarla/source/carla/rpc/Transform.h index 8fe8b1cc7..01584ccb0 100644 --- a/LibCarla/source/carla/rpc/Transform.h +++ b/LibCarla/source/carla/rpc/Transform.h @@ -6,70 +6,14 @@ #pragma once -#include "carla/rpc/Location.h" -#include "carla/rpc/MsgPack.h" - -#ifdef LIBCARLA_INCLUDED_FROM_UE4 -# include "Transform.h" -#endif // LIBCARLA_INCLUDED_FROM_UE4 +#include "carla/geom/Transform.h" namespace carla { namespace rpc { - class Rotation { - public: + using Rotation = geom::Rotation; - Rotation() = default; - - Rotation(float p, float y, float r) - : pitch(p), - yaw(y), - roll(r) {} - - float pitch = 0.0f; - float yaw = 0.0f; - float roll = 0.0f; - -#ifdef LIBCARLA_INCLUDED_FROM_UE4 - - Rotation(const FRotator &rotator) - : Rotation(rotator.Pitch, rotator.Yaw, rotator.Roll) {} - - operator FRotator() const { - return FRotator{pitch, yaw, roll}; - } - -#endif // LIBCARLA_INCLUDED_FROM_UE4 - - MSGPACK_DEFINE_ARRAY(pitch, yaw, roll); - }; - - class Transform { - public: - - Transform() = default; - - Transform(const Location &in_location, const Rotation &in_rotation) - : location(in_location), - rotation(in_rotation) {} - - Location location; - Rotation rotation; - -#ifdef LIBCARLA_INCLUDED_FROM_UE4 - - Transform(const FTransform &transform) - : Transform(Location(transform.GetLocation()), Rotation(transform.Rotator())) {} - - operator FTransform() const { - const FVector scale{1.0f, 1.0f, 1.0f}; - return FTransform{FRotator(rotation), FVector(location), scale}; - } - -#endif // LIBCARLA_INCLUDED_FROM_UE4 - - MSGPACK_DEFINE_ARRAY(location, rotation); - }; + using Transform = geom::Transform; } // namespace rpc } // namespace carla diff --git a/LibCarla/source/carla/rpc/VehicleControl.h b/LibCarla/source/carla/rpc/VehicleControl.h index bc7447cf5..f9635f180 100644 --- a/LibCarla/source/carla/rpc/VehicleControl.h +++ b/LibCarla/source/carla/rpc/VehicleControl.h @@ -6,7 +6,7 @@ #pragma once -#include "carla/rpc/MsgPack.h" +#include "carla/MsgPack.h" namespace carla { namespace rpc { diff --git a/LibCarla/source/carla/streaming/Token.h b/LibCarla/source/carla/streaming/Token.h index 1cc397d90..e8442512a 100644 --- a/LibCarla/source/carla/streaming/Token.h +++ b/LibCarla/source/carla/streaming/Token.h @@ -6,7 +6,7 @@ #pragma once -#include "carla/rpc/MsgPack.h" +#include "carla/MsgPack.h" #include diff --git a/PythonAPI/source/libcarla/Transform.cpp b/PythonAPI/source/libcarla/Transform.cpp index fda1aa341..d35083793 100644 --- a/PythonAPI/source/libcarla/Transform.cpp +++ b/PythonAPI/source/libcarla/Transform.cpp @@ -11,7 +11,7 @@ #include namespace carla { -namespace rpc { +namespace geom { std::ostream &operator<<(std::ostream &out, const Location &location) { out << "Location(x=" << location.x @@ -32,18 +32,18 @@ namespace rpc { return out; } -} // namespace rpc +} // namespace geom } // namespace carla void export_transform() { using namespace boost::python; - namespace cc = carla::client; + namespace cg = carla::geom; - class_("Location") + class_("Location") .def(init((arg("x")=0.0f, arg("y")=0.0f, arg("z")=0.0f))) - .def_readwrite("x", &cc::Location::x) - .def_readwrite("y", &cc::Location::y) - .def_readwrite("z", &cc::Location::z) + .def_readwrite("x", &cg::Location::x) + .def_readwrite("y", &cg::Location::y) + .def_readwrite("z", &cg::Location::z) .def(self += self) .def(self + self) .def(self -= self) @@ -51,19 +51,19 @@ void export_transform() { .def(self_ns::str(self_ns::self)) ; - class_("Rotation") + class_("Rotation") .def(init((arg("pitch")=0.0f, arg("yaw")=0.0f, arg("roll")=0.0f))) - .def_readwrite("pitch", &cc::Rotation::pitch) - .def_readwrite("yaw", &cc::Rotation::yaw) - .def_readwrite("roll", &cc::Rotation::roll) + .def_readwrite("pitch", &cg::Rotation::pitch) + .def_readwrite("yaw", &cg::Rotation::yaw) + .def_readwrite("roll", &cg::Rotation::roll) .def(self_ns::str(self_ns::self)) ; - class_("Transform") - .def(init( - (arg("location")=cc::Location(), arg("rotation")=cc::Rotation()))) - .def_readwrite("location", &cc::Transform::location) - .def_readwrite("rotation", &cc::Transform::rotation) + class_("Transform") + .def(init( + (arg("location")=cg::Location(), arg("rotation")=cg::Rotation()))) + .def_readwrite("location", &cg::Transform::location) + .def_readwrite("rotation", &cg::Transform::rotation) .def(self_ns::str(self_ns::self)) ; }