Skip to content

Commit

Permalink
Upgrade to Unreal Engine 4.22 and clang 7
Browse files Browse the repository at this point in the history
  • Loading branch information
nsubiron committed May 3, 2019
1 parent e52f6c7 commit 32d9715
Show file tree
Hide file tree
Showing 24 changed files with 111 additions and 113 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ matrix:
apt:
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-xenial-7
packages:
- g++-7 # we need this one for the libstdc++.
- clang-6.0
- clang-7
- ninja-build
- python
- python-pip
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## Latest

* Upgraded to Unreal Engine 4.22
* Recorder fixes:
- Actors at start of playback could interpolate positions from its current position instead than the recorded position, making some fast sliding effect during 1 frame.
- Camera following in playback was not working if a new map was needed to load.
Expand Down
8 changes: 4 additions & 4 deletions Docs/build_system.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ process.

![modules](img/modules.png)

In Linux, we compile CARLA and all the dependencies with clang-6.0 and C++14
In Linux, we compile CARLA and all the dependencies with clang-7.0 and C++14
standard. We however link against different runtime C++ libraries depending on
where the code going to be used, since all the code that is going to be linked
with Unreal Engine needs to be compiled using `libc++`.
Expand All @@ -26,7 +26,7 @@ make setup

Get and compile dependencies

* llvm-6.0 (libc++ and libc++abi)
* llvm-7.1 (libc++ and libc++abi)
* rpclib-2.2.1 (twice, with libstdc++ and libc++)
* boost-1.69 (headers only)
* googletest-1.8.0 (with libc++)
Expand All @@ -53,8 +53,8 @@ Two configurations:

#### CarlaUE4 and Carla plugin

Both compiled at the same step with Unreal Engine 4.21 build tool. They require
the `UE4_ROOT` environment variable set.
Both compiled at the same step with Unreal Engine build tool. They require the
`UE4_ROOT` environment variable set.

Command

