Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## LATEST Changes

* Fixed compiler warnings across 20 LibCarla files including signed/unsigned conversions, pessimizing moves, deep copies in range-for loops, and C-style casts (ported from ue4-dev)
* Fix typos in README.md
* Added actor description as Actor TAGs
* Create class with functions to import points and polylines from satellite segmentation (#8946, #8949 #8950)
Expand Down
2 changes: 1 addition & 1 deletion LibCarla/source/carla/Exception.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ namespace boost
}

BOOST_NORETURN
inline void throw_exception(const std::exception &e, boost::source_location const& loc)
inline void throw_exception(const std::exception &e, boost::source_location const& /*loc*/)
{
throw_exception(e);
}
Expand Down
3 changes: 2 additions & 1 deletion LibCarla/source/carla/client/detail/Simulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,8 @@ EpisodeProxy Simulator::GetCurrentEpisode() {
std::string map_name;
std::string map_base_path;
bool fill_base_string = false;
for (int i = map_info.name.size() - 1; i >= 0; --i) {
for (size_t ri = map_info.name.size(); ri > 0; --ri) {
size_t i = ri - 1;
if (fill_base_string == false && map_info.name[i] != '/') {
map_name += map_info.name[i];
} else {
Expand Down
5 changes: 3 additions & 2 deletions LibCarla/source/carla/geom/Mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,8 +309,9 @@ namespace geom {
rhs.GetNormals().begin(),
rhs.GetNormals().end());

const size_t vertex_to_start_concating = v_num - num_vertices_to_link;
for( size_t i = 1; i < num_vertices_to_link; ++i ) {
const size_t vertices_to_link = static_cast<size_t>(num_vertices_to_link);
const size_t vertex_to_start_concating = v_num - vertices_to_link;
for( size_t i = 1; i < vertices_to_link; ++i ) {
_indexes.push_back( vertex_to_start_concating + i );
_indexes.push_back( vertex_to_start_concating + i + 1 );
_indexes.push_back( v_num + i );
Expand Down
8 changes: 4 additions & 4 deletions LibCarla/source/carla/geom/Simplification.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace geom {

// Reduce to the X% of the polys
float target_size = static_cast<float>(Simplification.triangles.size());
Simplification.simplify_mesh((target_size * simplification_percentage));
Simplification.simplify_mesh(static_cast<int>(target_size * simplification_percentage));

pmesh->GetVertices().clear();
pmesh->GetIndexes().clear();
Expand All @@ -46,9 +46,9 @@ namespace geom {
}

for (size_t i = 0; i < Simplification.triangles.size(); ++i) {
pmesh->GetIndexes().push_back((Simplification.triangles[i].v[0]) + 1);
pmesh->GetIndexes().push_back((Simplification.triangles[i].v[1]) + 1);
pmesh->GetIndexes().push_back((Simplification.triangles[i].v[2]) + 1);
pmesh->GetIndexes().push_back(static_cast<size_t>((Simplification.triangles[i].v[0]) + 1));
pmesh->GetIndexes().push_back(static_cast<size_t>((Simplification.triangles[i].v[1]) + 1));
pmesh->GetIndexes().push_back(static_cast<size_t>((Simplification.triangles[i].v[2]) + 1));
}
}

Expand Down
8 changes: 3 additions & 5 deletions LibCarla/source/carla/multigpu/primary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,12 @@ namespace multigpu {
return;
}

auto handle_sent = [weak, message](const boost::system::error_code &ec, size_t DEBUG_ONLY(bytes)) {
auto handle_sent = [weak, message](const boost::system::error_code &ec, size_t) {
auto self = weak.lock();
if (!self) return;
if (ec) {
log_error("session ", self->_session_id, ": error sending data: ", ec.message());
self->CloseNow(ec);
} else {
// DEBUG_ASSERT_EQ(bytes, sizeof(message_size_type) + message->size());
}
};

Expand All @@ -106,7 +104,7 @@ namespace multigpu {

// sent first size buffer
self->_deadline.expires_from_now(self->_timeout);
int this_size = text.size();
int this_size = static_cast<int>(text.size());
boost::asio::async_write(
self->_socket,
boost::asio::buffer(&this_size, sizeof(this_size)),
Expand Down Expand Up @@ -146,7 +144,7 @@ namespace multigpu {

auto handle_read_header = [weak, message, handle_read_data](
boost::system::error_code ec,
size_t DEBUG_ONLY(bytes)) {
size_t) {
auto self = weak.lock();
if (!self) return;
if (!ec && (message->size() > 0u)) {
Expand Down
26 changes: 12 additions & 14 deletions LibCarla/source/carla/multigpu/primaryCommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ void PrimaryCommands::SendFrameData(carla::Buffer buffer) {

// broadcast to all secondary servers the map to load
void PrimaryCommands::SendLoadMap(std::string map) {
carla::Buffer buf((unsigned char *) map.c_str(), (size_t) map.size() + 1);
carla::Buffer buf(reinterpret_cast<unsigned char *>(const_cast<char *>(map.c_str())), static_cast<size_t>(map.size() + 1));
_router->Write(MultiGPUCommand::LOAD_MAP, std::move(buf));
}

// send to who the router wants the request for a token
token_type PrimaryCommands::SendGetToken(stream_id sensor_id) {
log_info("asking for a token");
carla::Buffer buf((carla::Buffer::value_type *) &sensor_id,
(size_t) sizeof(stream_id));
carla::Buffer buf(reinterpret_cast<carla::Buffer::value_type *>(&sensor_id),
static_cast<size_t>(sizeof(stream_id)));
auto fut = _router->WriteToNext(MultiGPUCommand::GET_TOKEN, std::move(buf));

auto response = fut.get();
Expand All @@ -56,7 +56,7 @@ token_type PrimaryCommands::SendGetToken(stream_id sensor_id) {
// send to know if a connection is alive
void PrimaryCommands::SendIsAlive() {
std::string msg("Are you alive?");
carla::Buffer buf((unsigned char *) msg.c_str(), (size_t) msg.size());
carla::Buffer buf(reinterpret_cast<unsigned char *>(const_cast<char *>(msg.c_str())), static_cast<size_t>(msg.size()));
log_info("sending is alive command");
auto fut = _router->WriteToNext(MultiGPUCommand::YOU_ALIVE, std::move(buf));
auto response = fut.get();
Expand All @@ -67,12 +67,11 @@ void PrimaryCommands::SendEnableForROS(stream_id sensor_id) {
// search if the sensor has been activated in any secondary server
auto it = _servers.find(sensor_id);
if (it != _servers.end()) {
carla::Buffer buf((carla::Buffer::value_type *) &sensor_id,
(size_t) sizeof(stream_id));
carla::Buffer buf(reinterpret_cast<carla::Buffer::value_type *>(&sensor_id),
static_cast<size_t>(sizeof(stream_id)));
auto fut = _router->WriteToOne(it->second, MultiGPUCommand::ENABLE_ROS, std::move(buf));

auto response = fut.get();
bool res = (*reinterpret_cast<bool *>(response.buffer.data()));
fut.get();
} else {
log_error("enable_for_ros for sensor", sensor_id, " not found on any server");
}
Expand All @@ -82,12 +81,11 @@ void PrimaryCommands::SendDisableForROS(stream_id sensor_id) {
// search if the sensor has been activated in any secondary server
auto it = _servers.find(sensor_id);
if (it != _servers.end()) {
carla::Buffer buf((carla::Buffer::value_type *) &sensor_id,
(size_t) sizeof(stream_id));
carla::Buffer buf(reinterpret_cast<carla::Buffer::value_type *>(&sensor_id),
static_cast<size_t>(sizeof(stream_id)));
auto fut = _router->WriteToOne(it->second, MultiGPUCommand::DISABLE_ROS, std::move(buf));

auto response = fut.get();
bool res = (*reinterpret_cast<bool *>(response.buffer.data()));
fut.get();
} else {
log_error("disable_for_ros for sensor", sensor_id, " not found on any server");
}
Expand All @@ -97,8 +95,8 @@ bool PrimaryCommands::SendIsEnabledForROS(stream_id sensor_id) {
// search if the sensor has been activated in any secondary server
auto it = _servers.find(sensor_id);
if (it != _servers.end()) {
carla::Buffer buf((carla::Buffer::value_type *) &sensor_id,
(size_t) sizeof(stream_id));
carla::Buffer buf(reinterpret_cast<carla::Buffer::value_type *>(&sensor_id),
static_cast<size_t>(sizeof(stream_id)));
auto fut = _router->WriteToOne(it->second, MultiGPUCommand::IS_ENABLED_ROS, std::move(buf));

auto response = fut.get();
Expand Down
6 changes: 3 additions & 3 deletions LibCarla/source/carla/multigpu/router.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ void Router::Write(MultiGPUCommand id, Buffer &&buffer) {
CommandHeader header;
header.id = id;
header.size = buffer.size();
Buffer buf_header((uint8_t *) &header, sizeof(header));
Buffer buf_header(reinterpret_cast<uint8_t *>(&header), sizeof(header));

auto view_header = carla::BufferView::CreateFrom(std::move(buf_header));
auto view_data = carla::BufferView::CreateFrom(std::move(buffer));
Expand All @@ -134,7 +134,7 @@ std::future<SessionInfo> Router::WriteToNext(MultiGPUCommand id, Buffer &&buffer
CommandHeader header;
header.id = id;
header.size = buffer.size();
Buffer buf_header((uint8_t *) &header, sizeof(header));
Buffer buf_header(reinterpret_cast<uint8_t *>(&header), sizeof(header));

auto view_header = carla::BufferView::CreateFrom(std::move(buf_header));
auto view_data = carla::BufferView::CreateFrom(std::move(buffer));
Expand Down Expand Up @@ -166,7 +166,7 @@ std::future<SessionInfo> Router::WriteToOne(std::weak_ptr<Primary> server, Multi
CommandHeader header;
header.id = id;
header.size = buffer.size();
Buffer buf_header((uint8_t *) &header, sizeof(header));
Buffer buf_header(reinterpret_cast<uint8_t *>(&header), sizeof(header));

auto view_header = carla::BufferView::CreateFrom(std::move(buf_header));
auto view_data = carla::BufferView::CreateFrom(std::move(buffer));
Expand Down
8 changes: 4 additions & 4 deletions LibCarla/source/carla/multigpu/secondary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ namespace multigpu {
return;
}

auto handle_sent = [weak, message](const boost::system::error_code &ec, size_t DEBUG_ONLY(bytes)) {
auto handle_sent = [weak, message](const boost::system::error_code &ec, size_t) {
auto self = weak.lock();
if (!self) return;
if (ec) {
Expand Down Expand Up @@ -172,7 +172,7 @@ namespace multigpu {
return;
}

auto handle_sent = [weak, message](const boost::system::error_code &ec, size_t DEBUG_ONLY(bytes)) {
auto handle_sent = [weak, message](const boost::system::error_code &ec, size_t) {
auto self = weak.lock();
if (!self) return;
if (ec) {
Expand All @@ -197,7 +197,7 @@ namespace multigpu {
return;
}

auto handle_sent = [weak](const boost::system::error_code &ec, size_t DEBUG_ONLY(bytes)) {
auto handle_sent = [weak](const boost::system::error_code &ec, size_t) {
auto self = weak.lock();
if (!self) return;
if (ec) {
Expand All @@ -207,7 +207,7 @@ namespace multigpu {

// _deadline.expires_from_now(_timeout);
// sent first size buffer
int this_size = text.size();
int this_size = static_cast<int>(text.size());
boost::asio::async_write(
self->_socket,
boost::asio::buffer(&this_size, sizeof(this_size)),
Expand Down
10 changes: 5 additions & 5 deletions LibCarla/source/carla/road/Deformation.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,17 @@ namespace deformation {
float constraintX = 17.0f;
float constraintY = 12.0f;

float BumpX = std::ceil(posx / constraintX);
float BumpY = std::floor(posy / constraintY);
float BumpX = static_cast<float>(std::ceil(posx / constraintX));
float BumpY = static_cast<float>(std::floor(posy / constraintY));

BumpX *= constraintX;
BumpY *= constraintY;

float DistanceToBumpOrigin = sqrt(pow(BumpX - posx, 2) + pow(BumpY - posy, 2) );
float MaxDistance = 2.0;
float DistanceToBumpOrigin = static_cast<float>(sqrt(pow(BumpX - posx, 2) + pow(BumpY - posy, 2)));
float MaxDistance = 2.0f;

if (DistanceToBumpOrigin <= MaxDistance) {
bumpsoffset = sin(DistanceToBumpOrigin);
bumpsoffset = static_cast<float>(sin(DistanceToBumpOrigin));
}

return A3 * bumpsoffset;
Expand Down
42 changes: 17 additions & 25 deletions LibCarla/source/carla/road/Map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1181,7 +1181,7 @@ namespace road {
std::thread neworker(
[this, &write_mutex, &mesh_factory, &RoadsIDToGenerate, &road_out_mesh_list, i, num_roads_per_thread]() {
std::map<road::Lane::LaneType, std::vector<std::unique_ptr<geom::Mesh>>> Current =
std::move(GenerateRoadsMultithreaded(mesh_factory, RoadsIDToGenerate,i, num_roads_per_thread ));
GenerateRoadsMultithreaded(mesh_factory, RoadsIDToGenerate,i, num_roads_per_thread );
std::scoped_lock<std::mutex> guard(write_mutex);
for ( auto&& pair : Current ) {
if (road_out_mesh_list.find(pair.first) != road_out_mesh_list.end()) {
Expand Down Expand Up @@ -1323,7 +1323,7 @@ namespace road {
}
}

return std::move(LineMarks);
return LineMarks;
}

std::vector<carla::geom::BoundingBox> Map::GetJunctionsBoundingBoxes() const {
Expand Down Expand Up @@ -1354,7 +1354,7 @@ namespace road {
size_t endoffset = (index+1) * number_of_roads_per_thread;
size_t end = RoadsId.size();

for (int i = start; i < endoffset && i < end; ++i) {
for (size_t i = start; i < endoffset && i < end; ++i) {
const auto& road = _data.GetRoads().at(RoadsId[i]);
if (!road.IsJunction()) {
mesh_factory.GenerateAllOrderedWithMaxLen(road, out);
Expand All @@ -1365,7 +1365,7 @@ namespace road {
}

void Map::GenerateJunctions(const carla::geom::MeshFactory& mesh_factory,
const rpc::OpendriveGenerationParameters& params,
const rpc::OpendriveGenerationParameters& /*params*/,
const geom::Vector3D& minpos,
const geom::Vector3D& maxpos,
std::map<road::Lane::LaneType,
Expand All @@ -1374,7 +1374,6 @@ namespace road {
std::vector<JuncId> JunctionsToGenerate = FilterJunctionsByPosition(minpos, maxpos);
size_t num_junctions = JunctionsToGenerate.size();
std::cout << "Generating " << std::to_string(num_junctions) << " junctions" << std::endl;
size_t junctionindex = 0;
size_t num_junctions_per_thread = 5;
size_t num_threads = (num_junctions / num_junctions_per_thread) + 1;
num_threads = num_threads > 1 ? num_threads : 1;
Expand Down Expand Up @@ -1466,20 +1465,16 @@ namespace road {
}

std::unique_ptr<geom::Mesh> Map::SDFToMesh(const road::Junction& jinput,
const std::vector<geom::Vector3D>& sdfinput,
int grid_cells_per_dim) const {
const std::vector<geom::Vector3D>& /*sdfinput*/,
int /*grid_cells_per_dim*/) const {

int junctionid = jinput.GetId();
float box_extraextension_factor = 1.2f;
const double CubeSize = 0.5;
carla::geom::BoundingBox bb = jinput.GetBoundingBox();
carla::geom::Vector3D MinOffset = bb.location - geom::Location(bb.extent * box_extraextension_factor);
carla::geom::Vector3D MaxOffset = bb.location + geom::Location(bb.extent * box_extraextension_factor);
carla::geom::Vector3D OffsetPerCell = ( bb.extent * box_extraextension_factor * 2 ) / grid_cells_per_dim;

auto junctionsdf = [this, OffsetPerCell, CubeSize, MinOffset, junctionid](MeshReconstruction::Vec3 const& pos)
auto junctionsdf = [this, CubeSize](MeshReconstruction::Vec3 const& pos)
{
geom::Vector3D worldloc(pos.x, pos.y, pos.z);
geom::Vector3D worldloc(static_cast<float>(pos.x), static_cast<float>(pos.y), static_cast<float>(pos.z));
std::optional<element::Waypoint> CheckingWaypoint = GetWaypoint(geom::Location(worldloc), 0x1 << 1);
if (CheckingWaypoint) {
if ( pos.z < 0.2) {
Expand All @@ -1492,7 +1487,7 @@ namespace road {
geom::Transform InRoadWPTransform = ComputeTransform(*InRoadWaypoint);

geom::Vector3D director = geom::Location(worldloc) - (InRoadWPTransform.location);
geom::Vector3D laneborder = InRoadWPTransform.location + geom::Location(director.MakeUnitVector() * GetLaneWidth(*InRoadWaypoint) * 0.5f);
geom::Vector3D laneborder = InRoadWPTransform.location + geom::Location(director.MakeUnitVector() * static_cast<float>(GetLaneWidth(*InRoadWaypoint) * 0.5));

geom::Vector3D Distance = laneborder - worldloc;
if (Distance.Length2D() < CubeSize * 1.1 && pos.z < 0.2) {
Expand All @@ -1501,30 +1496,27 @@ namespace road {
return Distance.Length() * -1.0;
};

double gridsizeindouble = grid_cells_per_dim;
MeshReconstruction::Rect3 domain;
domain.min = { MinOffset.x, MinOffset.y, MinOffset.z };
domain.size = { bb.extent.x * box_extraextension_factor * 2, bb.extent.y * box_extraextension_factor * 2, 0.4 };

MeshReconstruction::Vec3 cubeSize{ CubeSize, CubeSize, 0.2 };
auto mesh = MeshReconstruction::MarchCube(junctionsdf, domain, cubeSize );
carla::geom::Rotation inverse = bb.rotation;
carla::geom::Vector3D trasltation = bb.location;
geom::Mesh out_mesh;

for (auto& cv : mesh.vertices) {
geom::Vector3D newvertex;
newvertex.x = cv.x;
newvertex.y = cv.y;
newvertex.z = cv.z;
newvertex.x = static_cast<float>(cv.x);
newvertex.y = static_cast<float>(cv.y);
newvertex.z = static_cast<float>(cv.z);
out_mesh.AddVertex(newvertex);
}

auto finalvertices = out_mesh.GetVertices();
for (auto ct : mesh.triangles) {
out_mesh.AddIndex(ct[1] + 1);
out_mesh.AddIndex(ct[0] + 1);
out_mesh.AddIndex(ct[2] + 1);
out_mesh.AddIndex(static_cast<size_t>(ct[1] + 1));
out_mesh.AddIndex(static_cast<size_t>(ct[0] + 1));
out_mesh.AddIndex(static_cast<size_t>(ct[2] + 1));
}

for (auto& cv : out_mesh.GetVertices() ) {
Expand All @@ -1535,7 +1527,7 @@ namespace road {
geom::Transform InRoadWPTransform = ComputeTransform(*InRoadWaypoint);

geom::Vector3D director = geom::Location(cv) - (InRoadWPTransform.location);
geom::Vector3D laneborder = InRoadWPTransform.location + geom::Location(director.MakeUnitVector() * GetLaneWidth(*InRoadWaypoint) * 0.5f);
geom::Vector3D laneborder = InRoadWPTransform.location + geom::Location(director.MakeUnitVector() * static_cast<float>(GetLaneWidth(*InRoadWaypoint) * 0.5));
cv = laneborder;
}
}
Expand Down Expand Up @@ -1564,7 +1556,7 @@ namespace road {
const auto& lane = lane_pair.second;
if ( lane.GetType() == road::Lane::LaneType::Sidewalk ) {
std::optional<element::Waypoint> sw =
GetWaypoint(road.GetId(), lane_pair.first, lane.GetDistance() + (lane.GetLength() * 0.5f));
GetWaypoint(road.GetId(), lane_pair.first, static_cast<float>(lane.GetDistance() + (lane.GetLength() * 0.5)));
if (!GetWaypoint(ComputeTransform(*sw).location).has_value()){
sidewalk_lane_meshes.push_back(mesh_factory.GenerateSidewalk(lane));
}
Expand Down
Loading
Loading