Fix python3

This commit is contained in:
Bernd Gassmann 2020-03-24 14:49:46 +01:00
parent eea9359527
commit c64472b40f
4 changed files with 36 additions and 11 deletions

View File

@ -53,6 +53,7 @@ def get_libcarla_extensions():
if 'BUILD_RSS_VARIANT' in os.environ and os.environ['BUILD_RSS_VARIANT'] == 'true':
print('Building AD RSS variant.')
extra_compile_args += ['-DLIBCARLA_RSS_ENABLED']
extra_compile_args += ['-DLIBCARLA_PYTHON_MAJOR_' + str(sys.version_info[0])]
extra_link_args += [os.path.join(pwd, 'dependencies/lib/libad_rss_map_integration_python' + str(sys.version_info[0]) + '.a')]
extra_link_args += [os.path.join(pwd, 'dependencies/lib/libad_rss_map_integration.a')]
extra_link_args += [os.path.join(pwd, 'dependencies/lib/libad_map_access_python' + str(sys.version_info[0]) + '.a')]

View File

@ -10,6 +10,24 @@
#include <ad/rss/world/RssDynamics.hpp>
#include <boost/python/suite/indexing/vector_indexing_suite.hpp>
#ifdef LIBCARLA_PYTHON_MAJOR_2
extern "C" {
void initlibad_physics_python();
void initlibad_rss_python();
void initlibad_map_access_python();
void initlibad_rss_map_integration_python();
}
#endif
#ifdef LIBCARLA_PYTHON_MAJOR_3
extern "C" {
void PyInit_libad_physics_python();
void PyInit_libad_rss_python();
void PyInit_libad_map_access_python();
void PyInit_libad_rss_map_integration_python();
}
#endif
namespace carla {
namespace rss {
@ -61,6 +79,22 @@ static auto GetVisualizationMode(const carla::client::RssSensor &self) {
}
void export_ad_rss() {
#ifdef LIBCARLA_PYTHON_MAJOR_2
initlibad_physics_python();
initlibad_rss_python();
initlibad_map_access_python();
initlibad_rss_map_integration_python();
#endif
#ifdef LIBCARLA_PYTHON_MAJOR_3
PyInit_libad_physics_python();
PyInit_libad_rss_python();
PyInit_libad_map_access_python();
PyInit_libad_rss_map_integration_python();
#endif
using namespace boost::python;
namespace cc = carla::client;
namespace cs = carla::sensor;

View File

@ -198,12 +198,6 @@ static auto MakeCallback(boost::python::object callback) {
#ifdef LIBCARLA_RSS_ENABLED
#include "AdRss.cpp"
extern "C" {
void initlibad_physics_python();
void initlibad_rss_python();
void initlibad_map_access_python();
void initlibad_rss_map_integration_python();
}
#endif
@ -226,10 +220,6 @@ BOOST_PYTHON_MODULE(libcarla) {
export_commands();
export_trafficmanager();
# ifdef LIBCARLA_RSS_ENABLED
initlibad_physics_python();
initlibad_rss_python();
initlibad_map_access_python();
initlibad_rss_map_integration_python();
export_ad_rss();
# endif
}

View File

@ -595,7 +595,7 @@ class HUD(object):
pygame.draw.rect(display, (255, 0, 0), rect)
text_color = (255, 0, 0)
item = item[0]
if isinstance(item, basestring) and len(item) > 0: # At this point has to be a str.
if len(item) > 0: # At this point has to be a str.
surface = self._font_mono.render(item, True, text_color)
display.blit(surface, (8, v_offset))
v_offset += 18