Expand Down
2 changes: 1 addition & 1 deletion Docs/coding_standard.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ C++
* Comments should not exceed 80 columns, code may exceed this limit a bit in
rare occasions if it results in clearer code.
* Compilation should not give any error or warning
(`clang++-6.0 -Wall -Wextra -std=C++14 -Wno-missing-braces`).
(`clang++-7 -Wall -Wextra -std=C++14 -Wno-missing-braces`).
* The use of `throw` is forbidden, use `carla::throw_exception` instead.
* Unreal C++ code (CarlaUE4 and Carla plugin) follow the
[Unreal Engine's Coding Standard][ue4link] with the exception of using
Expand Down
18 changes: 10 additions & 8 deletions Docs/how_to_build_on_linux.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ Install the build tools and dependencies

```
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key|sudo apt-key add -
sudo apt-add-repository "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-7 main"
sudo apt-get update
sudo apt-get install build-essential clang-6.0 lld-6.0 g++-7 cmake ninja-build python python-pip python-dev python3-dev python3-pip libpng16-dev libtiff5-dev libjpeg-dev tzdata sed curl wget unzip autoconf libtool
sudo apt-get install build-essential clang-7 lld-7 g++-7 cmake ninja-build python python-pip python-dev python3-dev python3-pip libpng16-dev libtiff5-dev libjpeg-dev tzdata sed curl wget unzip autoconf libtool
pip2 install --user setuptools
pip3 install --user setuptools
```
Expand All @@ -20,8 +22,8 @@ change your default clang version to compile Unreal Engine and the CARLA
dependencies

```sh
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/lib/llvm-6.0/bin/clang++ 102
sudo update-alternatives --install /usr/bin/clang clang /usr/lib/llvm-6.0/bin/clang 102
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/lib/llvm-7/bin/clang++ 170
sudo update-alternatives --install /usr/bin/clang clang /usr/lib/llvm-7/bin/clang 170
```

Build Unreal Engine
Expand All @@ -32,13 +34,13 @@ Build Unreal Engine
need to add your GitHub username when you sign up at
[www.unrealengine.com](https://www.unrealengine.com).

Download and compile Unreal Engine 4.21. Here we will assume you install it at
`~/UnrealEngine_4.21", but you can install it anywhere, just replace the path
Download and compile Unreal Engine 4.22. Here we will assume you install it at
`~/UnrealEngine_4.22", but you can install it anywhere, just replace the path
where necessary.

```sh
git clone --depth=1 -b 4.21 https://github.com/EpicGames/UnrealEngine.git ~/UnrealEngine_4.21
cd ~/UnrealEngine_4.21
git clone --depth=1 -b 4.22 https://github.com/EpicGames/UnrealEngine.git ~/UnrealEngine_4.22
cd ~/UnrealEngine_4.22
./Setup.sh && ./GenerateProjectFiles.sh && make
```

Expand Down Expand Up @@ -71,7 +73,7 @@ For CARLA to find your Unreal Engine's installation folder you need to set the
following environment variable

```sh
export UE4_ROOT=~/UnrealEngine_4.21
export UE4_ROOT=~/UnrealEngine_4.22
```

You can also add this variable to your `~/.bashrc` or `~/.profile`.
Expand Down
2 changes: 1 addition & 1 deletion Docs/how_to_build_on_windows.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

Also:

- [Unreal Engine](https://www.unrealengine.com/download) (v4.21.x)
- [Unreal Engine](https://www.unrealengine.com/download) (v4.22.x)
- [Visual Studio](https://www.visualstudio.com/downloads/) (2017)

<h3>Environment Setup</h3>
Expand Down
4 changes: 2 additions & 2 deletions Examples/CppClient/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ BINDIR=$(CURDIR)/bin
INSTALLDIR=$(CURDIR)/libcarla-install
TOOLCHAIN=$(CURDIR)/ToolChain.cmake

CC=/usr/bin/clang-6.0
CXX=/usr/bin/clang++-6.0
CC=/usr/bin/clang-7
CXX=/usr/bin/clang++-7
CXXFLAGS=-std=c++14 -pthread -fPIC -O3 -DNDEBUG -Werror -Wall -Wextra

define log
Expand Down
4 changes: 2 additions & 2 deletions Examples/CppClient/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ want

```cmake
# Example ToolChain.cmake
set(CMAKE_C_COMPILER /usr/bin/clang-6.0)
set(CMAKE_CXX_COMPILER /usr/bin/clang++-6.0)
set(CMAKE_C_COMPILER /usr/bin/clang-7)
set(CMAKE_CXX_COMPILER /usr/bin/clang++-7)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -O3 -DNDEBUG" CACHE STRING "" FORCE)
```

Expand Down
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ pipeline {
agent any

environment {
UE4_ROOT = '/var/lib/jenkins/UnrealEngine_4.21'
UE4_ROOT = '/var/lib/jenkins/UnrealEngine_4.22'
}

options {
Expand Down
14 changes: 7 additions & 7 deletions LibCarla/source/carla/road/Map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,31 +257,31 @@ namespace road {
RELEASE_ASSERT(waypoint.lane_id >= lanes.begin()->first);
RELEASE_ASSERT(waypoint.lane_id <= lanes.rbegin()->first);

double lane_width = 0;
double lane_tangent = 0;
float lane_width = 0.0f;
float lane_tangent = 0.0f;
if (waypoint.lane_id < 0) {
// right lane
const auto side_lanes = MakeListView(
std::make_reverse_iterator(lanes.lower_bound(0)), lanes.rend());
const auto computed_width =
ComputeTotalLaneWidth(side_lanes, waypoint.s, waypoint.lane_id);
lane_width = computed_width.first;
lane_tangent = computed_width.second;
lane_width = static_cast<float>(computed_width.first);
lane_tangent = static_cast<float>(computed_width.second);
} else {
// left lane
const auto side_lanes = MakeListView(lanes.lower_bound(1), lanes.end());
const auto computed_width =
ComputeTotalLaneWidth(side_lanes, waypoint.s, waypoint.lane_id);
lane_width = computed_width.first;
lane_tangent = computed_width.second;
lane_width = static_cast<float>(computed_width.first);
lane_tangent = static_cast<float>(computed_width.second);
}

// get a directed point in s and apply the computed lateral offet
DirectedPoint dp = road.GetDirectedPointIn(waypoint.s);

// compute the tangent of the laneOffset
const auto lane_offset_info = road.GetInfo<RoadInfoLaneOffset>(waypoint.s);
const auto lane_offset_tangent = lane_offset_info->GetPolynomial().Tangent(waypoint.s);
const auto lane_offset_tangent = static_cast<float>(lane_offset_info->GetPolynomial().Tangent(waypoint.s));

lane_tangent -= lane_offset_tangent;

Expand Down
6 changes: 3 additions & 3 deletions LibCarla/source/carla/road/Road.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ namespace road {
const auto geometry = _info.GetInfo<element::RoadInfoGeometry>(clamped_s);

const auto lane_offset = _info.GetInfo<element::RoadInfoLaneOffset>(clamped_s);
const auto offset = lane_offset->GetPolynomial().Evaluate(clamped_s);
const auto offset = static_cast<float>(lane_offset->GetPolynomial().Evaluate(clamped_s));

// Apply road's lane offset record
element::DirectedPoint p = geometry->GetGeometry().PosFromDist(clamped_s - geometry->GetDistance());
Expand Down Expand Up @@ -244,7 +244,7 @@ namespace road {
DirectedPoint current_dp = dp_lane_zero;
for (const auto &lane : right_lanes) {
const auto lane_width_info = lane.second->GetInfo<RoadInfoLaneWidth>(s);
const auto half_width = lane_width_info->GetPolynomial().Evaluate(s) * 0.5;
const auto half_width = static_cast<float>(lane_width_info->GetPolynomial().Evaluate(s)) * 0.5f;

current_dp.ApplyLateralOffset(half_width);
const auto current_dist = geom::Math::Distance(current_dp.location, loc);
Expand All @@ -267,7 +267,7 @@ namespace road {
current_dp = dp_lane_zero;
for (const auto &lane : left_lanes) {
const auto lane_width_info = lane.second->GetInfo<RoadInfoLaneWidth>(s);
const auto half_width = -lane_width_info->GetPolynomial().Evaluate(s) * 0.5;
const auto half_width = -static_cast<float>(lane_width_info->GetPolynomial().Evaluate(s)) * 0.5f;

current_dp.ApplyLateralOffset(half_width);
const auto current_dist = geom::Math::Distance(current_dp.location, loc);
Expand Down
24 changes: 12 additions & 12 deletions LibCarla/source/carla/road/element/Geometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ namespace element {
double tangent = 0.0; // [radians]
double pitch = 0.0; // [radians]

void ApplyLateralOffset(double lateral_offset) {
void ApplyLateralOffset(float lateral_offset) {
/// @todo Z axis??
auto normal_x = std::sin(tangent);
auto normal_y = -std::cos(tangent);
auto normal_x = std::sin(static_cast<float>(tangent));
auto normal_y = -std::cos(static_cast<float>(tangent));
location.x += lateral_offset * normal_x;
location.y += lateral_offset * normal_y;
}
Expand Down Expand Up @@ -117,11 +117,11 @@ namespace element {
: Geometry(GeometryType::LINE, start_offset, length, heading, start_pos) {}

DirectedPoint PosFromDist(double dist) const override {
dist = geom::Math::Clamp(dist, 0.0, _length);
DEBUG_ASSERT(_length > 0.0);
dist = geom::Math::Clamp(dist, 0.0, _length);
DirectedPoint p(_start_position, _heading);
p.location.x += dist * std::cos(p.tangent);
p.location.y += dist * std::sin(p.tangent);
p.location.x += static_cast<float>(dist * std::cos(p.tangent));
p.location.y += static_cast<float>(dist * std::sin(p.tangent));
return p;
}

Expand Down Expand Up @@ -159,11 +159,11 @@ namespace element {
const double radius = 1.0 / _curvature;
constexpr double pi_half = geom::Math::Pi<double>() / 2.0;
DirectedPoint p(_start_position, _heading);
p.location.x += radius * std::cos(p.tangent + pi_half);
p.location.y += radius * std::sin(p.tangent + pi_half);
p.location.x += static_cast<float>(radius * std::cos(p.tangent + pi_half));
p.location.y += static_cast<float>(radius * std::sin(p.tangent + pi_half));
p.tangent += dist * _curvature;
p.location.x -= radius * std::cos(p.tangent + pi_half);
p.location.y -= radius * std::sin(p.tangent + pi_half);
p.location.x -= static_cast<float>(radius * std::cos(p.tangent + pi_half));
p.location.y -= static_cast<float>(radius * std::sin(p.tangent + pi_half));
return p;
}

Expand Down Expand Up @@ -228,8 +228,8 @@ namespace element {
DirectedPoint p(_start_position, _heading);
const double cos_a = std::cos(p.tangent);
const double sin_a = std::sin(p.tangent);
p.location.x += C * cos_a - S * sin_a;
p.location.y += S * cos_a + C * sin_a;
p.location.x += static_cast<float>(C * cos_a - S * sin_a);
p.location.y += static_cast<float>(S * cos_a + C * sin_a);
p.tangent += length * length;

return p;
Expand Down
2 changes: 1 addition & 1 deletion PythonAPI/carla/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def walk(folder, file_filter='*'):
os.path.join(pwd, 'dependencies/lib', pylib)]
extra_compile_args = [
'-isystem', 'dependencies/include/system', '-fPIC', '-std=c++14',
'-Werror', '-Wall', '-Wextra', '-Wpedantic',
'-Werror', '-Wall', '-Wextra', '-Wpedantic', '-Wno-self-assign-overloaded',
'-Wdeprecated', '-Wno-shadow', '-Wuninitialized', '-Wunreachable-code',
'-Wpessimizing-move', '-Wold-style-cast', '-Wnull-dereference',
'-Wduplicate-enum', '-Wnon-virtual-dtor', '-Wheader-hygiene',
Expand Down
2 changes: 1 addition & 1 deletion Unreal/CarlaUE4/CarlaUE4.uproject
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"FileVersion": 3,
"EngineAssociation": "4.21",
"EngineAssociation": "4.22",
"Category": "",
"Description": "",
"Modules": [
Expand Down
47 changes: 18 additions & 29 deletions Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Sensor/PixelReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,35 +85,24 @@ void FPixelReader::SendPixelsInRenderThread(TSensor &Sensor)
{
check(Sensor.CaptureRenderTarget != nullptr);

// First we create the message header (needs to be created in the
// game-thread).
auto AsyncStream = Sensor.GetDataStream(Sensor);

// We need a shared ptr here because UE4 macros do not move the arguments -_-
auto StreamPtr = std::make_shared<decltype(AsyncStream)>(std::move(AsyncStream));

// Then we enqueue commands in the render-thread that will write the image
// buffer to the data stream.

auto WriteAndSend = [&Sensor, Stream=std::move(StreamPtr)](auto &InRHICmdList) mutable
{
/// @todo Can we make sure the sensor is not going to be destroyed?
if (!Sensor.IsPendingKill())
// Enqueue a command in the render-thread that will write the image buffer to
// the data stream. The stream is created in the capture thus executed in the
// game-thread.
ENQUEUE_RENDER_COMMAND(FWritePixels_SendPixelsInRenderThread)
(
[&Sensor, Stream=Sensor.GetDataStream(Sensor)](auto &InRHICmdList) mutable
{
auto Buffer = Stream->PopBufferFromPool();
WritePixelsToBuffer(
*Sensor.CaptureRenderTarget,
Buffer,
carla::sensor::SensorRegistry::get<TSensor *>::type::header_offset,
InRHICmdList);
Stream->Send(Sensor, std::move(Buffer));
/// @todo Can we make sure the sensor is not going to be destroyed?
if (!Sensor.IsPendingKill())
{
auto Buffer = Stream.PopBufferFromPool();
WritePixelsToBuffer(
*Sensor.CaptureRenderTarget,
Buffer,
carla::sensor::SensorRegistry::get<TSensor *>::type::header_offset,
InRHICmdList);
Stream.Send(Sensor, std::move(Buffer));
}
}
};

ENQUEUE_UNIQUE_RENDER_COMMAND_ONEPARAMETER(
FWritePixels_SendPixelsInRenderThread,
std::function<void(FRHICommandListImmediate &)>, WriteAndSendFunction, std::move(WriteAndSend),
{
WriteAndSendFunction(RHICmdList);
});
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ enum class EVehicleInputPriority : uint8

inline static bool operator<=(EVehicleInputPriority Lhs, EVehicleInputPriority Rhs)
{
constexpr auto Cast = [](auto e) { return static_cast<typename std::underlying_type<decltype(e)>::type>(e); };
auto Cast = [](auto e) { return static_cast<typename std::underlying_type<decltype(e)>::type>(e); };
return Cast(Lhs) <= Cast(Rhs);
}
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ AWheeledVehicleAIController::~AWheeledVehicleAIController() {}
// -- APlayerController --------------------------------------------------------
// =============================================================================

void AWheeledVehicleAIController::Possess(APawn *aPawn)
void AWheeledVehicleAIController::OnPossess(APawn *aPawn)
{
Super::Possess(aPawn);
Super::OnPossess(aPawn);

if (IsPossessingAVehicle())
{
Expand All @@ -119,9 +119,9 @@ void AWheeledVehicleAIController::Possess(APawn *aPawn)
}
}

void AWheeledVehicleAIController::UnPossess()
void AWheeledVehicleAIController::OnUnPossess()
{
Super::UnPossess();
Super::OnUnPossess();

Vehicle = nullptr;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ class CARLA_API AWheeledVehicleAIController : public APlayerController

public:

void Possess(APawn *aPawn) override;
void OnPossess(APawn *aPawn) override;

void UnPossess() override;
void OnUnPossess() override;

void Tick(float DeltaTime) override;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ AWalkerController::AWalkerController(const FObjectInitializer& ObjectInitializer
PrimaryActorTick.bCanEverTick = true;
}

void AWalkerController::Possess(APawn *InPawn)
void AWalkerController::OnPossess(APawn *InPawn)
{
Super::Possess(InPawn);
Super::OnPossess(InPawn);

auto *Character = Cast<ACharacter>(InPawn);
if (Character == nullptr)
Expand Down
Loading

0 comments on commit 32d9715

Please sign in to comment.