Skip to content

Sync 4 21#3488

Merged
donghaiwang merged 11 commits intohutbfrom
sync_4_21
Mar 23, 2026
Merged

Sync 4 21#3488
donghaiwang merged 11 commits intohutbfrom
sync_4_21

Conversation

@donghaiwang
Copy link
Copy Markdown
Member

Description

Fixes #

Where has this been tested?

  • Platform(s): ...
  • Python version(s): ...
  • Unreal Engine version(s): ...

Possible Drawbacks

* fix(LibCarla): resolve all 282 compiler warnings across 27 files

Mechanical, zero-behavior-change refactoring that eliminates every
compiler warning emitted during LibCarla server and client builds.
Each warning category corresponds to a concrete defect class: silent
integer truncation on large maps, NRVO-preventing moves, deep copies in
parser loops, discarded ROS2 command responses, and C-style casts that
bypass type checking. Fixing them removes the noise that masks real issues
and establishes the baseline needed to enforce -Werror in CI.

Changes by category:
- Fix misleading indentation in FIleTransfer.cpp (brace correction)
- Eliminate unnecessary deep-copies in range-for loops (parsers)
- Remove pessimizing std::move() on return statements (NRVO)
- Reorder constructor initializer lists to match declaration order
- Remove unused variables, lambda captures, and dead code
- Annotate unused parameters with /*name*/ comment syntax (C++14)
- Replace implicit signed/unsigned conversions with size_t or static_cast
- Replace implicit double-to-float with explicit static_cast<float> or float literals
- Replace C-style casts with static_cast / reinterpret_cast
- Fix third-party headers: namespace pollution, bitfield sign, duplicate macros

Files changed (27):
  carla/Exception.cpp
  carla/client/FIleTransfer.cpp
  carla/client/detail/Simulator.cpp
  carla/geom/Mesh.cpp
  carla/geom/Simplification.cpp
  carla/multigpu/primary.cpp
  carla/multigpu/primaryCommands.cpp
  carla/multigpu/router.cpp
  carla/multigpu/secondary.cpp
  carla/opendrive/parser/GeoReferenceParser.cpp
  carla/opendrive/parser/GeometryParser.cpp
  carla/opendrive/parser/RoadParser.cpp
  carla/road/Deformation.h
  carla/road/Map.cpp
  carla/road/MapBuilder.cpp
  carla/road/MeshFactory.cpp
  carla/road/element/Geometry.cpp
  carla/trafficmanager/ALSM.cpp
  carla/trafficmanager/LocalizationStage.cpp
  test/client/test_image.cpp
  test/client/test_opendrive.cpp
  test/common/test_geom.cpp
  test/server/test_benchmark_streaming.cpp
  third-party/marchingcube/Cube.h
  third-party/marchingcube/MeshReconstruction.h
  third-party/marchingcube/Triangulation.h
  third-party/simplify/Simplify.h

Result: make LibCarla.server.release and make LibCarla.client.release
produce 0 warnings from LibCarla code. 44/45 unit tests pass;
the single failure (vector3D.make_unit_vec) is pre-existing.

* Added log record of the PR changes to CHANGELOG.md

Description
This PR removes all compiler warnings emitted from LibCarla code during
make LibCarla.server.release and make LibCarla.client.release.

The changes are mechanical and focused on warning cleanup only. No new
features were added and no intended runtime behavior was changed.

Main categories addressed in this PR:

Added braces where indentation was misleading
Replaced unnecessary copies in range-based loops with references
Removed dead code and unused variables
Marked unused parameters in a C++14-compatible way
Made integer and size conversions explicit
Made float narrowing conversions explicit
Replaced old-style C casts with C++ casts
Reordered constructor initializer lists to match declaration order
Completed or silenced switch handling where appropriate
Applied minimal warning fixes in a few third-party bundled headers
This PR also helps establish a zero-warning baseline for LibCarla, making
future regressions easier to detect.

Additional notes:

make LibCarla.server.release finished with 0 warnings from LibCarla code
make LibCarla.client.release finished with 0 warnings from LibCarla code
make check.LibCarla passed 44/45 tests
The only failing test was vector3D.make_unit_vec, which is pre-existing
and unrelated to this PR
Related documentation added in docs/:

docs/libcarla_warnings_refactoring.md
docs/libcarla_warnings_pr_report.md
docs/memory_leak_analysis_libcarla_cpp.md
Fixes #

