Skip to content

Commit b9defd3

Browse files
authored
fix(franka): left over ik refactor (#256)
1 parent 36a0d2d commit b9defd3

4 files changed

Lines changed: 60 additions & 29 deletions

File tree

examples/fr3/fr3_direct_control.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from rcs.camera.sim import SimCameraConfig, SimCameraSet
77
from rcs_fr3._core import hw
88
from rcs_fr3.desk import FCI, ContextManager, Desk, load_creds_franka_desk
9+
from rcs_fr3.utils import default_fr3_hw_robot_cfg
910

1011
import rcs
1112
from rcs import sim
@@ -60,15 +61,15 @@ def main():
6061
gripper: rcs.common.Gripper
6162
if ROBOT_INSTANCE == RobotPlatform.SIMULATION:
6263
simulation = sim.Sim(rcs.scenes["fr3_empty_world"].mjb)
63-
mjcf_path = rcs.scenes["fr3_empty_world"].mjcf_robot
64+
robot_cfg = sim.SimRobotConfig()
65+
robot_cfg.add_id("0")
66+
robot_cfg.tcp_offset = rcs.common.Pose(rcs.common.FrankaHandTCPOffset())
6467
ik = rcs.common.Pin(
65-
mjcf_path,
66-
"attachment_site_0",
68+
robot_cfg.kinematic_model_path,
69+
robot_cfg.attachment_site,
70+
urdf=robot_cfg.kinematic_model_path.endswith(".urdf"),
6771
)
68-
cfg = sim.SimRobotConfig()
69-
cfg.add_id("0")
70-
cfg.tcp_offset = rcs.common.Pose(rcs.common.FrankaHandTCPOffset())
71-
robot = rcs.sim.SimRobot(simulation, ik, cfg)
72+
robot = rcs.sim.SimRobot(simulation, ik, robot_cfg)
7273

7374
gripper_cfg_sim = sim.SimGripperConfig()
7475
gripper_cfg_sim.add_id("0")
@@ -95,15 +96,14 @@ def main():
9596
simulation.open_gui()
9697

9798
else:
98-
mjcf_path = rcs.scenes["fr3_empty_world"].mjcf_robot
99+
fr3_cfg = default_fr3_hw_robot_cfg()
100+
fr3_cfg.tcp_offset = rcs.common.Pose(rcs.common.FrankaHandTCPOffset())
99101
ik = rcs.common.Pin(
100-
mjcf_path,
101-
"attachment_site_0",
102+
fr3_cfg.kinematic_model_path,
103+
fr3_cfg.attachment_site,
104+
urdf=fr3_cfg.kinematic_model_path.endswith(".urdf"),
102105
)
103106
robot = hw.Franka(ROBOT_IP, ik)
104-
robot_cfg = hw.FR3Config()
105-
robot_cfg.tcp_offset = rcs.common.Pose(rcs.common.FrankaHandTCPOffset())
106-
robot_cfg.ik_solver = hw.IKSolver.rcs_ik
107107
robot.set_config(robot_cfg) # type: ignore
108108

109109
gripper_cfg_hw = hw.FHConfig()

extensions/rcs_fr3/src/rcs_fr3/desk.py

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@
1313
import rcs_fr3
1414
import requests
1515
from dotenv import load_dotenv
16-
from rcs_fr3.utils import default_fr3_hw_gripper_cfg
16+
from rcs_fr3.utils import default_fr3_hw_gripper_cfg, default_fr3_hw_robot_cfg
1717
from requests.packages import urllib3 # type: ignore[attr-defined]
1818
from websockets.sync.client import connect
1919

20+
import rcs
21+
2022
_logger = logging.getLogger("desk")
2123

2224
TOKEN_PATH = "~/.rcs/token.conf"
@@ -47,10 +49,16 @@ def load_creds_franka_desk(postfix: str = "") -> tuple[str, str]:
4749

4850
def home(ip: str, username: str, password: str, shut: bool, unlock: bool = False):
4951
with Desk.fci(ip, username, password, unlock=unlock):
50-
f = rcs_fr3.hw.Franka(ip)
51-
config = rcs_fr3.hw.FR3Config()
52-
config.speed_factor = 0.2
53-
f.set_config(config)
52+
robot_cfg = default_fr3_hw_robot_cfg()
53+
robot_cfg.tcp_offset = rcs.common.Pose(rcs.common.FrankaHandTCPOffset())
54+
robot_cfg.speed_factor = 0.2
55+
ik = rcs.common.Pin(
56+
robot_cfg.kinematic_model_path,
57+
robot_cfg.attachment_site,
58+
urdf=robot_cfg.kinematic_model_path.endswith(".urdf"),
59+
)
60+
f = rcs_fr3.hw.Franka(ip, ik)
61+
f.set_config(robot_cfg)
5462
config_hand = rcs_fr3.hw.FHConfig()
5563
g = rcs_fr3.hw.FrankaHand(ip, config_hand)
5664
if shut:
@@ -62,9 +70,16 @@ def home(ip: str, username: str, password: str, shut: bool, unlock: bool = False
6270

6371
def info(ip: str, username: str, password: str, include_hand: bool = False):
6472
with Desk.fci(ip, username, password):
65-
f = rcs_fr3.hw.Franka(ip)
66-
config = rcs_fr3.hw.FR3Config()
67-
f.set_config(config)
73+
robot_cfg = default_fr3_hw_robot_cfg()
74+
robot_cfg.tcp_offset = rcs.common.Pose(rcs.common.FrankaHandTCPOffset())
75+
robot_cfg.speed_factor = 0.2
76+
ik = rcs.common.Pin(
77+
robot_cfg.kinematic_model_path,
78+
robot_cfg.attachment_site,
79+
urdf=robot_cfg.kinematic_model_path.endswith(".urdf"),
80+
)
81+
f = rcs_fr3.hw.Franka(ip, ik)
82+
f.set_config(robot_cfg)
6883
print("Robot info:")
6984
print("Current cartesian position:")
7085
print(f.get_cartesian_position())

extensions/rcs_panda/src/rcs_panda/desk.py

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@
1313
import rcs_panda
1414
import requests
1515
from dotenv import load_dotenv
16-
from rcs_panda.utils import default_panda_hw_gripper_cfg
16+
from rcs_panda.utils import default_panda_hw_gripper_cfg, default_panda_hw_robot_cfg
1717
from requests.packages import urllib3 # type: ignore[attr-defined]
1818
from websockets.sync.client import connect
1919

20+
import rcs
21+
2022
_logger = logging.getLogger("desk")
2123

2224
TOKEN_PATH = "~/.rcs/token.conf"
@@ -47,10 +49,16 @@ def load_creds_franka_desk(postfix: str = "") -> tuple[str, str]:
4749

4850
def home(ip: str, username: str, password: str, shut: bool, unlock: bool = False):
4951
with Desk.fci(ip, username, password, unlock=unlock):
50-
f = rcs_panda.hw.Franka(ip)
51-
config = rcs_panda.hw.PandaConfig()
52-
config.speed_factor = 0.2
53-
f.set_config(config)
52+
robot_cfg = default_panda_hw_robot_cfg()
53+
robot_cfg.tcp_offset = rcs.common.Pose(rcs.common.FrankaHandTCPOffset())
54+
robot_cfg.speed_factor = 0.2
55+
ik = rcs.common.Pin(
56+
robot_cfg.kinematic_model_path,
57+
robot_cfg.attachment_site,
58+
urdf=robot_cfg.kinematic_model_path.endswith(".urdf"),
59+
)
60+
f = rcs_panda.hw.Franka(ip, ik)
61+
f.set_config(robot_cfg)
5462
config_hand = rcs_panda.hw.FHConfig()
5563
g = rcs_panda.hw.FrankaHand(ip, config_hand)
5664
if shut:
@@ -62,9 +70,16 @@ def home(ip: str, username: str, password: str, shut: bool, unlock: bool = False
6270

6371
def info(ip: str, username: str, password: str, include_hand: bool = False):
6472
with Desk.fci(ip, username, password):
65-
f = rcs_panda.hw.Franka(ip)
66-
config = rcs_panda.hw.PandaConfig()
67-
f.set_config(config)
73+
robot_cfg = default_panda_hw_robot_cfg()
74+
robot_cfg.tcp_offset = rcs.common.Pose(rcs.common.FrankaHandTCPOffset())
75+
robot_cfg.speed_factor = 0.2
76+
ik = rcs.common.Pin(
77+
robot_cfg.kinematic_model_path,
78+
robot_cfg.attachment_site,
79+
urdf=robot_cfg.kinematic_model_path.endswith(".urdf"),
80+
)
81+
f = rcs_panda.hw.Franka(ip, ik)
82+
f.set_config(robot_cfg)
6883
print("Robot info:")
6984
print("Current cartesian position:")
7085
print(f.get_cartesian_position())

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
build
22
wheel
3+
setuptools
34
scikit-build-core>=0.3.3
45
pybind11
56
cmake

0 commit comments

Comments
 (0)