Skip to content

Commit

Permalink
Merge branch 'dev' into overhaul-agent-parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
Daraan authored Mar 27, 2024
2 parents bb1c98f + d5d3cf9 commit af05e51
Show file tree
Hide file tree
Showing 33 changed files with 948 additions and 383 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@
* Added functions to get actor' bones and components names
* Added functions to get actor' sockets transforms
* make PythonAPI Windows: Fixed incompatibility issue with Anaconda due `py` command.
* Added function to get actor' sockets names
* Fixed bug in python agents when vehicle list was empty causing a check on all vehicles (BasicAgent.py) and detected pedestrians as vehicles if no pedestrains are present (BehaviourAgent.py)
* Extended debug drawing functions to allow drawing primitives on HUD layer
* Added possibility to change gravity variable in imui sensor for the accelerometer
* Fixed ROS2 native extension build error when ROS2 is installed in the system.
* ROS2Native: Force fast-dds dependencies download to avoid build crash when boost_asio and tinyxml2 are not installed in Linux.
* Unified the settings of the Python agents to use a dictionary structure for most of their parameters which further allows more dynamic changes.

## CARLA 0.9.15
Expand Down Expand Up @@ -39,6 +43,8 @@
* Fixed bug causing the `FPixelReader::SavePixelsToDisk(PixelData, FilePath)` function to crash due to pixel array not set correctly.
* Fixed segfaults in Python API due to incorrect GIL locking under Python 3.10.
* Fixed the import script, where could use any other TilesInfo.txt if the destination folder has many
* Fixed PythonAPI not installing on Debian due to deprecated function of distro in setup.py. Less ambiguous error for other posix platforms.


## CARLA 0.9.14

Expand Down
2 changes: 1 addition & 1 deletion Co-Simulation/Sumo/sumo_integration/sumo_simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ def _get_sumo_net(cfg_file):
net_file = os.path.join(os.path.dirname(cfg_file), tag.get('value'))
logging.debug('Reading net file: %s', net_file)

sumo_net = traci.sumolib.net.readNet(net_file)
sumo_net = sumolib.net.readNet(net_file)
return sumo_net

class SumoSimulation(object):
Expand Down
514 changes: 273 additions & 241 deletions Docs/python_api.md

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions LibCarla/source/carla/client/Actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ namespace client {
return GetEpisode().Lock()->GetActorSocketRelativeTransforms(*this);
}

std::vector<std::string> Actor::GetSocketNames() const {
return GetEpisode().Lock()->GetActorSocketNames(*this);
}

