-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: add ros2 env * feat: add lidar sensor * feat: add lidar sensor * Revert "feat: add lidar sensor" This reverts commit 6c44f99. * feat: Add support for Lidar sensor in LoggerBackend and ROS2Backend
- Loading branch information
Showing
6 changed files
with
166 additions
and
12 deletions.
There are no files selected for viewing
This file contains 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 @@ | ||
|
||
sensor: | ||
imu: | ||
update_frequency: 250 | ||
|
||
lidar: | ||
update_frequency: 25 | ||
prim_path: /World/AnymalC/lidar/lidar_PhysX |
This file contains 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 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 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 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
74 changes: 74 additions & 0 deletions
74
exts/stride.simulator/stride/simulator/vehicles/sensors/lidar.py
This file contains 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,74 @@ | ||
__all__ = ["Lidar"] | ||
|
||
from stride.simulator.vehicles import State | ||
from stride.simulator.vehicles.sensors.sensor import Sensor | ||
|
||
from omni.isaac.core import World | ||
from omni.isaac.sensor import RotatingLidarPhysX | ||
from omni.isaac.range_sensor import _range_sensor # Imports the python bindings to interact with lidar sensor | ||
|
||
class Lidar(Sensor): | ||
""" | ||
The class that implements the Lidar sensor. This class inherits the base class Sensor. | ||
""" | ||
|
||
def __init__(self, config=None): | ||
""" | ||
Initialize the Lidar class | ||
Args: | ||
""" | ||
if config is None: | ||
config = {} | ||
else: | ||
assert isinstance(config, dict), "The config parameter must be a dictionary." | ||
|
||
self.config = config | ||
|
||
super().__init__(sensor_type="Lidar", update_frequency=self.config.get("update_frequency", 10.0)) | ||
|
||
# Save the state of the sensor | ||
self._state = { | ||
"points": [], | ||
} | ||
|
||
self.lidar_interface = _range_sensor.acquire_lidar_sensor_interface() # Used to interact with the LIDAR | ||
|
||
self.lidar_flag_ = False | ||
|
||
|
||
@property | ||
def state(self): | ||
return self._state | ||
|
||
@Sensor.update_at_frequency | ||
def update(self, state: State, dt: float): | ||
|
||
if self.lidar_flag_ is True: | ||
pointcloud = self.lidar_interface.get_point_cloud_data(self.config.get("prim_path")) | ||
# print(pointcloud) | ||
self._state["points"] = pointcloud | ||
|
||
else: | ||
my_world = World.instance() | ||
|
||
## check there is world | ||
if my_world is None: | ||
pass | ||
else: | ||
self._lidar = my_world.scene.add( | ||
RotatingLidarPhysX(prim_path=self.config.get("prim_path"), name="range_sensor", | ||
rotation_dt = 10 | ||
) | ||
) | ||
self._lidar.set_fov([360, 30]) | ||
self._lidar.set_resolution([0.4, 0.4]) | ||
self._lidar.set_valid_range([0.1, 6]) | ||
self._lidar.enable_visualization(high_lod=True, | ||
draw_points=True, | ||
draw_lines=False) | ||
|
||
self.lidar_flag_ = True | ||
|
||
return self._state | ||
|