Where has this been tested?
Platform(s): Linux
Python version(s): N/A
Unreal Engine version(s): N/A
Possible Drawbacks
Although the changes are intended to be behavior-preserving, this PR
touches multiple files across LibCarla and bundled third-party code, so
any future merge conflict in these areas may be slightly harder to review.
Some fixes in bundled third-party files may need to be re-applied if those
sources are updated upstream in the future.
…em, and enabling parallel make

#9573

Description
This PR improves the OSM renderer build process in Util/BuildTools/BuildOSMRenderer.sh to make it more reliable and faster.

The following changes were introduced:

Replaced make with make -j$(nproc) in all build steps to enable parallel compilation and reduce build time.
Pinned lunasvg to v2.3.8 using a shallow clone:
git clone -b v2.3.8 --depth 1 ${LUNASVG_REPO} ${LUNASVG_SOURCE_FOLDER}
Added explicit Boost linker flags when building the OSM renderer:
-DCMAKE_EXE_LINKER_FLAGS="-L${CARLA_BUILD_FOLDER}/boost-1.84.0-c10-install/lib -lboost_system"
These changes are intended to improve reproducibility and reduce build failures in the OSM renderer toolchain.

The lunasvg change avoids pulling the latest upstream state, which may introduce incompatibilities over time. Pinning a known release makes the dependency more stable and predictable.

The Boost linker flag was added to address build/link errors reported by the community when compiling the OSM renderer.

Using parallel make also improves developer experience by reducing compilation time during setup.

Fixes #6913

Where has this been tested?
Platform(s): Linux
Python version(s): N/A
Unreal Engine version(s): UE4
Possible Drawbacks
Using make -j$(nproc) increases CPU usage during compilation and may be too aggressive on low-memory systems.
Pinning lunasvg to a fixed release reduces exposure to upstream regressions, but it also means future fixes in newer versions will not be picked up automatically unless the version is updated manually.
Adding explicit linker flags may need adjustment in the future if the Boost build layout changes.
#7982

Description
Included in this PR are

Doc changes
Rolled back two changes from changed get_required_files docs #7763:

