Add namespaces for road classes and opendrive
This commit is contained in:
parent
db9d6a781d
commit
dd0de88fbd
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 <https://opensource.org/licenses/MIT>.
|
||||
|
||||
#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 <typename Packer>
|
||||
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 <typename MSGPACK_OBJECT>
|
||||
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
|
|
@ -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 <https://opensource.org/licenses/MIT>.
|
||||
|
||||
#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
|
|
@ -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 <https://opensource.org/licenses/MIT>.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "carla/road/Map.h"
|
||||
|
||||
#include <istream>
|
||||
#include <ostream>
|
||||
|
||||
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
|
|
@ -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 <https://opensource.org/licenses/MIT>.
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace carla {
|
||||
namespace road {
|
||||
|
||||
class Map {
|
||||
public:
|
||||
|
||||
|
||||
};
|
||||
|
||||
} // namespace road
|
||||
} // namespace carla
|
|
@ -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 <https://opensource.org/licenses/MIT>.
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace carla {
|
||||
namespace road {
|
||||
|
||||
class MapBuilder {
|
||||
public:
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
} // namespace road
|
||||
} // namespace carla
|
|
@ -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 <vector>
|
||||
|
|
|
@ -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 <vector>
|
||||
|
|
|
@ -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 <vector>
|
||||
|
|
|
@ -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 <typename Packer>
|
||||
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 <typename MSGPACK_OBJECT>
|
||||
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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "carla/rpc/MsgPack.h"
|
||||
#include "carla/MsgPack.h"
|
||||
|
||||
namespace carla {
|
||||
namespace rpc {
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "carla/rpc/MsgPack.h"
|
||||
#include "carla/MsgPack.h"
|
||||
|
||||
#include <array>
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include <ostream>
|
||||
|
||||
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_<cc::Location>("Location")
|
||||
class_<cg::Location>("Location")
|
||||
.def(init<float, float, float>((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_<cc::Rotation>("Rotation")
|
||||
class_<cg::Rotation>("Rotation")
|
||||
.def(init<float, float, float>((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_<cc::Transform>("Transform")
|
||||
.def(init<cc::Location, cc::Rotation>(
|
||||
(arg("location")=cc::Location(), arg("rotation")=cc::Rotation())))
|
||||
.def_readwrite("location", &cc::Transform::location)
|
||||
.def_readwrite("rotation", &cc::Transform::rotation)
|
||||
class_<cg::Transform>("Transform")
|
||||
.def(init<cg::Location, cg::Rotation>(
|
||||
(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))
|
||||
;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue