-
Notifications
You must be signed in to change notification settings - Fork 399
Add CpuLidar system plugin with optimized physics raycasting #3343
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
apojomovsky
wants to merge
19
commits into
gazebosim:main
Choose a base branch
from
apojomovsky:feature/cpu-lidar
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 17 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
8a3147b
gz-sim: CpuLidar system plugin with sensor discovery, RaycastData pop…
apojomovsky a87591a
docs: CpuLidar example world and documentation
apojomovsky f9b5ae5
copyright: update to 2026
apojomovsky 242a7e0
copyright: update to 2026
apojomovsky cfc5d9f
test: refine CPU Lidar integration tests for consistency and robustness
apojomovsky 91094e8
feat: prefer batch raycasting API in Physics system
apojomovsky 0ed6f46
perf: gate raycasting to sensor update frequency, not physics rate
apojomovsky 9013478
test: add PointCloudPublished end-to-end integration test
apojomovsky a6a44c7
bazel: add cpu_lidar system plugin target
apojomovsky e4441c3
revert: remove unrelated copyright year changes
apojomovsky 9b34a31
style: tighten comments to match codebase conventions
apojomovsky f49df80
style: fix minor issues in Python binding docstrings
apojomovsky 9d2eb66
Revert "style: fix minor issues in Python binding docstrings"
apojomovsky e3520e1
fix: revert comments accidentally removed
apojomovsky 26a2b6a
fix: resolve cpplint violations in cpu_lidar
apojomovsky 01235ee
fix: default needsRaycast to true, add subscriber in RaycastResultsPr…
apojomovsky c868be9
Merge branch 'main' into feature/cpu-lidar
apojomovsky 895ca91
style: inline test subscription callbacks
apojomovsky ac80b71
Merge branch 'main' into feature/cpu-lidar
apojomovsky File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,233 @@ | ||
| <?xml version="1.0" ?> | ||
| <!-- | ||
| CPU Lidar Sensor Demo | ||
|
|
||
| This world demonstrates a physics-based lidar sensor that uses the collision | ||
| engine (DART + Bullet) for raycasting instead of the GPU rendering pipeline. | ||
| It does not require a GPU or rendering engine. | ||
|
|
||
| Requirements: | ||
| - Physics engine must be DART with the Bullet collision detector. | ||
| Other collision detectors (ODE, FCL) do not support raycasting. | ||
| - The cpu-lidar system plugin must be loaded (not the sensors system). | ||
| - The sensor detects collision geometry, not visual meshes. | ||
|
|
||
| Echo lidar messages: | ||
| gz topic -e -t /cpu_lidar | ||
| Echo point cloud messages: | ||
| gz topic -e -t /cpu_lidar/points | ||
| --> | ||
| <sdf version="1.6"> | ||
| <world name="cpu_lidar_demo"> | ||
|
|
||
| <!-- DART physics with Bullet collision detector (required for raycasting) --> | ||
| <physics name="1ms" type="dart"> | ||
| <max_step_size>0.001</max_step_size> | ||
| <real_time_factor>1.0</real_time_factor> | ||
| <dart> | ||
| <collision_detector>bullet</collision_detector> | ||
| </dart> | ||
| </physics> | ||
|
|
||
| <plugin | ||
| filename="gz-sim-physics-system" | ||
| name="gz::sim::systems::Physics"> | ||
| </plugin> | ||
| <!-- CPU lidar system — processes lidar sensors via physics raycasting --> | ||
| <plugin | ||
| filename="gz-sim-cpu-lidar-system" | ||
| name="gz::sim::systems::CpuLidar"> | ||
| </plugin> | ||
| <plugin | ||
| filename="gz-sim-scene-broadcaster-system" | ||
| name="gz::sim::systems::SceneBroadcaster"> | ||
| </plugin> | ||
| <plugin | ||
| filename="gz-sim-user-commands-system" | ||
| name="gz::sim::systems::UserCommands"> | ||
| </plugin> | ||
|
|
||
| <light type="directional" name="sun"> | ||
| <cast_shadows>true</cast_shadows> | ||
| <pose>0 0 10 0 0 0</pose> | ||
| <diffuse>0.8 0.8 0.8 1</diffuse> | ||
| <specular>0.2 0.2 0.2 1</specular> | ||
| <attenuation> | ||
| <range>1000</range> | ||
| <constant>0.9</constant> | ||
| <linear>0.01</linear> | ||
| <quadratic>0.001</quadratic> | ||
| </attenuation> | ||
| <direction>-0.5 0.1 -0.9</direction> | ||
| </light> | ||
|
|
||
| <!-- Ground plane --> | ||
| <model name="ground_plane"> | ||
| <static>true</static> | ||
| <link name="link"> | ||
| <collision name="collision"> | ||
| <geometry> | ||
| <box> | ||
| <size>20 20 0.1</size> | ||
| </box> | ||
| </geometry> | ||
| </collision> | ||
| <visual name="visual"> | ||
| <geometry> | ||
| <box> | ||
| <size>20 20 0.1</size> | ||
| </box> | ||
| </geometry> | ||
| <material> | ||
| <ambient>0.8 0.8 0.8 1</ambient> | ||
| <diffuse>0.8 0.8 0.8 1</diffuse> | ||
| <specular>0.8 0.8 0.8 1</specular> | ||
| </material> | ||
| </visual> | ||
| </link> | ||
| </model> | ||
|
|
||
| <!-- Obstacle: box in front --> | ||
| <model name="box_front"> | ||
| <static>true</static> | ||
| <pose>3 0 0.5 0 0 0</pose> | ||
| <link name="link"> | ||
| <collision name="collision"> | ||
| <geometry> | ||
| <box> | ||
| <size>1 1 1</size> | ||
| </box> | ||
| </geometry> | ||
| </collision> | ||
| <visual name="visual"> | ||
| <geometry> | ||
| <box> | ||
| <size>1 1 1</size> | ||
| </box> | ||
| </geometry> | ||
| <material> | ||
| <ambient>1 0 0 1</ambient> | ||
| <diffuse>1 0 0 1</diffuse> | ||
| <specular>1 0 0 1</specular> | ||
| </material> | ||
| </visual> | ||
| </link> | ||
| </model> | ||
|
|
||
| <!-- Obstacle: cylinder to the left --> | ||
| <model name="cylinder_left"> | ||
| <static>true</static> | ||
| <pose>0 3 0.5 0 0 0</pose> | ||
| <link name="link"> | ||
| <collision name="collision"> | ||
| <geometry> | ||
| <cylinder> | ||
| <radius>0.5</radius> | ||
| <length>1.0</length> | ||
| </cylinder> | ||
| </geometry> | ||
| </collision> | ||
| <visual name="visual"> | ||
| <geometry> | ||
| <cylinder> | ||
| <radius>0.5</radius> | ||
| <length>1.0</length> | ||
| </cylinder> | ||
| </geometry> | ||
| <material> | ||
| <ambient>0 1 0 1</ambient> | ||
| <diffuse>0 1 0 1</diffuse> | ||
| <specular>0 1 0 1</specular> | ||
| </material> | ||
| </visual> | ||
| </link> | ||
| </model> | ||
|
|
||
| <!-- Obstacle: box behind and to the right --> | ||
| <model name="box_behind_right"> | ||
| <static>true</static> | ||
| <pose>-2 -2 0.75 0 0 0.785</pose> | ||
| <link name="link"> | ||
| <collision name="collision"> | ||
| <geometry> | ||
| <box> | ||
| <size>1.5 0.5 1.5</size> | ||
| </box> | ||
| </geometry> | ||
| </collision> | ||
| <visual name="visual"> | ||
| <geometry> | ||
| <box> | ||
| <size>1.5 0.5 1.5</size> | ||
| </box> | ||
| </geometry> | ||
| <material> | ||
| <ambient>0 0 1 1</ambient> | ||
| <diffuse>0 0 1 1</diffuse> | ||
| <specular>0 0 1 1</specular> | ||
| </material> | ||
| </visual> | ||
| </link> | ||
| </model> | ||
|
|
||
| <!-- Model with CPU lidar sensor --> | ||
| <model name="lidar_platform"> | ||
| <static>true</static> | ||
| <pose>0 0 0.5 0 0 0</pose> | ||
| <link name="link"> | ||
| <pose>0.05 0.05 0.05 0 0 0</pose> | ||
| <inertial> | ||
| <mass>0.1</mass> | ||
| <inertia> | ||
| <ixx>0.000166667</ixx> | ||
| <iyy>0.000166667</iyy> | ||
| <izz>0.000166667</izz> | ||
| </inertia> | ||
| </inertial> | ||
| <collision name="collision"> | ||
| <geometry> | ||
| <box> | ||
| <size>0.1 0.1 0.1</size> | ||
| </box> | ||
| </geometry> | ||
| </collision> | ||
| <visual name="visual"> | ||
| <geometry> | ||
| <box> | ||
| <size>0.1 0.1 0.1</size> | ||
| </box> | ||
| </geometry> | ||
| </visual> | ||
|
|
||
| <sensor name="cpu_lidar" type="lidar"> | ||
| <topic>/cpu_lidar</topic> | ||
| <update_rate>10</update_rate> | ||
| <always_on>1</always_on> | ||
| <visualize>false</visualize> | ||
| <ray> | ||
| <scan> | ||
| <horizontal> | ||
| <samples>640</samples> | ||
| <resolution>1</resolution> | ||
| <min_angle>-3.14159</min_angle> | ||
| <max_angle>3.14159</max_angle> | ||
| </horizontal> | ||
| <vertical> | ||
| <samples>1</samples> | ||
| <resolution>1</resolution> | ||
| <min_angle>0</min_angle> | ||
| <max_angle>0</max_angle> | ||
| </vertical> | ||
| </scan> | ||
| <range> | ||
| <min>0.08</min> | ||
| <max>10.0</max> | ||
| <resolution>0.01</resolution> | ||
| </range> | ||
| </ray> | ||
| </sensor> | ||
| </link> | ||
| </model> | ||
|
|
||
| </world> | ||
| </sdf> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| /* | ||
| * Copyright (C) 2026 Open Source Robotics Foundation | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| * | ||
| */ | ||
| #ifndef GZ_SIM_COMPONENTS_CPU_LIDAR_HH_ | ||
| #define GZ_SIM_COMPONENTS_CPU_LIDAR_HH_ | ||
|
|
||
| #include <sdf/Sensor.hh> | ||
| #include <gz/sim/components/Factory.hh> | ||
| #include <gz/sim/components/Component.hh> | ||
| #include <gz/sim/components/Serialization.hh> | ||
| #include <gz/sim/config.hh> | ||
|
|
||
| namespace gz | ||
| { | ||
| namespace sim | ||
| { | ||
| // Inline bracket to help doxygen filtering. | ||
| inline namespace GZ_SIM_VERSION_NAMESPACE { | ||
| namespace components | ||
| { | ||
| /// \brief A component type that contains a CPU lidar sensor, | ||
| /// sdf::Sensor, information. | ||
| using CpuLidar = Component<sdf::Sensor, class CpuLidarTag, | ||
| serializers::SensorSerializer>; | ||
| GZ_SIM_REGISTER_COMPONENT("gz_sim_components.CpuLidar", CpuLidar) | ||
| } | ||
| } | ||
| } | ||
| } | ||
| #endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| gz_add_system(cpu-lidar | ||
| SOURCES | ||
| CpuLidar.cc | ||
| PUBLIC_LINK_LIBS | ||
| gz-common::gz-common | ||
| PRIVATE_LINK_LIBS | ||
| gz-sensors::cpu_lidar | ||
| ) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.