Re added "identifiers" in this docstring, as the sentence is incomplete currently.
- Defines the of each GBuffer texture (See the method
+ Defines the identifiers of each GBuffer texture (See the method
Removed the accidentally re added reference to the removed carla.Sensor.is_listening property. See Corrected information that Sensor.is_listening is (currently) a method #7439
fixes of spelling mistakes (docstring and documentation)

Corrected wrong literal wrapping instead of linking in

[old:] Defines the of each GBuffer texture (See the method [carla.Sensor.listen_to_gbuffer](#carla.Sensor.listen_to_gbuffer)).

Added Missing __init__ documentation for OpendriveGenerationParameters
Client.replay_file: replay_sensors was not declared as default value
World.[try_]spawn_actor parameter is named attachment_type and not attachment
Added documentation for Transform.inverse_transform from Added inverse transform #7999
added WorldSnapshot.elapsed_seconds to API description.
Fixed missing/wrong parameter for Client.apply_batch[_sync]
Needs decision:

 TrafficManager.set_boundaries_respawn_dormant_vehicles has no default values. Current default values are annotations that describe the bounds but are not really default values. I am not sure how to address this.
Changes in non-documentation files:
Added space after # Heading when docs are generated #Python API references -> # Python API references to be correct markdown. I am not sure if this is intentionally or an old oversight, but haven't seen anything where this could be relevant
Changed in python examples: on_world_tick(self, timestamp -> world_snapshot) to better reflect correct API usage.
Where has this been tested?
Platform(s): Ubuntu
Python version(s): 3.7 & 3.10 (should be irrelevant)
Unreal Engine version(s): 4.26
Possible Drawbacks
Does 4 have any side effects?
Concerning 11): Are there sideeffects to consider with the parameter renaming of def on_world_tick(self, timestamp -> world_snapshot): in the examples?

Note:
Currently pending changes to snippets and blueprint library (bp_libarary.md) from make PythonAPI.docs not included
…stream refactor

PR #9431 ("Extend ROS2 support Step 1") refactored EnableForROS from
a simple boolean to a per-actor set but removed the ROS2 enablement
check from AreClientsListening(). This caused Sensor::Tick() to exit
early when no Python stream client was connected, preventing sensors
from generating data for ROS2 topics.

Restore the invariant by checking !_enable_for_ros.empty() in
AreClientsListening(), matching the 0.9.16 behavior where
_enabled_for_ros kept sensors active for ROS2 publishing.

Also downgrade log_error to log_debug in EnableForROS/DisableForROS
since these are informational messages, not errors.
The traffic manager PID controller used fixed delta time values. In case
the simulation was not running at exact the fixed_delta_seconds of 0.05,
the PID controller overreacted or underreacted massively.
Using the actual delta time between the control steps improved the PID
controller behaviour on different timings.
To ensure that the controller is not degenerating because of the
inverse of the delta time on time steps close to zero (which should
rarely happen in practice -- if at all), just the previous signals are
returned.
After 7b2ef1d only the python unit
tests were adapted. This commit adapts the C++ tests to the changed
behavior.

After 7b2ef1d only the python unit tests were adapted. This commit adapts the C++ tests to the changed behavior.

Interestingly, this missing adaption wasn't detected by the CI run: When looking into the respective run, I only found that the make check.PythonAPI is called and the C++ ones seem to be switched off...
#9582

Description
This PR fixes compile-time warnings in the LibCarla ROS2 module by applying targeted, warning-focused changes across the ROS2 bridge, publishers, subscribers, and generated PubSub type headers.

The goal of this PR is to improve build hygiene and compatibility with stricter compiler settings without changing runtime behavior or public APIs.

Main changes included in this PR:

Added a missing return path in GetOrCreateSensor() to fix -Wreturn-type
Added virtual destructors to BasePublisher and BaseSubscriber
Replaced old-style C casts with static_cast and reinterpret_cast
Added explicit conversions to fix integer narrowing warnings
Marked unused parameters to silence -Wunused-parameter
Removed redundant const qualifiers from by-value return types
Reordered members in base classes to match constructor initialization order
More specifically:

LibCarla/source/carla/ros2/ROS2.cpp

Added return nullptr; at the end of GetOrCreateSensor()
Replaced C-style pointer casts with explicit C++ casts
Added explicit static_cast conversions for sensor type and width/height values
Marked several unused parameters in sensor processing functions
LibCarla/source/carla/ros2/publishers/BasePublisher.h

Added virtual ~BasePublisher() = default;
Removed redundant const from by-value getters
Reordered protected members to match constructor initialization order
LibCarla/source/carla/ros2/subscribers/BaseSubscriber.h

Added virtual ~BaseSubscriber() = default;
Removed redundant const from by-value getters
Reordered protected members to match constructor initialization order
LibCarla/source/carla/ros2/publishers/PublisherImpl.h

Replaced listener cast with static_cast
Marked unused callback parameter
LibCarla/source/carla/ros2/subscribers/SubscriberImpl.h

Replaced listener cast with static_cast
Marked unused callback parameter
LibCarla/source/carla/ros2/publishers/CarlaTransformPublisher.cpp

Replaced structured binding syntax with a C++14-compatible alternative
LibCarla/source/carla/ros2/publishers/CarlaPointCloudPublisher.cpp

Added explicit casts for point_step and row_step
LibCarla/source/carla/ros2/publishers/CarlaDVSPublisher.cpp

Removed redundant const from GetPointSize()
Added explicit conversion in DVS event point-cloud generation
LibCarla/source/carla/ros2/publishers/CarlaLidarPublisher.*

LibCarla/source/carla/ros2/publishers/CarlaRadarPublisher.*

LibCarla/source/carla/ros2/publishers/CarlaSemanticLidarPublisher.*

LibCarla/source/carla/ros2/publishers/CarlaPointCloudPublisher.h

Removed redundant const from GetPointSize() return types
LibCarla/source/carla/ros2/types/*PubSubTypes.h

Replaced old-style casts in offset helper templates with explicit C++ casts
These changes are intended to be mechanical and warning-oriented only. No ROS2 message schema, public interface, or expected runtime data flow was intentionally changed.

Fixes #

Where has this been tested?
Platform(s): Linux Ubuntu 22.04
Python version(s): N/A
Unreal Engine version(s): UE4
Possible Drawbacks
This PR touches multiple ROS2-related files, including generated PubSub type headers, so future upstream syncs in these files may require reapplying or reconciling some of these warning fixes.
Although the changes are intended to be behavior-preserving, any warning cleanup involving casts or base class definitions should still be reviewed carefully in case a downstream component depended on previous implicit behavior.

- Add missing return path in GetOrCreateSensor (fix -Wreturn-type)
- Add virtual destructors to BasePublisher and BaseSubscriber
- Replace C-style casts with reinterpret_cast/static_cast
- Fix integer narrowing with explicit static_cast for size_t/uint64_t
- Mark unused parameters to silence -Wunused-parameter
- Remove const from by-value return types (-Wignored-qualifiers)
- Replace C++17 structured bindings for C++14 compatibility
- Reorder constructor initializers to match member declaration order

Made-with: Cursor
@donghaiwang donghaiwang merged commit 9ca2ab8 into hutb Mar 23, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant