v0.1.10
This commit is contained in:
@@ -1,3 +1,12 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
'''
|
||||
@File : visualization.py
|
||||
@Time : 2025/12/18 20:19:09
|
||||
@Author : wty-yy
|
||||
@Version : 1.0
|
||||
@Blog : https://wty-yy.github.io/
|
||||
@Desc : Visualization Metric Implementation
|
||||
'''
|
||||
from robogauge.tasks.robots import RobotConfig
|
||||
from robogauge.tasks.gauge.metrics.base_metric import BaseMetric, SimData, GoalData
|
||||
|
||||
@@ -9,20 +18,20 @@ class VisualizationMetric(BaseMetric):
|
||||
|
||||
def __init__(self,
|
||||
robot_cfg: RobotConfig,
|
||||
dof_force: bool = False,
|
||||
dof_torque: bool = False,
|
||||
dof_pos: bool = False,
|
||||
**kwargs
|
||||
):
|
||||
super().__init__(robot_cfg)
|
||||
self.dof_force = dof_force
|
||||
self.dof_torque = dof_torque
|
||||
self.dof_pos = dof_pos
|
||||
|
||||
def __call__(self, sim_data: SimData, goal_data: GoalData) -> float:
|
||||
for i in range(len(sim_data.proprio.joint.force)):
|
||||
for i in range(len(sim_data.proprio.joint.torque)):
|
||||
name = sim_data.proprio.joint.names[i]
|
||||
if self.dof_force:
|
||||
force = sim_data.proprio.joint.force[i]
|
||||
logger.log(force, f'dof_force/{name}', step=sim_data.n_step)
|
||||
if self.dof_torque:
|
||||
torque = sim_data.proprio.joint.torque[i]
|
||||
logger.log(torque, f'dof_torque/{name}', step=sim_data.n_step)
|
||||
if self.dof_pos:
|
||||
pos = sim_data.proprio.joint.pos[i]
|
||||
logger.log(pos, f'dof_pos/{name}', step=sim_data.n_step)
|
||||
|
||||
Reference in New Issue
Block a user