New build system for Windows
This commit is contained in:
parent
ed2a1afa6f
commit
4f62a201a0
|
@ -1,4 +1,9 @@
|
|||
CARLA UE4 Plugin
|
||||
================
|
||||
|
||||
To build within a project [CarlaServer](Source/CarlaServer/README.md) needs to
|
||||
be built first.
|
||||
|
||||
See [carla-ue4](https://bitbucket.org/carla-cvc/carla-ue4).
|
||||
|
||||
|
||||
|
|
|
@ -5,6 +5,8 @@ using UnrealBuildTool;
|
|||
|
||||
public class Carla : ModuleRules
|
||||
{
|
||||
private readonly bool bUseDebugLibs = false;
|
||||
|
||||
public Carla(TargetInfo Target)
|
||||
{
|
||||
PublicIncludePaths.AddRange(
|
||||
|
@ -48,6 +50,7 @@ public class Carla : ModuleRules
|
|||
|
||||
AddBoostDependency(Target);
|
||||
AddProtobufDependency(Target);
|
||||
AddTurboJPEGDependency(Target);
|
||||
AddCarlaServerDependency(Target);
|
||||
|
||||
if (Target.Platform == UnrealTargetPlatform.Linux)
|
||||
|
@ -55,7 +58,6 @@ public class Carla : ModuleRules
|
|||
// Fails to link the std libraries.
|
||||
PublicAdditionalLibraries.Add("stdc++");
|
||||
}
|
||||
PublicAdditionalLibraries.Add("turbojpeg");
|
||||
}
|
||||
|
||||
private bool IsWindows(TargetInfo Target)
|
||||
|
@ -97,12 +99,23 @@ public class Carla : ModuleRules
|
|||
if (IsWindows(Target))
|
||||
{
|
||||
string ProtobufRoot = System.Environment.GetEnvironmentVariable("PROTOBUF_ROOT");
|
||||
string ProtobufLib;
|
||||
if (bUseDebugLibs)
|
||||
{
|
||||
ProtobufRoot = Path.Combine(ProtobufRoot, "Debug");
|
||||
ProtobufLib = "libprotobufd.lib";
|
||||
}
|
||||
else
|
||||
{
|
||||
ProtobufRoot = Path.Combine(ProtobufRoot, "Release");
|
||||
ProtobufLib = "libprotobuf.lib";
|
||||
}
|
||||
if (string.IsNullOrEmpty(ProtobufRoot) || !System.IO.Directory.Exists(ProtobufRoot))
|
||||
{
|
||||
throw new System.Exception("PROTOBUF_ROOT is not defined, or points to a non-existant directory, please set this environment variable.");
|
||||
}
|
||||
PrivateIncludePaths.Add(Path.Combine(ProtobufRoot, "include"));
|
||||
PublicAdditionalLibraries.Add(Path.Combine(ProtobufRoot, "lib", "libprotobuf.lib"));
|
||||
PublicAdditionalLibraries.Add(Path.Combine(ProtobufRoot, "lib", ProtobufLib));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -110,31 +123,41 @@ public class Carla : ModuleRules
|
|||
}
|
||||
}
|
||||
|
||||
public void AddCarlaServerDependency(TargetInfo Target)
|
||||
private void AddTurboJPEGDependency(TargetInfo Target)
|
||||
{
|
||||
string CarlaServerIncludePath;
|
||||
string CarlaServerLibPath;
|
||||
string CarlaServerLib;
|
||||
string TurboJpegLib;
|
||||
|
||||
if (IsWindows(Target))
|
||||
if (Target.Platform == UnrealTargetPlatform.Linux)
|
||||
{
|
||||
CarlaServerIncludePath = "CarlaServer/include";
|
||||
CarlaServerLibPath = "CarlaServer/lib/Release";
|
||||
CarlaServerLib = Path.Combine(ModuleDirectory, "..", CarlaServerLibPath, "carla_server.lib");
|
||||
TurboJpegLib = Path.Combine(ModuleDirectory, "..", CarlaServerLibPath, "turbojpeg.lib");
|
||||
PublicAdditionalLibraries.Add("turbojpeg");
|
||||
}
|
||||
}
|
||||
|
||||
private void AddCarlaServerDependency(TargetInfo Target)
|
||||
{
|
||||
string CarlaServerIncludePath = "CarlaServer/include";
|
||||
string CarlaServerLibPath = Path.Combine(ModuleDirectory, "..", "CarlaServer/lib");
|
||||
|
||||
string CarlaServerLibBaseName;
|
||||
if (bUseDebugLibs)
|
||||
{
|
||||
CarlaServerLibBaseName = "carlaserverd";
|
||||
}
|
||||
else
|
||||
{
|
||||
CarlaServerIncludePath = "CarlaServer/include";
|
||||
CarlaServerLibPath = "CarlaServer/lib";
|
||||
CarlaServerLib = Path.Combine(ModuleDirectory, "..", CarlaServerLibPath, "libcarla_server.a");
|
||||
TurboJpegLib = Path.Combine(ModuleDirectory, "..", CarlaServerLibPath, "libturbojpeg.a");
|
||||
CarlaServerLibBaseName = "carlaserver";
|
||||
}
|
||||
|
||||
string CarlaServerLib;
|
||||
if (IsWindows(Target))
|
||||
{
|
||||
CarlaServerLib = Path.Combine(CarlaServerLibPath, CarlaServerLibBaseName + ".lib");
|
||||
}
|
||||
else
|
||||
{
|
||||
CarlaServerLib = Path.Combine(CarlaServerLibPath, "lib" + CarlaServerLibBaseName + ".a");
|
||||
}
|
||||
|
||||
PublicIncludePaths.Add(CarlaServerIncludePath);
|
||||
PrivateIncludePaths.Add(CarlaServerIncludePath);
|
||||
PublicAdditionalLibraries.Add(CarlaServerLib);
|
||||
PublicAdditionalLibraries.Add(TurboJpegLib);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -116,7 +116,7 @@ static bool SendAndReadSceneValues(
|
|||
if (!Server.sendSceneValues(sceneValues))
|
||||
return false;
|
||||
// Wait till we receive an answer.
|
||||
uint32 EndIndex;
|
||||
uint32 EndIndex = 0u;
|
||||
bool Success = false;
|
||||
UE_LOG(LogCarlaServer, Log, TEXT("(tryReadEpisodeStart) Waiting for client..."));
|
||||
while (!Success) {
|
||||
|
@ -125,7 +125,7 @@ static bool SendAndReadSceneValues(
|
|||
}
|
||||
UE_LOG(LogCarlaServer, Log, TEXT("Episode start received: { StartIndex = %d, EndIndex = %d }"), StartIndex, EndIndex);
|
||||
// Make sure the index is in range.
|
||||
if (StartIndex >= AvailableStartSpots.Num()) {
|
||||
if (StartIndex >= static_cast<uint32>(AvailableStartSpots.Num())) {
|
||||
UE_LOG(
|
||||
LogCarlaServer,
|
||||
Error,
|
||||
|
|
|
@ -40,7 +40,7 @@ void ACarlaPlayerState::CopyProperties(APlayerState *PlayerState)
|
|||
}
|
||||
}
|
||||
|
||||
void ACarlaPlayerState::RegisterCollision(AActor */*Actor*/, FVector NormalImpulse)
|
||||
void ACarlaPlayerState::RegisterCollision(AActor * /*Actor*/, FVector NormalImpulse)
|
||||
{
|
||||
CollisionIntensityOther += NormalImpulse.Size();
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ CMakeCache.txt
|
|||
CMakeFiles
|
||||
|
||||
bin
|
||||
bin_debug
|
||||
build
|
||||
include
|
||||
lib
|
||||
|
|
|
@ -10,24 +10,115 @@ endif (UNIX)
|
|||
set(CMAKE_CXX_STANDARD 14)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED 14)
|
||||
|
||||
# Boost configuration.
|
||||
# ==============================================================================
|
||||
# -- Suppress windows warning --------------------------------------------------
|
||||
# ==============================================================================
|
||||
|
||||
# http://stackoverflow.com/a/40217291
|
||||
if (WIN32)
|
||||
macro(get_WIN32_WINNT version)
|
||||
if (CMAKE_SYSTEM_VERSION)
|
||||
set(ver ${CMAKE_SYSTEM_VERSION})
|
||||
string(REGEX MATCH "^([0-9]+).([0-9])" ver ${ver})
|
||||
string(REGEX MATCH "^([0-9]+)" verMajor ${ver})
|
||||
# Check for Windows 10, b/c we'll need to convert to hex 'A'.
|
||||
if ("${verMajor}" MATCHES "10")
|
||||
set(verMajor "A")
|
||||
string(REGEX REPLACE "^([0-9]+)" ${verMajor} ver ${ver})
|
||||
endif ("${verMajor}" MATCHES "10")
|
||||
# Remove all remaining '.' characters.
|
||||
string(REPLACE "." "" ver ${ver})
|
||||
# Prepend each digit with a zero.
|
||||
string(REGEX REPLACE "([0-9A-Z])" "0\\1" ver ${ver})
|
||||
set(${version} "0x${ver}")
|
||||
endif(CMAKE_SYSTEM_VERSION)
|
||||
endmacro(get_WIN32_WINNT)
|
||||
get_WIN32_WINNT(ver)
|
||||
add_definitions(-D_WIN32_WINNT=${ver})
|
||||
endif(WIN32)
|
||||
|
||||
# ==============================================================================
|
||||
# -- Boost ---------------------------------------------------------------------
|
||||
# ==============================================================================
|
||||
|
||||
set(Boost_USE_STATIC_LIBS ON)
|
||||
find_package(Boost REQUIRED system date_time regex)
|
||||
include_directories(${Boost_INCLUDE_DIRS})
|
||||
|
||||
#TurboJPEG
|
||||
# ==============================================================================
|
||||
# -- Protobuf ------------------------------------------------------------------
|
||||
# ==============================================================================
|
||||
|
||||
# Protobuf.
|
||||
include(FindProtobuf)
|
||||
find_package(Protobuf REQUIRED)
|
||||
include_directories(${PROTOBUF_INCLUDE_DIR})
|
||||
if (UNIX)
|
||||
set(Protobuf_LIBRARIES ${Protobuf_LIBRARIES} protobuf turbojpeg)
|
||||
|
||||
include(FindProtobuf)
|
||||
find_package(Protobuf REQUIRED)
|
||||
include_directories(${PROTOBUF_INCLUDE_DIR})
|
||||
set(Protobuf_LIBRARIES protobuf)
|
||||
|
||||
elseif (WIN32)
|
||||
|
||||
if (CMAKE_BUILD_TYPE MATCHES Debug)
|
||||
|
||||
if (EXISTS $ENV{PROTOBUF_ROOT}/Debug)
|
||||
message(STATUS "Using Protobuf DEBUG at " $ENV{PROTOBUF_ROOT}/Debug)
|
||||
include_directories($ENV{PROTOBUF_ROOT}/Debug/include)
|
||||
link_directories($ENV{PROTOBUF_ROOT}/Debug/lib)
|
||||
set(Protobuf_LIBRARIES libprotobufd.lib)
|
||||
else (EXISTS $ENV{PROTOBUF_ROOT}/Debug)
|
||||
message(FATAL_ERROR "Cannot find PROTOBUF_ROOT/Debug")
|
||||
endif (EXISTS $ENV{PROTOBUF_ROOT}/Debug)
|
||||
|
||||
else (CMAKE_BUILD_TYPE MATCHES Release)
|
||||
|
||||
if (EXISTS $ENV{PROTOBUF_ROOT}/Release)
|
||||
message(STATUS "Using Protobuf RELEASE at " $ENV{PROTOBUF_ROOT}/Release)
|
||||
include_directories($ENV{PROTOBUF_ROOT}/Release/include)
|
||||
link_directories($ENV{PROTOBUF_ROOT}/Release/lib)
|
||||
set(Protobuf_LIBRARIES libprotobuf.lib)
|
||||
else (EXISTS $ENV{PROTOBUF_ROOT}/Release)
|
||||
message(FATAL_ERROR "Cannot find PROTOBUF_ROOT/Release")
|
||||
endif (EXISTS $ENV{PROTOBUF_ROOT}/Release)
|
||||
|
||||
endif (CMAKE_BUILD_TYPE MATCHES Debug)
|
||||
|
||||
endif (UNIX)
|
||||
|
||||
# ==============================================================================
|
||||
# -- TurboJPEG -----------------------------------------------------------------
|
||||
# ==============================================================================
|
||||
|
||||
if (UNIX)
|
||||
|
||||
set(TurboJPEG_LIBRARIES ${TurboJPEG_LIBRARIES} turbojpeg)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DWITH_TURBOJPEG")
|
||||
|
||||
elseif (WIN32)
|
||||
|
||||
message(WARNING "TurboJPEG not available for Windows yet")
|
||||
|
||||
endif (UNIX)
|
||||
|
||||
# ==============================================================================
|
||||
# -- Project config ------------------------------------------------------------
|
||||
# ==============================================================================
|
||||
|
||||
set(CarlaServer_Deps_LIBRARIES
|
||||
${TurboJPEG_LIBRARIES}
|
||||
${Protobuf_LIBRARIES}
|
||||
${Boost_DATE_TIME_LIBRARY}
|
||||
${Boost_REGEX_LIBRARY}
|
||||
${Boost_SYSTEM_LIBRARY}
|
||||
${CMAKE_THREAD_LIBS_INIT})
|
||||
|
||||
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)
|
||||
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
|
||||
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
|
||||
if (CMAKE_BUILD_TYPE MATCHES Debug)
|
||||
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin_debug)
|
||||
set(CarlaServer_LIBRARIES carlaserverd ${CarlaServer_Deps_LIBRARIES})
|
||||
elseif (CMAKE_BUILD_TYPE MATCHES Release)
|
||||
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
|
||||
set(CarlaServer_LIBRARIES carlaserver ${CarlaServer_Deps_LIBRARIES})
|
||||
endif (CMAKE_BUILD_TYPE MATCHES Debug)
|
||||
|
||||
include_directories("${PROJECT_SOURCE_DIR}/source")
|
||||
|
||||
|
|
|
@ -1,14 +1,35 @@
|
|||
BUILD_FOLDER=build
|
||||
PROTOBUF_SRC_DIR=source/carla/server
|
||||
|
||||
default: build
|
||||
cd build && ninja && ninja install
|
||||
MY_CMAKE_FLAGS=-H. -B$(BUILD_FOLDER)
|
||||
|
||||
build: protobuf
|
||||
cmake -H. -B$(BUILD_FOLDER) -G "Ninja"
|
||||
ifeq ($(OS),Windows_NT)
|
||||
DEFAULT_RULE=build_windows
|
||||
else
|
||||
DEFAULT_RULE=build_linux
|
||||
endif
|
||||
|
||||
default: release
|
||||
|
||||
debug: BUILD_FOLDER=build/debug
|
||||
debug: MY_CMAKE_FLAGS+=-DCMAKE_BUILD_TYPE=Debug
|
||||
debug: $(DEFAULT_RULE)
|
||||
|
||||
release: BUILD_FOLDER=build/release
|
||||
release: MY_CMAKE_FLAGS+=-DCMAKE_BUILD_TYPE=Release
|
||||
release: $(DEFAULT_RULE)
|
||||
|
||||
build_linux: protobuf
|
||||
cmake $(MY_CMAKE_FLAGS) -G "Ninja"
|
||||
cd $(BUILD_FOLDER) && ninja && ninja install
|
||||
|
||||
build_windows: protobuf
|
||||
cmake $(MY_CMAKE_FLAGS) -G "NMake Makefiles"
|
||||
cd $(BUILD_FOLDER) && nmake && nmake install
|
||||
|
||||
vsproject: BUILD_FOLDER=build/visualstudio
|
||||
vsproject: MY_CMAKE_FLAGS+=-DCMAKE_BUILD_TYPE=Debug
|
||||
vsproject: protobuf
|
||||
cmake -H. -B$(BUILD_FOLDER) -G "Visual Studio 14 2015 Win64"
|
||||
cmake $(MY_CMAKE_FLAGS) -G "Visual Studio 14 2015 Win64"
|
||||
|
||||
protobuf: $(PROTOBUF_SRC_DIR)/carla_protocol.pb.cc
|
||||
|
||||
|
@ -20,4 +41,4 @@ clean:
|
|||
rm -Rf build CMakeFiles
|
||||
|
||||
clean-all: clean
|
||||
rm -Rf bin lib include
|
||||
rm -Rf bin bin_debug lib include
|
||||
|
|
|
@ -27,25 +27,42 @@ At the configure step add PIC compile option
|
|||
|
||||
#### Windows
|
||||
|
||||
Warning: Outdated
|
||||
Note: JPEG compression is not implemented on Windows, the server won't send any
|
||||
images.
|
||||
|
||||
Install and compile [boost](http://www.boost.org/).
|
||||
Compile and install [boost](http://www.boost.org/).
|
||||
|
||||
Install and compile [protobuf](https://developers.google.com/protocol-buffers/).
|
||||
While compiling protobuf, use `-Dprotobuf_MSVC_STATIC_RUNTIME=OFF` when calling
|
||||
CMake in order to use the static runtime library, otherwise may give errors
|
||||
while trying to link with CarlaServer.
|
||||
Compile [protobuf](https://developers.google.com/protocol-buffers/). While
|
||||
compiling protobuf, use `-Dprotobuf_MSVC_STATIC_RUNTIME=OFF` when calling CMake
|
||||
in order to use the static runtime library, otherwise may give errors while
|
||||
trying to link with CarlaServer. Generate both debug and release and install
|
||||
under `$PROTOBUF_ROOT/Debug` and `$PROTOBUF_ROOT/Release` respectively.
|
||||
|
||||
CMake looks at the following environment variables
|
||||
The Makefile uses cmake to generate project files. Under Windows, it requires
|
||||
the following environment variables set
|
||||
|
||||
* `CMAKE_INCLUDE_PATH` should contain the protobuf include folder.
|
||||
* `CMAKE_LIBRARY_PATH` should contain "libprotobuf" "libprotobuf-lite" "liteprotoc" .lib files.
|
||||
* `BOOST_ROOT` root of the boost folder.
|
||||
* `PROTOBUF_ROOT` contains two folder `Debug` and `Release`, each of them with subfolders `lib` and `include`.
|
||||
|
||||
To generate the Visual Studio solution
|
||||
Before calling make you need to set up the environment calling `vcvarsall.bat`,
|
||||
usually located at the Visual Studio installation folder. Call it (don't forget
|
||||
the amd64 at the end)
|
||||
|
||||
$ "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" amd64
|
||||
|
||||
Then build either debug or release
|
||||
|
||||
$ make debug
|
||||
|
||||
or
|
||||
|
||||
$ make release
|
||||
|
||||
To generate the Visual Studio project
|
||||
|
||||
$ make vsproject
|
||||
|
||||
The solution gets generated at `./build/CarlaServer.sln`. Change the solution
|
||||
configuration to match protobuf (release, most probably). Don't forget to build
|
||||
the project INSTALL, it doesn't build when building the solution.
|
||||
The solution gets generated at `./build/visualstudio/CarlaServer.sln`. Change
|
||||
the solution configuration to match protobuf (release, most probably). Don't
|
||||
forget to build the project INSTALL, it doesn't build when building the
|
||||
solution.
|
||||
|
|
|
@ -1,8 +1,13 @@
|
|||
file(GLOB carla_server_SRC
|
||||
file(GLOB carlaserver_SRC
|
||||
"*.h"
|
||||
"*.cpp"
|
||||
"*.pb.h"
|
||||
"*.pb.cc"
|
||||
)
|
||||
set(carlaserver_SRC ${carlaserver_SRC} ../CarlaServer.cpp)
|
||||
|
||||
add_library(carla_server STATIC ../CarlaServer.cpp ${carla_server_SRC})
|
||||
if (CMAKE_BUILD_TYPE MATCHES Debug)
|
||||
add_library(carlaserverd STATIC ${carlaserver_SRC})
|
||||
elseif (CMAKE_BUILD_TYPE MATCHES Release)
|
||||
add_library(carlaserver STATIC ${carlaserver_SRC})
|
||||
endif (CMAKE_BUILD_TYPE MATCHES Debug)
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
#include "CarlaCommunication.h"
|
||||
#include "lodepng.h"
|
||||
|
||||
#include "carla_protocol.pb.h"
|
||||
#include "../CarlaServer.h"
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
#include "CarlaCommunication.h"
|
||||
#include "carla/CarlaServer.h"
|
||||
//#include "lodepng.h"
|
||||
|
||||
#include "carla_protocol.pb.h"
|
||||
|
||||
|
@ -11,76 +10,51 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
#include <turbojpeg.h>
|
||||
//#include "jpeglib.h"
|
||||
|
||||
#ifdef WITH_TURBOJPEG
|
||||
#include <turbojpeg.h>
|
||||
#endif // WITH_TURBOJPEG
|
||||
|
||||
namespace carla {
|
||||
namespace server {
|
||||
|
||||
|
||||
|
||||
static void WriteImage(const unsigned char *image, long unsigned int size){
|
||||
FILE *out;
|
||||
out = fopen("test.jpeg","w");
|
||||
fwrite(image,1,size,out);
|
||||
fclose(out);
|
||||
}
|
||||
|
||||
|
||||
//static bool getPNGImage(
|
||||
// const std::vector<Color> &in,
|
||||
// uint32_t width,
|
||||
// uint32_t height,
|
||||
// std::vector<unsigned char> &outPNG) {
|
||||
static bool getJPEGImage(
|
||||
const int jpeg_quality,
|
||||
const int color_components,
|
||||
const int width,
|
||||
const int height,
|
||||
const std::vector<Color> &image,
|
||||
bool depth,
|
||||
Reward &rwd
|
||||
){
|
||||
|
||||
const int jpeg_quality,
|
||||
const int color_components,
|
||||
const int width,
|
||||
const int height,
|
||||
const std::vector<Color> &image,
|
||||
bool depth,
|
||||
Reward &rwd){
|
||||
#ifndef WITH_TURBOJPEG
|
||||
return false;
|
||||
#else
|
||||
long unsigned int jpegSize = 0;
|
||||
|
||||
unsigned char *compressedImage;
|
||||
|
||||
if (image.empty())
|
||||
return false;
|
||||
|
||||
|
||||
if (image.size() != width * height) {
|
||||
std::cerr << "Invalid image size" << std::endl;
|
||||
return false;
|
||||
}
|
||||
// Convert to char array RGBA.
|
||||
int size = 3u * image.size();
|
||||
unsigned char color_img[size];
|
||||
|
||||
for (int i = 0, color_it = 0; i < size; ++color_it){
|
||||
color_img[i++] = image[color_it].R;
|
||||
color_img[i++] = image[color_it].G;
|
||||
color_img[i++] = image[color_it].B;
|
||||
std::vector<unsigned char> color_image;
|
||||
color_image.reserve(3u * image.size());
|
||||
for (const Color &color : image) {
|
||||
color_image.push_back(color.R);
|
||||
color_image.push_back(color.G);
|
||||
color_image.push_back(color.B);
|
||||
}
|
||||
|
||||
tjhandle jpegCompressor = tjInitCompress();
|
||||
|
||||
tjCompress2(jpegCompressor, color_img, width, 0, height, TJPF_RGB,
|
||||
tjCompress2(jpegCompressor, color_image.data(), width, 0, height, TJPF_RGB,
|
||||
&compressedImage, &jpegSize, TJSAMP_444, jpeg_quality, TJFLAG_FASTDCT);
|
||||
|
||||
|
||||
tjDestroy(jpegCompressor);
|
||||
|
||||
WriteImage(compressedImage, jpegSize);
|
||||
|
||||
if (!depth) rwd.set_image(compressedImage, jpegSize);
|
||||
|
||||
else rwd.set_depth(compressedImage, jpegSize);
|
||||
|
||||
if (!depth) {
|
||||
rwd.set_image(compressedImage, jpegSize);
|
||||
} else {
|
||||
rwd.set_depth(compressedImage, jpegSize);
|
||||
}
|
||||
return true;
|
||||
#endif // WITH_TURBOJPEG
|
||||
}
|
||||
|
||||
|
||||
|
@ -108,10 +82,8 @@ namespace server {
|
|||
|
||||
auto images = {values.image_rgb_0/*, values.image_rgb_1*/};
|
||||
for (const std::vector<Color> &image : images) {
|
||||
unsigned char *png_image;
|
||||
long unsigned int jpegSize = 0;
|
||||
if (!getJPEGImage(75, 3, values.image_width, values.image_height, image, false, reward)){
|
||||
|
||||
if (!getJPEGImage(75, 3, values.image_width, values.image_height, image, false, reward)) {
|
||||
std::cout << "ERROR" << std::endl;
|
||||
}
|
||||
}
|
||||
|
@ -130,22 +102,10 @@ namespace server {
|
|||
|
||||
void Protocol::LoadScene(Scene &scene, const Scene_Values &values) {
|
||||
std::vector<Vector2D> positions = values.possible_positions;
|
||||
|
||||
|
||||
/* std::cout << "POSSIBLE POSITIONS 3"<< std::endl;
|
||||
|
||||
for (int i=0; i<values.possible_positions.size(); ++i){
|
||||
std::cout << " x: " << values.possible_positions[i].x << " y: " << values.possible_positions[i].y << std::endl;
|
||||
}
|
||||
|
||||
std::cout << "POSSIBLE POSITIONS 4"<< std::endl;
|
||||
*/
|
||||
for (int i = 0; i < positions.size(); ++i) {
|
||||
Scene::Position* point = scene.add_position();
|
||||
point->set_pos_x(positions[i].x);
|
||||
point->set_pos_y(positions[i].y);
|
||||
|
||||
//std::cout << " x: " << point->pos_x() << " y: " << point->pos_y() << std::endl;
|
||||
}
|
||||
|
||||
if (_communication->GetMode() == Mode::STEREO) {
|
||||
|
|
|
@ -58,8 +58,8 @@ namespace carla {
|
|||
}
|
||||
|
||||
void TCPServer::writeString(const std::string &message, error_code &error) {
|
||||
|
||||
std::string outMessage(GetBytes(message.length()) + message);
|
||||
const int messageSize = static_cast<int>(message.length());
|
||||
std::string outMessage(GetBytes(messageSize) + message);
|
||||
|
||||
boost::asio::write(_socket, boost::asio::buffer(outMessage), error);
|
||||
|
||||
|
@ -124,7 +124,7 @@ namespace carla {
|
|||
_socket.close();
|
||||
_socket.shutdown(boost::asio::ip::tcp::socket::shutdown_both);
|
||||
_acceptor.cancel();*/
|
||||
|
||||
|
||||
}
|
||||
|
||||
} // namespace server
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
syntax = "proto2";
|
||||
|
||||
// Client Messages
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -1,26 +1,8 @@
|
|||
add_executable(test_async_server async_server.cpp)
|
||||
target_link_libraries(test_async_server
|
||||
carla_server
|
||||
${Protobuf_LIBRARIES}
|
||||
${CMAKE_THREAD_LIBS_INIT}
|
||||
${Boost_DATE_TIME_LIBRARY}
|
||||
${Boost_REGEX_LIBRARY}
|
||||
${Boost_SYSTEM_LIBRARY})
|
||||
target_link_libraries(test_async_server ${CarlaServer_LIBRARIES})
|
||||
|
||||
add_executable(test_sync_server sync_server.cpp)
|
||||
target_link_libraries(test_sync_server
|
||||
carla_server
|
||||
${Protobuf_LIBRARIES}
|
||||
${CMAKE_THREAD_LIBS_INIT}
|
||||
${Boost_DATE_TIME_LIBRARY}
|
||||
${Boost_REGEX_LIBRARY}
|
||||
${Boost_SYSTEM_LIBRARY})
|
||||
target_link_libraries(test_sync_server ${CarlaServer_LIBRARIES})
|
||||
|
||||
add_executable(test_client client.cpp)
|
||||
target_link_libraries(test_client
|
||||
carla_server
|
||||
${Protobuf_LIBRARIES}
|
||||
${CMAKE_THREAD_LIBS_INIT}
|
||||
${Boost_DATE_TIME_LIBRARY}
|
||||
${Boost_REGEX_LIBRARY}
|
||||
${Boost_SYSTEM_LIBRARY})
|
||||
target_link_libraries(test_client ${CarlaServer_LIBRARIES})
|
||||
|
|
|
@ -30,8 +30,8 @@ static std::string daytimeString() {
|
|||
static std::vector<carla::Color> makeImage(uint32_t width, uint32_t height) {
|
||||
// Xisco's magic image generator.
|
||||
std::vector<unsigned char> img(width * height * 4);
|
||||
for (int i = 0; i < height; ++i) {
|
||||
for (int e = 0; e < width; ++e) {
|
||||
for (uint32_t i = 0; i < height; ++i) {
|
||||
for (uint32_t e = 0; e < width; ++e) {
|
||||
img[4 * width * i + 4 * e + 0] = 255 * !(e & i);
|
||||
img[4 * width * i + 4 * e + 1] = e ^ i;
|
||||
img[4 * width * i + 4 * e + 2] = e | i;
|
||||
|
|
Loading…
Reference in New Issue