utils
Logging utilities for controller runs.
类:
| 名称 | 描述 |
|---|---|
Logger |
A class for logging and visualization. |
Logger
Logger(logging_freq_hz: int, output_folder: str = 'results', num_drones: int = 1, duration_sec: int = 0, colab: bool = False)
A class for logging and visualization.
Stores, saves to file, and plots the kinematic information and RPMs of a simulation with one or more drones.
Initialize logger buffers and output settings.
Note
The order in which information is stored by Logger.log() is not the
same as the one in obs["id"]["state"]; see implementation below.
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
|
int
|
Logging frequency in Hz. |
必需 |
|
str
|
Output directory for saved logs. |
'results'
|
|
int
|
Number of drones. |
1
|
|
int
|
Preallocated duration in seconds (0 disables). |
0
|
|
bool
|
Enable Colab-friendly plotting. |
False
|
方法:
| 名称 | 描述 |
|---|---|
log |
Log entries for a single simulation step. |
save |
Save the logs to file. |
save_as_csv |
Save logs as comma separated values. |
plot |
Plot kinematics and RPMs for all drones. |
log
log(drone: int, timestamp: float, state: ndarray, control: ndarray = np.zeros(12))
Log entries for a single simulation step.
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
|
int
|
Drone index for the log entry. |
必需 |
|
float
|
Simulation timestamp. |
必需 |
|
ndarray
|
Drone state vector, shape (20,). |
必需 |
|
ndarray
|
Control target vector, shape (12,). |
zeros(12)
|
save
save()
Save the logs to file.
save_as_csv
save_as_csv(comment: str = '')
Save logs as comma separated values.
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
|
str
|
Added to the folder name. |
''
|
plot
plot()
Plot kinematics and RPMs for all drones.