Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions extensions/rcs_fr3/src/rcs_fr3/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,19 @@
@fr3_app.command()
def home(
ip: Annotated[str, typer.Argument(help="IP of the robot")],
shut: Annotated[bool, typer.Option("-s", help="Should the robot be shut down")] = False,
unlock: Annotated[bool, typer.Option("-u", help="unlocks the robot")] = False,
fh: Annotated[bool, typer.Option("-h", help="franka hand open")] = False,
):
"""Moves the FR3 to home position"""
user, pw = load_creds_franka_desk()
rcs_fr3.desk.home(ip, user, pw, shut, unlock, fh)
rcs_fr3.desk.home(ip)


# griper command
@fr3_app.command()
def gripper(
ip: Annotated[str, typer.Argument(help="IP of the robot")],
close_gripper: Annotated[bool, typer.Option("-c", help="close gripper")] = False,
):
"""Opens or closes the gripper"""
rcs_fr3.desk.gripper(ip, close_gripper)


@fr3_app.command()
Expand All @@ -36,8 +42,7 @@ def info(
include_gripper: Annotated[bool, typer.Option("-g", help="includes gripper")] = False,
):
"""Prints info about the robots current joint position and end effector pose, optionally also the gripper."""
user, pw = load_creds_franka_desk()
rcs_fr3.desk.info(ip, user, pw, include_gripper)
rcs_fr3.desk.info(ip, include_gripper)


@fr3_app.command()
Expand Down
76 changes: 40 additions & 36 deletions extensions/rcs_fr3/src/rcs_fr3/desk.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,45 +45,49 @@ def load_creds_franka_desk(postfix: str = "") -> tuple[str, str]:
return os.environ[username_key], os.environ[password_key]


def home(ip: str, username: str, password: str, shut: bool, unlock: bool = False, fh: bool = False):
with Desk.fci(ip, username, password, unlock=unlock):
def home(ip: str):
default_env = DefaultFR3HardwareEnv()
default_env.ip = ip
env_cfg = default_env.config()
robot_cfg = env_cfg.robot_cfg
robot_cfg.speed_factor = 0.2
f = rcs_fr3.hw.Franka(robot_cfg)
f.move_home()


def gripper(ip: str, close_gripper: bool):

default_env = DefaultFR3HardwareEnv()
default_env.ip = ip
env_cfg = default_env.config()
config_hand = env_cfg.gripper_cfg
assert isinstance(config_hand, rcs_fr3.hw.FHConfig)
g = rcs_fr3.hw.FrankaHand(config_hand)
if close_gripper:
g.shut()
else:
g.open()


def info(ip: str, include_hand: bool = False):
robot_cfg = rcs_fr3.hw.FR3Config(ip=ip)
robot_cfg.speed_factor = 0.2
f = rcs_fr3.hw.Franka(robot_cfg)
print("Robot info:")
print("Current cartesian position:")
print(f.get_cartesian_position())
print("Current joint position:")
print(f.get_joint_position())
if include_hand:
default_env = DefaultFR3HardwareEnv()
default_env.ip = ip
env_cfg = default_env.config()
robot_cfg = env_cfg.robot_cfg
robot_cfg.speed_factor = 0.2
f = rcs_fr3.hw.Franka(robot_cfg)
if fh:
config_hand = env_cfg.gripper_cfg
assert isinstance(config_hand, rcs_fr3.hw.FHConfig)
g = rcs_fr3.hw.FrankaHand(config_hand)
if shut:
g.shut()
else:
g.open()
f.move_home()


def info(ip: str, username: str, password: str, include_hand: bool = False):
with Desk.fci(ip, username, password):
robot_cfg = rcs_fr3.hw.FR3Config(ip=ip)
robot_cfg.speed_factor = 0.2
f = rcs_fr3.hw.Franka(robot_cfg)
print("Robot info:")
print("Current cartesian position:")
print(f.get_cartesian_position())
print("Current joint position:")
print(f.get_joint_position())
if include_hand:
default_env = DefaultFR3HardwareEnv()
default_env.ip = ip
env_cfg = default_env.config()
config_hand = env_cfg.gripper_cfg
assert isinstance(config_hand, rcs_fr3.hw.FHConfig)
g = rcs_fr3.hw.FrankaHand(config_hand)
print("Gripper info:")
print("Current normalized width:")
print(g.get_normalized_width())
config_hand = env_cfg.gripper_cfg
assert isinstance(config_hand, rcs_fr3.hw.FHConfig)
g = rcs_fr3.hw.FrankaHand(config_hand)
print("Gripper info:")
print("Current normalized width:")
print(g.get_normalized_width())


def lock(ip: str, username: str, password: str):
Expand Down
17 changes: 11 additions & 6 deletions extensions/rcs_panda/src/rcs_panda/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,18 @@
@panda_app.command()
def home(
ip: Annotated[str, typer.Argument(help="IP of the robot")],
shut: Annotated[bool, typer.Option("-s", help="Should the robot be shut down")] = False,
unlock: Annotated[bool, typer.Option("-u", help="unlocks the robot")] = False,
):
"""Moves the panda to home position"""
user, pw = load_creds_franka_desk()
rcs_panda.desk.home(ip, user, pw, shut, unlock)
rcs_panda.desk.home(ip)


@panda_app.command()
def gripper(
ip: Annotated[str, typer.Argument(help="IP of the robot")],
close_gripper: Annotated[bool, typer.Option("-c", help="close gripper")] = False,
):
"""Opens or closes the gripper"""
rcs_panda.desk.gripper(ip, close_gripper)


@panda_app.command()
Expand All @@ -35,8 +41,7 @@ def info(
include_gripper: Annotated[bool, typer.Option("-g", help="includes gripper")] = False,
):
"""Prints info about the robots current joint position and end effector pose, optionally also the gripper."""
user, pw = load_creds_franka_desk()
rcs_panda.desk.info(ip, user, pw, include_gripper)
rcs_panda.desk.info(ip, include_gripper)


@panda_app.command()
Expand Down
68 changes: 36 additions & 32 deletions extensions/rcs_panda/src/rcs_panda/desk.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,44 +45,48 @@ def load_creds_franka_desk(postfix: str = "") -> tuple[str, str]:
return os.environ[username_key], os.environ[password_key]


def home(ip: str, username: str, password: str, shut: bool, unlock: bool = False):
with Desk.fci(ip, username, password, unlock=unlock):
def home(ip: str):
default_env = DefaultPandaHardwareEnv()
default_env.ip = ip
env_cfg = default_env.config()
robot_cfg = env_cfg.robot_cfg
robot_cfg.speed_factor = 0.2
f = rcs_panda.hw.Franka(robot_cfg)
f.move_home()


def gripper(ip: str, close_gripper: bool):
default_env = DefaultPandaHardwareEnv()
default_env.ip = ip
env_cfg = default_env.config()
config_hand = env_cfg.gripper_cfg
assert isinstance(config_hand, rcs_panda.hw.FHConfig)
g = rcs_panda.hw.FrankaHand(config_hand)
if close_gripper:
g.shut()
else:
g.open()


def info(ip: str, include_hand: bool = False):
robot_cfg = rcs_panda.hw.PandaConfig(ip=ip)
robot_cfg.speed_factor = 0.2
f = rcs_panda.hw.Franka(robot_cfg)
print("Robot info:")
print("Current cartesian position:")
print(f.get_cartesian_position())
print("Current joint position:")
print(f.get_joint_position())
if include_hand:
default_env = DefaultPandaHardwareEnv()
default_env.ip = ip
env_cfg = default_env.config()
robot_cfg = env_cfg.robot_cfg
robot_cfg.speed_factor = 0.2
f = rcs_panda.hw.Franka(robot_cfg)
config_hand = env_cfg.gripper_cfg
assert isinstance(config_hand, rcs_panda.hw.FHConfig)
g = rcs_panda.hw.FrankaHand(config_hand)
if shut:
g.shut()
else:
g.open()
f.move_home()


def info(ip: str, username: str, password: str, include_hand: bool = False):
with Desk.fci(ip, username, password):
robot_cfg = rcs_panda.hw.PandaConfig(ip=ip)
robot_cfg.speed_factor = 0.2
f = rcs_panda.hw.Franka(robot_cfg)
print("Robot info:")
print("Current cartesian position:")
print(f.get_cartesian_position())
print("Current joint position:")
print(f.get_joint_position())
if include_hand:
default_env = DefaultPandaHardwareEnv()
default_env.ip = ip
env_cfg = default_env.config()
config_hand = env_cfg.gripper_cfg
assert isinstance(config_hand, rcs_panda.hw.FHConfig)
g = rcs_panda.hw.FrankaHand(config_hand)
print("Gripper info:")
print("Current normalized width:")
print(g.get_normalized_width())
print("Gripper info:")
print("Current normalized width:")
print(g.get_normalized_width())


def lock(ip: str, username: str, password: str):
Expand Down
Loading