Merge branch 'dev' into issue2

This commit is contained in:
nsubiron 2018-01-11 14:51:30 +01:00
commit 9b409cd56b
14 changed files with 85 additions and 54 deletions

View File

@ -1,13 +1,27 @@
language: python language: python
os: linux
dist: trusty # xenial is not yet supported.
env: TEST="Pylint"
python: python:
- "2.7"
- "3.5" - "3.5"
- "3.6" - "3.6"
- "2.7"
install: install:
- pip install -r PythonClient/requirements.txt - pip install -r PythonClient/requirements.txt
- pip install pylint - pip install pylint
script: script:
- pylint --errors-only --rcfile=PythonClient/.pylintrc PythonClient/carla PythonClient/*.py - pylint --disable=R,C --rcfile=PythonClient/.pylintrc PythonClient/carla PythonClient/*.py
matrix:
include:
- env: TEST="CppCheck"
install: true
addons:
apt:
packages:
- cppcheck
script:
- cppcheck Unreal/CarlaUE4/Source Unreal/CarlaUE4/Plugins/Carla/Source Util/ -iUtil/Build -iUtil/CarlaServer/source/carla/server/carla_server.pb.cc --quiet --error-exitcode=1 --enable=warning

View File

@ -15,7 +15,7 @@ Reporting bugs
-------------- --------------
Use our [issue section](issueslink) on GitHub. Please check before that the Use our [issue section](issueslink) on GitHub. Please check before that the
issue was not already added. issue is not already reported.
[issueslink]: https://github.com/carla-simulator/carla/issues [issueslink]: https://github.com/carla-simulator/carla/issues
@ -31,10 +31,14 @@ your request as a new issue.
Code contributions Code contributions
------------------ ------------------
So you are considering making a code contribution, great! we love to have
contributions from the community.
Before starting hands-on on coding, please check out the Before starting hands-on on coding, please check out the
[projects page][projectslink] to see if we are already working on that. In case [projects page][projectslink] to see if we are already working on that, it would
of doubt or to discuss how to proceed, please contact one of us (or send an be a pity putting an effort into something just to discover that someone else
email to carla.simulator@gmail.com). was already working on that. In case of doubt or to discuss how to proceed,
please contact one of us (or send an email to carla.simulator@gmail.com).
[projectslink]: https://github.com/carla-simulator/carla/projects/1 [projectslink]: https://github.com/carla-simulator/carla/projects/1
@ -42,22 +46,40 @@ email to carla.simulator@gmail.com).
Check out the ["CARLA Design"](carla_design.md) document to get an idea on the Check out the ["CARLA Design"](carla_design.md) document to get an idea on the
different modules that compose CARLA, and chose the most appropriate one to hold different modules that compose CARLA, and chose the most appropriate one to hold
the new feature. the new feature. We are aware the developers documentation is still scarce,
please ask us in case of doubt, and of course don't hesitate to improve the
current documentation if you feel confident enough.
#### Coding style #### Coding standard
Please follow the current coding style when submitting new code. Please follow the current coding style when submitting new code.
###### General
* Use spaces, not tabs. * Use spaces, not tabs.
* Comments should not exceed 80 columns, code may exceed this limit a bit in rare * Avoid adding trailing whitespace as it creates noise in the diffs.
occasions if it results in clearer code. * Comments should not exceed 80 columns, code may exceed this limit a bit in rare occasions if it results in clearer code.
###### Python
* All code must be compatible with Python 2.7, 3.5, and 3.6.
* [Pylint](https://www.pylint.org/) should not give any error or warning (few exceptions apply with external classes like `numpy`, see our `.pylintrc`).
* Python code follows [PEP8 style guide](https://www.python.org/dev/peps/pep-0008/) (use `autopep8` whenever possible). * Python code follows [PEP8 style guide](https://www.python.org/dev/peps/pep-0008/) (use `autopep8` whenever possible).
* Unreal C++ code, CarlaUE4 and Carla plugin, follow the [Unreal Engine's Coding Standard](https://docs.unrealengine.com/latest/INT/Programming/Development/CodingStandard/) with the exception of using spaces instead of tabs.
###### C++
* Compilation should not give any error or warning (`clang++ -Wall -Wextra -std=C++14`).
* Unreal C++ code (CarlaUE4 and Carla plugin) follow the [Unreal Engine's Coding Standard](https://docs.unrealengine.com/latest/INT/Programming/Development/CodingStandard/) with the exception of using spaces instead of tabs.
* CarlaServer uses [Google's style guide](https://google.github.io/styleguide/cppguide.html). * CarlaServer uses [Google's style guide](https://google.github.io/styleguide/cppguide.html).
#### Pull request #### Pull-requests
Once you think your contribution is ready to be added to CARLA, please submit a Once you think your contribution is ready to be added to CARLA, please submit a
pull request and one of our team members will take a look at it. pull-request to the `dev` branch.
Try to be as descriptive as possible when filling the pull-request description. Try to be as descriptive as possible when filling the pull-request description.
Please note that there are some checks that the new code is required to pass
before we can do the merge. The checks are automatically run by the continuous
integration system, you will see a green tick mark if all the checks succeeded.
If you see a red mark, please correct your code accordingly.

View File

@ -1,3 +1,4 @@
[TYPECHECK] [TYPECHECK]
ignored-modules=ConfigParser,numpy,pygame,shutil ignore=carla_server_pb2.py
ignored-classes=_socketobject ignored-modules=ConfigParser,numpy,numpy.random,pygame,shutil
ignored-classes=_socketobject,EpisodeReady

View File

@ -17,7 +17,6 @@ from . import util
try: try:
from . import carla_server_pb2 as carla_protocol from . import carla_server_pb2 as carla_protocol
from carla_protocol import EpisodeReady
except ImportError: except ImportError:
raise RuntimeError('cannot import "carla_server_pb2.py", run the protobuf compiler to generate this file') raise RuntimeError('cannot import "carla_server_pb2.py", run the protobuf compiler to generate this file')
@ -97,7 +96,7 @@ class CarlaClient(object):
data = self._world_client.read() data = self._world_client.read()
if not data: if not data:
raise RuntimeError('failed to read data from server') raise RuntimeError('failed to read data from server')
pb_message = EpisodeReady() pb_message = carla_protocol.EpisodeReady()
pb_message.ParseFromString(data) pb_message.ParseFromString(data)
if not pb_message.ready: if not pb_message.ready:
raise RuntimeError('cannot start episode: server failed to start episode') raise RuntimeError('cannot start episode: server failed to start episode')
@ -160,7 +159,7 @@ class CarlaClient(object):
raise RuntimeError('failed to read data from server') raise RuntimeError('failed to read data from server')
pb_message = carla_protocol.SceneDescription() pb_message = carla_protocol.SceneDescription()
pb_message.ParseFromString(data) pb_message.ParseFromString(data)
self._sensor_names = settings._get_sensor_names(carla_settings) self._sensor_names = settings.get_sensor_names(carla_settings)
self._is_episode_requested = True self._is_episode_requested = True
return pb_message return pb_message

View File

@ -38,14 +38,14 @@ class CarlaMap(object):
city_map_file = os.path.join(dir_path, city + '.png') city_map_file = os.path.join(dir_path, city + '.png')
city_map_file_lanes = os.path.join(dir_path, city + 'Lanes.png') city_map_file_lanes = os.path.join(dir_path, city + 'Lanes.png')
with open(city_file, 'r') as file: with open(city_file, 'r') as file_object:
linewordloffset = file.readline() linewordloffset = file_object.readline()
# The offset of the world from the zero coordinates ( The # The offset of the world from the zero coordinates ( The
# coordinate we consider zero) # coordinate we consider zero)
self.worldoffset = string_to_floats(linewordloffset) self.worldoffset = string_to_floats(linewordloffset)
lineworldangles = file.readline() lineworldangles = file_object.readline()
self.angles = string_to_floats(lineworldangles) self.angles = string_to_floats(lineworldangles)
self.worldrotation = np.array([ self.worldrotation = np.array([
@ -55,14 +55,14 @@ class CarlaMap(object):
# Ignore for now, these are offsets for map coordinates and scale # Ignore for now, these are offsets for map coordinates and scale
# (not used). # (not used).
_ = file.readline() _ = file_object.readline()
linemapoffset = file.readline() linemapoffset = file_object.readline()
# The offset of the map zero coordinate. # The offset of the map zero coordinate.
self.mapoffset = string_to_floats(linemapoffset) self.mapoffset = string_to_floats(linemapoffset)
# the graph resolution. # the graph resolution.
linegraphres = file.readline() linegraphres = file_object.readline()
self.resolution = string_to_node(linegraphres) self.resolution = string_to_node(linegraphres)
# The number of game units per pixel. # The number of game units per pixel.

View File

@ -113,7 +113,7 @@ class Image(SensorData):
size=(self.width, self.height), size=(self.width, self.height),
data=self.raw_data, data=self.raw_data,
decoder_name='raw') decoder_name='raw')
b, g, r, a = image.split() b, g, r, _ = image.split()
image = PImage.merge("RGB", (r, g, b)) image = PImage.merge("RGB", (r, g, b))
folder = os.path.dirname(filename) folder = os.path.dirname(filename)

View File

@ -122,18 +122,21 @@ class CarlaSettings(object):
return text.getvalue().replace(' = ', '=') return text.getvalue().replace(' = ', '=')
def _get_sensor_names(settings): def get_sensor_names(settings):
""" """
Return a list with the names of the sensors defined in the settings object. Return a list with the names of the sensors defined in the settings object.
The settings object can be a CarlaSettings or an INI formatted string. The settings object can be a CarlaSettings or an INI formatted string.
""" """
if isinstance(settings, CarlaSettings): if isinstance(settings, CarlaSettings):
# pylint: disable=protected-access
return [camera.CameraName for camera in settings._cameras] return [camera.CameraName for camera in settings._cameras]
ini = ConfigParser() ini = ConfigParser()
if sys.version_info >= (3, 0): if sys.version_info >= (3, 2):
ini.readfp(io.StringIO(settings)) ini.read_string(settings)
elif sys.version_info >= (3, 0):
ini.readfp(io.StringIO(settings)) # pylint: disable=deprecated-method
else: else:
ini.readfp(io.BytesIO(settings)) ini.readfp(io.BytesIO(settings)) # pylint: disable=deprecated-method
section_name = 'CARLA/SceneCapture' section_name = 'CARLA/SceneCapture'
option_name = 'Cameras' option_name = 'Cameras'

View File

@ -39,19 +39,18 @@ class TCPClient(object):
try: try:
self._socket = socket.create_connection(address=(self._host, self._port), timeout=self._timeout) self._socket = socket.create_connection(address=(self._host, self._port), timeout=self._timeout)
self._socket.settimeout(self._timeout) self._socket.settimeout(self._timeout)
logging.debug(self._logprefix + 'connected') logging.debug('%sconnected', self._logprefix)
return return
except Exception as exception: except OSError as exception:
error = exception error = exception
logging.debug(self._logprefix + 'connection attempt %d: %s', attempt, error) logging.debug('%sconnection attempt %d: %s', self._logprefix, attempt, error)
time.sleep(1) time.sleep(1)
continue
self._reraise_exception_as_tcp_error('failed to connect', error) self._reraise_exception_as_tcp_error('failed to connect', error)
def disconnect(self): def disconnect(self):
"""Disconnect any active connection.""" """Disconnect any active connection."""
if self._socket is not None: if self._socket is not None:
logging.debug(self._logprefix + 'disconnecting') logging.debug('%sdisconnecting', self._logprefix)
self._socket.close() self._socket.close()
self._socket = None self._socket = None
@ -66,7 +65,7 @@ class TCPClient(object):
header = struct.pack('<L', len(message)) header = struct.pack('<L', len(message))
try: try:
self._socket.sendall(header + message) self._socket.sendall(header + message)
except Exception as exception: except OSError as exception:
self._reraise_exception_as_tcp_error('failed to write data', exception) self._reraise_exception_as_tcp_error('failed to write data', exception)
def read(self): def read(self):
@ -86,7 +85,7 @@ class TCPClient(object):
while length > 0: while length > 0:
try: try:
data = self._socket.recv(length) data = self._socket.recv(length)
except Exception as exception: except OSError as exception:
self._reraise_exception_as_tcp_error('failed to read data', exception) self._reraise_exception_as_tcp_error('failed to read data', exception)
if not data: if not data:
raise TCPConnectionError(self._logprefix + 'connection closed') raise TCPConnectionError(self._logprefix + 'connection closed')

View File

@ -53,9 +53,9 @@ else:
# Workaround for older Python versions. # Workaround for older Python versions.
def print_over_same_line(text): def print_over_same_line(text):
line_length = max(print_over_same_line._last_line_length, len(text)) line_length = max(print_over_same_line.last_line_length, len(text))
empty_space = max(0, line_length - len(text)) empty_space = max(0, line_length - len(text))
sys.stdout.write('\r' + text + empty_space * ' ') sys.stdout.write('\r' + text + empty_space * ' ')
sys.stdout.flush() sys.stdout.flush()
print_over_same_line._last_line_length = line_length print_over_same_line.last_line_length = line_length
print_over_same_line._last_line_length = 0 print_over_same_line.last_line_length = 0

View File

@ -13,7 +13,6 @@ from __future__ import print_function
import argparse import argparse
import logging import logging
import random import random
import sys
import time import time
from carla.client import make_carla_client from carla.client import make_carla_client
@ -213,14 +212,10 @@ def main():
settings_filepath=args.carla_settings) settings_filepath=args.carla_settings)
print('Done.') print('Done.')
return
except TCPConnectionError as error: except TCPConnectionError as error:
logging.error(error) logging.error(error)
time.sleep(1) time.sleep(1)
except Exception as exception:
logging.exception(exception)
sys.exit(1)
if __name__ == '__main__': if __name__ == '__main__':

View File

@ -30,7 +30,6 @@ from __future__ import print_function
import argparse import argparse
import logging import logging
import random import random
import sys
import time import time
try: try:
@ -131,6 +130,8 @@ class CarlaGame(object):
self._map = CarlaMap(city_name) if city_name is not None else None self._map = CarlaMap(city_name) if city_name is not None else None
self._map_shape = self._map.map_image.shape if city_name is not None else None self._map_shape = self._map.map_image.shape if city_name is not None else None
self._map_view = self._map.get_map(WINDOW_HEIGHT) if city_name is not None else None self._map_view = self._map.get_map(WINDOW_HEIGHT) if city_name is not None else None
self._position = None
self._agent_positions = None
def execute(self): def execute(self):
"""Launch the PyGame.""" """Launch the PyGame."""
@ -363,9 +364,6 @@ def main():
except TCPConnectionError as error: except TCPConnectionError as error:
logging.error(error) logging.error(error)
time.sleep(1) time.sleep(1)
except Exception as exception:
logging.exception(exception)
sys.exit(1)
if __name__ == '__main__': if __name__ == '__main__':

View File

@ -102,7 +102,7 @@ private:
USceneComponent *SceneRootComponent; USceneComponent *SceneRootComponent;
UPROPERTY(Category = "Map Generation", VisibleAnywhere) UPROPERTY(Category = "Map Generation", VisibleAnywhere)
float MapScale; float MapScale = 1.0f;
UPROPERTY(Category = "Meshes", EditAnywhere) UPROPERTY(Category = "Meshes", EditAnywhere)
TMap<ECityMapMeshTag, UStaticMesh *> StaticMeshes; TMap<ECityMapMeshTag, UStaticMesh *> StaticMeshes;

View File

@ -1,4 +1,4 @@
CXX=g++ CXX=clang++
FLAGS=-Wall -Wextra -std=c++14 -fopenmp FLAGS=-Wall -Wextra -std=c++14 -fopenmp
LIBS=-lboost_system -lboost_filesystem -lboost_program_options -lpng -ljpeg -ltiff LIBS=-lboost_system -lboost_filesystem -lboost_program_options -lpng -ljpeg -ltiff
HEADERS=*.h HEADERS=*.h

View File

@ -4,9 +4,9 @@ Image Converter
Converts output images of depth and semantic segmentation to a prettier format. Converts output images of depth and semantic segmentation to a prettier format.
Requires boost_system, boost_filesystem, boost_program_options, libpng, libtiff, Requires boost_system, boost_filesystem, boost_program_options, libpng, libtiff,
libjpeg and openmp. libjpeg and libomp.
Compile with `g++ -std=c++14 -fopenmp`, for the default compilation just run Compile with `clang++ -std=c++14 -fopenmp`, for the default compilation just run
make make
make make