void Actor::SetLocation(const geom::Location &location) {
GetEpisode().Lock()->SetActorLocation(*this, location);
}
Expand Down
2 changes: 2 additions & 0 deletions LibCarla/source/carla/client/Actor.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ namespace client {

std::vector<geom::Transform> GetSocketRelativeTransforms() const;

std::vector<std::string> GetSocketNames() const;

/// Teleport the actor to @a location.
void SetLocation(const geom::Location &location);

Expand Down
45 changes: 45 additions & 0 deletions LibCarla/source/carla/client/DebugHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,16 @@ namespace client {
DrawShape(_episode, point, color, life_time, persistent_lines);
}

void DebugHelper::DrawHUDPoint(
const geom::Location &location,
float size,
sensor::data::Color color,
float life_time,
bool persistent_lines) {
Shape::HUDPoint point{location, size};
DrawShape(_episode, point, color, life_time, persistent_lines);
}

void DebugHelper::DrawLine(
const geom::Location &begin,
const geom::Location &end,
Expand All @@ -46,6 +56,17 @@ namespace client {
DrawShape(_episode, line, color, life_time, persistent_lines);
}

void DebugHelper::DrawHUDLine(
const geom::Location &begin,
const geom::Location &end,
float thickness,
Color color,
float life_time,
bool persistent_lines) {
Shape::HUDLine line{begin, end, thickness};
DrawShape(_episode, line, color, life_time, persistent_lines);
}

void DebugHelper::DrawArrow(
const geom::Location &begin,
const geom::Location &end,
Expand All @@ -59,6 +80,19 @@ namespace client {
DrawShape(_episode, arrow, color, life_time, persistent_lines);
}

void DebugHelper::DrawHUDArrow(
const geom::Location &begin,
const geom::Location &end,
float thickness,
float arrow_size,
sensor::data::Color color,
float life_time,
bool persistent_lines) {
Shape::HUDLine line{begin, end, thickness};
Shape::HUDArrow arrow{line, arrow_size};
DrawShape(_episode, arrow, color, life_time, persistent_lines);
}

void DebugHelper::DrawBox(
const geom::BoundingBox &box,
const geom::Rotation &rotation,
Expand All @@ -70,6 +104,17 @@ namespace client {
DrawShape(_episode, the_box, color, life_time, persistent_lines);
}

void DebugHelper::DrawHUDBox(
const geom::BoundingBox &box,
const geom::Rotation &rotation,
float thickness,
sensor::data::Color color,
float life_time,
bool persistent_lines) {
Shape::HUDBox the_box{box, rotation, thickness};
DrawShape(_episode, the_box, color, life_time, persistent_lines);
}

void DebugHelper::DrawString(
const geom::Location &location,
const std::string &text,
Expand Down
32 changes: 32 additions & 0 deletions LibCarla/source/carla/client/DebugHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ namespace client {
float life_time = -1.0f,
bool persistent_lines = true);

void DrawHUDPoint(
const geom::Location &location,
float size = 0.1f,
Color color = Color{255u, 0u, 0u},
float life_time = -1.0f,
bool persistent_lines = true);

void DrawLine(
const geom::Location &begin,
const geom::Location &end,
Expand All @@ -38,6 +45,14 @@ namespace client {
float life_time = -1.0f,
bool persistent_lines = true);

void DrawHUDLine(
const geom::Location &begin,
const geom::Location &end,
float thickness = 1.0f,
Color color = Color{225u, 0u, 0u},
float life_time = -1.0f,
bool presistent_lines = true);

void DrawArrow(
const geom::Location &begin,
const geom::Location &end,
Expand All @@ -47,6 +62,15 @@ namespace client {
float life_time = -1.0f,
bool persistent_lines = true);

void DrawHUDArrow(
const geom::Location &begin,
const geom::Location &end,
float thickness = 0.1f,
float arrow_size = 0.1f,
Color color = Color{255u, 0u, 0u},
float life_time = -1.0f,
bool persistent_lines = true);

void DrawBox(
const geom::BoundingBox &box,
const geom::Rotation &rotation,
Expand All @@ -55,6 +79,14 @@ namespace client {
float life_time = -1.0f,
bool persistent_lines = true);

void DrawHUDBox(
const geom::BoundingBox &box,
const geom::Rotation &rotation,
float thickness = 0.1f,
Color color = Color{255u, 0u, 0u},
float life_time = -1.0f,
bool persistent_lines = true);

void DrawString(
const geom::Location &location,
const std::string &text,
Expand Down
1 change: 1 addition & 0 deletions LibCarla/source/carla/client/FileTransfer.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <iostream>
#include <string>
#include <sys/stat.h>
#include <cstdint>

namespace carla {
namespace client {
Expand Down
4 changes: 4 additions & 0 deletions LibCarla/source/carla/client/Vehicle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,10 @@ namespace client {
BaseJSONPath);
}

void Vehicle::RestorePhysXPhysics() {
GetEpisode().Lock()->RestorePhysXPhysics(*this);
}

rpc::VehicleFailureState Vehicle::GetFailureState() const {
return GetEpisode().Lock()->GetActorSnapshot(*this).state.vehicle_data.failure_state;
}
Expand Down
2 changes: 2 additions & 0 deletions LibCarla/source/carla/client/Vehicle.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ namespace client {
std::string TireJSON = "",
std::string BaseJSONPath = "");

void RestorePhysXPhysics();

/// Returns the failure state of the vehicle
rpc::VehicleFailureState GetFailureState() const;

Expand Down
9 changes: 9 additions & 0 deletions LibCarla/source/carla/client/detail/Client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,11 @@ namespace detail {
return _pimpl->CallAndWait<return_t>("get_actor_socket_relative_transforms", actor);
}

std::vector<std::string> Client::GetActorSocketNames(rpc::ActorId actor) {
using return_t = std::vector<std::string>;
return _pimpl->CallAndWait<return_t>("get_actor_socket_names", actor);
}

void Client::SetActorSimulatePhysics(rpc::ActorId actor, const bool enabled) {
_pimpl->CallAndWait<void>("set_actor_simulate_physics", actor, enabled);
}
Expand Down Expand Up @@ -523,6 +528,10 @@ namespace detail {
BaseJSONPath);
}

void Client::RestorePhysXPhysics(rpc::ActorId vehicle) {
_pimpl->AsyncCall("restore_physx_physics", vehicle);
}

void Client::ApplyControlToWalker(rpc::ActorId walker, const rpc::WalkerControl &control) {
_pimpl->AsyncCall("apply_control_to_walker", walker, control);
}
Expand Down
5 changes: 5 additions & 0 deletions LibCarla/source/carla/client/detail/Client.h
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,9 @@ namespace detail {
std::vector<geom::Transform> GetActorSocketRelativeTransforms(
rpc::ActorId actor);

std::vector<std::string> GetActorSocketNames(
rpc::ActorId actor);

void SetActorSimulatePhysics(
rpc::ActorId actor,
bool enabled);
Expand Down Expand Up @@ -328,6 +331,8 @@ namespace detail {
std::string TireJSON,
std::string BaseJSONPath);

void RestorePhysXPhysics(rpc::ActorId vehicle);

void ApplyControlToWalker(
rpc::ActorId walker,
const rpc::WalkerControl &control);
Expand Down
8 changes: 8 additions & 0 deletions LibCarla/source/carla/client/detail/Simulator.h
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,10 @@ namespace detail {
return _client.GetActorSocketRelativeTransforms(actor.GetId());
}

std::vector<std::string> GetActorSocketNames(const Actor &actor) {
return _client.GetActorSocketNames(actor.GetId());
}

void SetActorLocation(Actor &actor, const geom::Location &location) {
_client.SetActorLocation(actor.GetId(), location);
}
Expand Down Expand Up @@ -613,6 +617,10 @@ namespace detail {
BaseJSONPath);
}

void RestorePhysXPhysics(Vehicle &vehicle) {
_client.RestorePhysXPhysics(vehicle.GetId());
}

/// @}
// =========================================================================
/// @name Operations with the recorder
Expand Down
28 changes: 27 additions & 1 deletion LibCarla/source/carla/rpc/DebugShape.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,34 +35,60 @@ namespace rpc {
MSGPACK_DEFINE_ARRAY(location, size);
};

struct HUDPoint {
geom::Location location;
float size;
MSGPACK_DEFINE_ARRAY(location, size);
};

struct Line {
geom::Location begin;
geom::Location end;
float thickness;
MSGPACK_DEFINE_ARRAY(begin, end, thickness);
};

struct HUDLine {
geom::Location begin;
geom::Location end;
float thickness;
MSGPACK_DEFINE_ARRAY(begin, end, thickness);
};

struct Arrow {
Line line;
float arrow_size;
MSGPACK_DEFINE_ARRAY(line, arrow_size);
};

struct HUDArrow {
HUDLine line;
float arrow_size;
MSGPACK_DEFINE_ARRAY(line, arrow_size);
};

struct Box {
geom::BoundingBox box;
geom::Rotation rotation;
float thickness;
MSGPACK_DEFINE_ARRAY(box, rotation, thickness);
};

struct HUDBox {
geom::BoundingBox box;
geom::Rotation rotation;
float thickness;
MSGPACK_DEFINE_ARRAY(box, rotation, thickness);
};

struct String {
geom::Location location;
std::string text;
bool draw_shadow;
MSGPACK_DEFINE_ARRAY(location, text, draw_shadow);
};

boost::variant2::variant<Point, Line, Arrow, Box, String> primitive;
boost::variant2::variant<Point, Line, Arrow, Box, String, HUDPoint, HUDLine, HUDArrow, HUDBox> primitive;

Color color = {255u, 0u, 0u};

Expand Down
9 changes: 5 additions & 4 deletions PythonAPI/carla/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ def walk(folder, file_filter='*'):

if os.name == "posix":
import distro

linux_distro = distro.linux_distribution()[0]
if linux_distro.lower() in ["ubuntu", "debian", "deepin"]:
supported_dists = ["ubuntu", "debian", "deepin"]

linux_distro = distro.id().lower()
if linux_distro in supported_dists:
pwd = os.path.dirname(os.path.realpath(__file__))
pylib = "libboost_python%d%d.a" % (sys.version_info.major,
sys.version_info.minor)
Expand Down Expand Up @@ -101,7 +102,7 @@ def walk(folder, file_filter='*'):
# extra_link_args += ['/usr/lib/gcc/x86_64-linux-gnu/7/libstdc++.a']
extra_link_args += ['-lstdc++']
else:
raise NotImplementedError
raise NotImplementedError(linux_distro + " not in supported posix platforms: " + str(supported_dists))
elif os.name == "nt":
pwd = os.path.dirname(os.path.realpath(__file__))
pylib = 'libboost_python%d%d' % (
Expand Down
4 changes: 3 additions & 1 deletion PythonAPI/carla/source/libcarla/Actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ void export_actor() {
.def("get_component_names", CALL_RETURNING_LIST(cc::Actor,GetComponentNames))
.def("get_bone_names", CALL_RETURNING_LIST(cc::Actor,GetBoneNames))
.def("get_socket_world_transforms", CALL_RETURNING_LIST(cc::Actor,GetSocketWorldTransforms))
.def("get_socket_relative_transforms", CALL_RETURNING_LIST(cc::Actor,GetSocketRelativeTransforms))
.def("get_socket_relative_transforms", CALL_RETURNING_LIST(cc::Actor,GetSocketRelativeTransforms))
.def("get_socket_names", CALL_RETURNING_LIST(cc::Actor,GetSocketNames))
.def("set_location", &cc::Actor::SetLocation, (arg("location")))
.def("set_transform", &cc::Actor::SetTransform, (arg("transform")))
.def("set_target_velocity", &cc::Actor::SetTargetVelocity, (arg("velocity")))
Expand Down Expand Up @@ -202,6 +203,7 @@ void export_actor() {
.def("enable_carsim", &cc::Vehicle::EnableCarSim, (arg("simfile_path") = ""))
.def("use_carsim_road", &cc::Vehicle::UseCarSimRoad, (arg("enabled")))
.def("enable_chrono_physics", &cc::Vehicle::EnableChronoPhysics, (arg("max_substeps")=30, arg("max_substep_delta_time")=0.002, arg("vehicle_json")="", arg("powetrain_json")="", arg("tire_json")="", arg("base_json_path")=""))
.def("restore_physx_physics", &cc::Vehicle::RestorePhysXPhysics)
.def("get_failure_state", &cc::Vehicle::GetFailureState)
.def(self_ns::str(self_ns::self))
;
Expand Down
Loading

0 comments on commit af05e51

Please sign in to comment.