-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
578c88d
commit 0768092
Showing
6 changed files
with
336 additions
and
298 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from dataclasses import dataclass | ||
from typing import List, Tuple | ||
|
||
import numpy as np | ||
|
||
from rnl.configs.config import SensorConfig | ||
from rnl.engine.collision import Collision | ||
|
||
|
||
@dataclass | ||
class SensorRobot: | ||
def __init__(self, sensor_config: SensorConfig): | ||
self.collision = Collision() | ||
self.max_range = sensor_config.max_range | ||
self.lidar_angle = np.linspace(0, sensor_config.fov, sensor_config.num_rays) | ||
|
||
def sensor( | ||
self, x: float, y: float, segments: List | ||
) -> Tuple[np.ndarray, np.ndarray]: | ||
""" | ||
Perform sensor measurements based on the robot's position and environment segments. | ||
""" | ||
seg = self.collision.filter_segments(segments, x, y, 6) | ||
intersections = self.collision.lidar_intersection( | ||
x, y, self.max_range, self.lidar_angle, seg | ||
) | ||
measurements = self.collision.lidar_measurement( | ||
x, y, self.max_range, self.lidar_angle, seg | ||
) | ||
return intersections, measurements |
Oops, something went wrong.