-
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.
Added Logger class as a simple child class.
- Loading branch information
1 parent
159c895
commit 14e000d
Showing
2 changed files
with
53 additions
and
0 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 |
---|---|---|
@@ -1 +1,2 @@ | ||
from .backend import Backend | ||
from .logger import Logger |
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,52 @@ | ||
import carb | ||
|
||
import omni.kit.app | ||
from stride.simulator.backends.backend import Backend | ||
|
||
class Logger(Backend): | ||
|
||
def __init__(self, vehicle_id: int): | ||
self._id = vehicle_id | ||
|
||
|
||
def update_state(self, state): | ||
""" | ||
Method that handles the receival of the state of the vehicle. It just prints the state to the console. | ||
""" | ||
|
||
carb.log_info("Received state update for vehicle {}".format(self._id)) | ||
carb.log_info("Position: {}".format(state.position)) | ||
carb.log_info("Attitude: {}".format(state.attitude)) | ||
carb.log_info("Linear velocity: {}".format(state.linear_velocity)) | ||
carb.log_info("Angular velocity: {}".format(state.angular_velocity)) | ||
carb.log_info("Linear acceleration: {}".format(state.linear_acceleration)) | ||
|
||
|
||
def update_sensor(self, sensor_type: str, data): | ||
""" | ||
Method that when implemented, should handle the receival of sensor data | ||
""" | ||
|
||
if sensor_type == "IMU": | ||
self.update_imu_data(data) | ||
|
||
# TODO: Add support for other sensors | ||
|
||
|
||
def update_imu_data(self, data): | ||
""" | ||
Method that handles the receival of IMU data. It just prints the data to the console. | ||
""" | ||
carb.log_info("Received IMU data for vehicle {}".format(self._id)) | ||
carb.log_info("Angular velocity: {}".format(data["angular_velocity"])) | ||
carb.log_info("Linear acceleration: {}".format(data["linear_acceleration"])) | ||
|
||
|
||
def update(self, dt: float): | ||
""" | ||
Method that update the state of the backend and the information being sent/received from the communication | ||
interface. This method will be called by the simulation on every physics steps. | ||
""" | ||
|
||
carb.log_info("Updating logger backend for vehicle {}".format(self._id)) | ||
carb.log_info("Time elapsed since last update: {}".format(dt)) |