Skip to content

Commit

Permalink
add backend logger
Browse files Browse the repository at this point in the history
  • Loading branch information
harderthan committed Jan 29, 2024
1 parent d14778e commit 8bb8ae9
Showing 1 changed file with 16 additions and 18 deletions.
34 changes: 16 additions & 18 deletions exts/stride.simulator/stride/simulator/backends/logger.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
import carb

import omni.kit.app
from stride.simulator.backends.backend import Backend


class Logger(Backend):
"""
Logger backend that just prints the state of the vehicle to the console.
"""

def __init__(self, vehicle_id: int):
super().__init__()
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))

carb.log_info(f"Received state update for vehicle {self._id}")
carb.log_info(f"Position: {state.position}")
carb.log_info(f"Attitude: {state.attitude}")
carb.log_info(f"Linear velocity: {state.linear_velocity}")
carb.log_info(f"Angular velocity: {state.angular_velocity}")
carb.log_info(f"Linear acceleration: {state.linear_acceleration}")

def update_sensor(self, sensor_type: str, data):
"""
Expand All @@ -32,21 +33,18 @@ def update_sensor(self, sensor_type: str, 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"]))

carb.log_info(f"Received IMU data for vehicle {self._id}")
carb.log_info(f"Angular velocity: {data['angular_velocity']}")
carb.log_info(f"Linear acceleration: {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))
carb.log_info(f"Updating logger backend for vehicle {self._id}")
carb.log_info(f"Time elapsed since last update: {dt}")

0 comments on commit 8bb8ae9

Please sign in to comment.