Skip to content

Commit 48fe542

Browse files
committed
style: py and cpp format
1 parent 27f2e1c commit 48fe542

8 files changed

Lines changed: 19 additions & 18 deletions

File tree

examples/fr3/fr3_env_cartesian_control.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
ROBOT_INSTANCE = RobotPlatform.SIMULATION
2727
FR3_IP = "192.168.101.1"
2828

29+
2930
def main():
3031
if ROBOT_INSTANCE == RobotPlatform.SIMULATION:
3132
env_rel = SimEnvCreator()(
@@ -40,6 +41,7 @@ def main():
4041
else:
4142
from rcs_fr3.creators import RCSFR3EnvCreator
4243
from rcs_fr3.utils import default_fr3_hw_gripper_cfg, default_fr3_hw_robot_cfg
44+
4345
env_rel = RCSFR3EnvCreator()(
4446
ip=FR3_IP,
4547
control_mode=ControlMode.CARTESIAN_TQuat,

examples/fr3/fr3_env_joint_control.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
ROBOT_INSTANCE = RobotPlatform.SIMULATION
2929
FR3_IP = "192.168.101.1"
3030

31+
3132
def main():
3233
if ROBOT_INSTANCE == RobotPlatform.SIMULATION:
3334
env_rel = SimEnvCreator()(
@@ -42,6 +43,7 @@ def main():
4243
else:
4344
from rcs_fr3.creators import RCSFR3EnvCreator
4445
from rcs_fr3.utils import default_fr3_hw_gripper_cfg, default_fr3_hw_robot_cfg
46+
4547
env_rel = RCSFR3EnvCreator()(
4648
ip=FR3_IP,
4749
control_mode=ControlMode.JOINTS,

examples/fr3/grasp_demo.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ def get_object_pose(self, geom_name) -> Pose:
2929
geom_id = mujoco.mj_name2id(model, mujoco.mjtObj.mjOBJ_GEOM, geom_name)
3030
obj_pose_world_coordinates = Pose(
3131
translation=data.geom_xpos[geom_id], rotation=data.geom_xmat[geom_id].reshape(3, 3)
32-
) * Pose(rpy_vector=np.array([0, 0, np.pi]), translation=[0, 0, 0]) # type: ignore
32+
) * Pose(
33+
rpy_vector=np.array([0, 0, np.pi]), translation=[0, 0, 0] # type: ignore
34+
)
3335
return self.unwrapped.robot.to_pose_in_robot_coordinates(obj_pose_world_coordinates)
3436

3537
def generate_waypoints(self, start_pose: Pose, end_pose: Pose, num_waypoints: int) -> list[Pose]:

python/rcs/envs/sim.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import logging
2+
import time
23
from typing import Any, SupportsFloat, Type, cast
34

45
import gymnasium as gym
@@ -12,11 +13,10 @@
1213
)
1314
from rcs.envs.space_utils import ActObsInfoWrapper
1415
from rcs.envs.utils import default_sim_robot_cfg, default_sim_tilburg_hand_cfg
16+
from rcs.utils import SimpleFrameRate
1517

1618
import rcs
17-
import time
1819
from rcs import sim
19-
from rcs.utils import SimpleFrameRate
2020

2121
logger = logging.getLogger(__name__)
2222
logger.setLevel(logging.INFO)
@@ -45,15 +45,15 @@ def __init__(self, env, simulation: sim.Sim, sim_wrapper: SimWrapper | None = No
4545
self.sim_robot = cast(sim.SimRobot, self.unwrapped.robot)
4646
self.sim = simulation
4747
cfg = self.sim.get_config()
48-
self.frame_rate = SimpleFrameRate(1/cfg.frequency, "RobotSimWrapper")
48+
self.frame_rate = SimpleFrameRate(1 / cfg.frequency, "RobotSimWrapper")
4949

5050
def step(self, action: dict[str, Any]) -> tuple[dict[str, Any], float, bool, bool, dict]:
5151
_, _, _, _, info = super().step(action)
5252
cfg = self.sim.get_config()
5353
if cfg.async_control:
54-
self.sim.step(round(1/cfg.frequency / self.sim.model.opt.timestep))
54+
self.sim.step(round(1 / cfg.frequency / self.sim.model.opt.timestep))
5555
if cfg.realtime:
56-
self.frame_rate.frame_rate = 1/cfg.frequency
56+
self.frame_rate.frame_rate = 1 / cfg.frequency
5757
self.frame_rate()
5858

5959
else:

python/rcs/sim/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from rcs._core.sim import (
22
SimCameraConfig,
3+
SimConfig,
34
SimGripper,
45
SimGripperConfig,
56
SimGripperState,
@@ -9,7 +10,6 @@
910
SimTilburgHand,
1011
SimTilburgHandConfig,
1112
SimTilburgHandState,
12-
SimConfig,
1313
)
1414
from rcs.sim.sim import Sim, gui_loop
1515

python/rcs/sim/sim.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import mujoco.viewer
1313
from rcs._core.sim import GuiClient as _GuiClient
1414
from rcs._core.sim import Sim as _Sim
15-
from rcs.sim import egl_bootstrap, SimConfig
15+
from rcs.sim import SimConfig, egl_bootstrap
1616
from rcs.utils import SimpleFrameRate
1717

1818
egl_bootstrap.bootstrap()

src/pybind/rcs.cpp

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -487,15 +487,11 @@ PYBIND11_MODULE(_core, m) {
487487
.def_readonly("last_width", &rcs::sim::SimGripperState::last_width)
488488
.def_readonly("collision", &rcs::sim::SimGripperState::collision);
489489

490-
py::class_<rcs::sim::SimConfig>(
491-
sim, "SimConfig")
490+
py::class_<rcs::sim::SimConfig>(sim, "SimConfig")
492491
.def(py::init<>())
493-
.def_readwrite("async_control",
494-
&rcs::sim::SimConfig::async_control)
495-
.def_readwrite("realtime",
496-
&rcs::sim::SimConfig::realtime)
497-
.def_readwrite("frequency",
498-
&rcs::sim::SimConfig::frequency)
492+
.def_readwrite("async_control", &rcs::sim::SimConfig::async_control)
493+
.def_readwrite("realtime", &rcs::sim::SimConfig::realtime)
494+
.def_readwrite("frequency", &rcs::sim::SimConfig::frequency)
499495
.def_readwrite("max_convergence_steps",
500496
&rcs::sim::SimConfig::max_convergence_steps);
501497

@@ -514,7 +510,6 @@ PYBIND11_MODULE(_core, m) {
514510
.def("_start_gui_server", &rcs::sim::Sim::start_gui_server, py::arg("id"))
515511
.def("_stop_gui_server", &rcs::sim::Sim::stop_gui_server);
516512

517-
518513
py::class_<rcs::sim::SimGripper, rcs::common::Gripper,
519514
std::shared_ptr<rcs::sim::SimGripper>>(sim, "SimGripper")
520515
.def(py::init<std::shared_ptr<rcs::sim::Sim>,

src/sim/sim.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class Renderer {
2929
struct SimConfig {
3030
bool async_control = false;
3131
bool realtime = false;
32-
int frequency = 30; // in Hz
32+
int frequency = 30; // in Hz
3333
int max_convergence_steps = 500;
3434
};
3535

0 commit comments

Comments
 (0)