ロボットAPI¤
このページでは、Robopyのロボット制御に関連するAPIを説明します。
RakudaRobot¤
RakudaRobot
¤
RakudaRobot(cfg: RakudaConfig)
Bases: ComposedRobot[RakudaPairSys, Sensors, RakudaObs]
| METHOD | DESCRIPTION |
|---|---|
connect |
|
disconnect |
|
teleoperation |
Start teleoperation for Rakuda robot. |
record |
|
record_parallel |
teleoperate_stepをteleop_hzで回しつつ、fpsごとに最新のarm_obsを記録し、 |
Source code in src/robopy/robots/rakuda/rakuda_robot.py
connect
¤
disconnect
¤
Source code in src/robopy/robots/rakuda/rakuda_robot.py
teleoperation
¤
Start teleoperation for Rakuda robot.
Source code in src/robopy/robots/rakuda/rakuda_robot.py
record
¤
record(max_frame: int, fps: int = 5) -> RakudaObs
Source code in src/robopy/robots/rakuda/rakuda_robot.py
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 | |
record_parallel
¤
record_parallel(max_frame: int, fps: int = 20, teleop_hz: int = 25, max_processing_time_ms: float = 40) -> RakudaObs
teleoperate_stepをteleop_hzで回しつつ、fpsごとに最新のarm_obsを記録し、 センサデータは並列取得する高速記録。
Source code in src/robopy/robots/rakuda/rakuda_robot.py
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 | |
RakudaConfig
dataclass
¤
RakudaConfig(leader_port: str, follower_port: str, sensors: RakudaSensorParams | None = None, slow_mode: bool = False, leader_torque_enabled: List[str] | None = None, follower_torque_enabled: List[str] | None = None)
Configuration class for Rakuda robot.
RakudaPairSys
¤
RakudaPairSys(cfg: RakudaConfig)
Bases: Robot
Class representing the Rakuda robotic system with both leader and follower arms.
| METHOD | DESCRIPTION |
|---|---|
connect |
Connect to both leader and follower arms. |
disconnect |
Disconnect from both leader and follower arms. |
get_observation |
Get the current observation from both arms. |
Source code in src/robopy/robots/rakuda/rakuda_pair_sys.py
connect
¤
Connect to both leader and follower arms.
Source code in src/robopy/robots/rakuda/rakuda_pair_sys.py
disconnect
¤
get_observation
¤
Get the current observation from both arms.
Source code in src/robopy/robots/rakuda/rakuda_pair_sys.py
RakudaLeader
¤
RakudaLeader(cfg: RakudaConfig)
Bases: RakudaArm
Class representing the leader arm of the Rakuda robotic system.
| METHOD | DESCRIPTION |
|---|---|
connect |
|
disconnect |
|
RakudaFollower
¤
RakudaFollower(cfg: RakudaConfig)
Bases: RakudaArm
Class representing the follower arm of the Rakuda robotic system.
| METHOD | DESCRIPTION |
|---|---|
connect |
Connect to the follower arm and enable torque. |
disconnect |
Disconnect from the follower arm and disable torque. |
KochRobot
¤
KochRobot(cfg: KochConfig)
Bases: ComposedRobot[KochPairSys, Sensors, KochObs]
| METHOD | DESCRIPTION |
|---|---|
connect |
|
disconnect |
|
teleoperation |
Start teleoperation mode where leader controls follower. |
forward_kinematics |
Compute FK from joint angles (degrees) to end-effector pose. |
inverse_kinematics |
Solve IK for a target end-effector pose. |
send_frame_action |
|
send_ee_frame_action |
Send a single end-effector pose action to the robot. |
send_ee |
Send a trajectory of end-effector poses to the robot. |
teleoperation
¤
Start teleoperation mode where leader controls follower.
forward_kinematics
classmethod
¤
forward_kinematics(joint_angles_deg: NDArray[float32]) -> EEPose
Compute FK from joint angles (degrees) to end-effector pose.
| PARAMETER | DESCRIPTION |
|---|---|
joint_angles_deg
|
(5,) or (6,) array of joint angles in degrees. If 6 values are given the last element (gripper) is ignored.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
EEPose
|
EEPose with position in metres and orientation in radians. |
inverse_kinematics
¤
inverse_kinematics(target_pose: EEPose | NDArray[float32], current_joint_angles_deg: NDArray[float32], ik_config: IKConfig | None = None) -> IKResult
Solve IK for a target end-effector pose.
| PARAMETER | DESCRIPTION |
|---|---|
target_pose
|
Desired EE pose (EEPose or (5,) array
TYPE:
|
current_joint_angles_deg
|
(5,) or (6,) current joint angles in degrees used as the initial guess.
TYPE:
|
ik_config
|
Optional override for solver parameters.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
IKResult
|
IKResult with |
send_ee_frame_action
¤
send_ee_frame_action(ee_action: NDArray[float32], current_joint_angles_deg: NDArray[float32] | None = None, gripper_deg: float = 0.0) -> None
Send a single end-effector pose action to the robot.
| PARAMETER | DESCRIPTION |
|---|---|
ee_action
|
(5,) array
TYPE:
|
current_joint_angles_deg
|
(5,) or (6,) current joint angles in degrees. If None the current follower positions are read.
TYPE:
|
gripper_deg
|
Gripper angle in degrees (used when ee_action is 5-dimensional).
TYPE:
|
send_ee
¤
Send a trajectory of end-effector poses to the robot.
Each row of ee_actions is converted to joint angles via IK. The previous frame's solution is used as the seed for the next frame so that the resulting joint trajectory is smooth.
| PARAMETER | DESCRIPTION |
|---|---|
max_frame
|
Number of frames in the trajectory.
TYPE:
|
fps
|
Playback frame-rate.
TYPE:
|
ee_actions
|
(max_frame, 5) or (max_frame, 6) end-effector poses. If 6 columns, the last column is the gripper angle in degrees.
TYPE:
|
teleop_hz
|
Motor command rate.
TYPE:
|
So101Robot¤
So101Robot
¤
So101Robot(cfg: So101Config)
Bases: ComposedRobot[So101PairSys, Sensors, So101Obs]
| METHOD | DESCRIPTION |
|---|---|
connect |
|
disconnect |
|
teleoperation |
Start teleoperation mode where leader controls follower. |
forward_kinematics |
Compute FK from joint angles (degrees) to end-effector pose. |
inverse_kinematics |
Solve IK for a target end-effector pose. |
send_frame_action |
|
send_ee_frame_action |
Send a single end-effector pose action to the robot. |
send_ee |
Send a trajectory of end-effector poses to the robot. |
teleoperation
¤
Start teleoperation mode where leader controls follower.
forward_kinematics
classmethod
¤
forward_kinematics(joint_angles_deg: NDArray[float32]) -> EEPose
Compute FK from joint angles (degrees) to end-effector pose.
| PARAMETER | DESCRIPTION |
|---|---|
joint_angles_deg
|
(5,) or (6,) array of joint angles in degrees. If 6 values are given the last element (gripper) is ignored.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
EEPose
|
EEPose with position in metres and orientation in radians. |
inverse_kinematics
¤
inverse_kinematics(target_pose: EEPose | NDArray[float32], current_joint_angles_deg: NDArray[float32], ik_config: IKConfig | None = None) -> IKResult
Solve IK for a target end-effector pose.
| PARAMETER | DESCRIPTION |
|---|---|
target_pose
|
Desired EE pose (EEPose or (5,) array
TYPE:
|
current_joint_angles_deg
|
(5,) or (6,) current joint angles in degrees used as the initial guess.
TYPE:
|
ik_config
|
Optional override for solver parameters.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
IKResult
|
IKResult with |
send_ee_frame_action
¤
send_ee_frame_action(ee_action: NDArray[float32], current_joint_angles_deg: NDArray[float32] | None = None, gripper_deg: float = 0.0) -> None
Send a single end-effector pose action to the robot.
| PARAMETER | DESCRIPTION |
|---|---|
ee_action
|
(5,) array
TYPE:
|
current_joint_angles_deg
|
(5,) or (6,) current joint angles in degrees. If None the current follower positions are read.
TYPE:
|
gripper_deg
|
Gripper angle in degrees (used when ee_action is 5-dimensional).
TYPE:
|
send_ee
¤
Send a trajectory of end-effector poses to the robot.
Each row of ee_actions is converted to joint angles via IK. The previous frame's solution is used as the seed for the next frame so that the resulting joint trajectory is smooth.
| PARAMETER | DESCRIPTION |
|---|---|
max_frame
|
Number of frames in the trajectory.
TYPE:
|
fps
|
Playback frame-rate.
TYPE:
|
ee_actions
|
(max_frame, 5) or (max_frame, 6) end-effector poses. If 6 columns, the last column is the gripper angle in degrees.
TYPE:
|
teleop_hz
|
Motor command rate.
TYPE:
|
So101Config
dataclass
¤
So101Config(follower_port: str, calibration_path: str, leader_port: str | None = None, sensors: So101SensorConfig = So101SensorConfig())
Configuration class for SO-101 robot.
The SO-101 uses Feetech STS3215 motors with 6 joints per arm: shoulder_pan, shoulder_lift, elbow_flex, wrist_flex, wrist_roll, gripper.
So101SpaceMouseController¤
SpaceMouseを使用したEE空間テレオペレーション。詳細はSpaceMouse APIを参照。
So101SpaceMouseController
¤
So101SpaceMouseController(robot: So101Robot, spacemouse_config: SpaceMouseConfig | None = None)
Control an SO-101 follower arm via a 3Dconnexion SpaceMouse.
The SpaceMouse 6-DOF input (x, y, z, roll, pitch, yaw — all normalised
to [-1, 1]) is mapped to incremental end-effector velocity commands.
At each control step the current EE pose is updated by the velocity
delta, then Inverse Kinematics converts the target pose to joint angles
that are sent to the follower arm.
The controller operates without a physical leader arm — the SpaceMouse replaces it. Gripper open/close is driven by the left/right buttons.
| PARAMETER | DESCRIPTION |
|---|---|
robot
|
A configured :class:
TYPE:
|
spacemouse_config
|
Optional tuning parameters. Defaults are reasonable for desktop-scale manipulation.
TYPE:
|
| METHOD | DESCRIPTION |
|---|---|
connect |
Connect the robot and start the SpaceMouse reader. |
disconnect |
Stop the SpaceMouse reader and disconnect the robot. |
teleoperation |
Run real-time SpaceMouse → EE-space teleoperation. |
record_parallel |
Record a SpaceMouse-driven trajectory with camera observations. |
teleoperation
¤
Run real-time SpaceMouse → EE-space teleoperation.
The control loop reads the SpaceMouse at control_hz, computes the incremental EE delta, runs IK and sends joint angles to the follower.
| PARAMETER | DESCRIPTION |
|---|---|
max_seconds
|
If given, stop after this many seconds. Otherwise
the loop runs until interrupted (
TYPE:
|
record_parallel
¤
record_parallel(max_frame: int, fps: int = 20, control_hz: int | None = None, is_async: bool = True) -> So101Obs
Record a SpaceMouse-driven trajectory with camera observations.
Architecture mirrors :meth:So101Robot.record_parallel — a fast
control thread drives the arm while the main thread captures camera
frames at the requested fps.
The returned So101Obs.arms.leader contains the commanded joint
angles (IK output), so the trajectory can be replayed verbatim with
So101Robot.send(). So101Obs.arms.follower contains the
actual motor readings.
| PARAMETER | DESCRIPTION |
|---|---|
max_frame
|
Number of sensor frames to record.
TYPE:
|
fps
|
Camera / observation capture rate.
TYPE:
|
control_hz
|
SpaceMouse control loop rate (defaults to config).
TYPE:
|
is_async
|
Use asynchronous camera reads when available.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
So101Obs
|
|
使用例¤
基本的なRakudaRobotの使用¤
from robopy import RakudaConfig, RakudaRobot
# 設定の作成
config = RakudaConfig(
leader_port="/dev/ttyUSB0",
follower_port="/dev/ttyUSB1"
)
# ロボットの作成と接続
robot = RakudaRobot(config)
robot.connect()
try:
# テレオペレーション
robot.teleoperation(duration=10)
# データ記録
obs = robot.record_parallel(max_frame=1000,20)
finally:
robot.disconnect()
個別アームの制御¤
from robopy.robots.rakuda import RakudaLeader, RakudaFollower
# 個別アームの作成
leader = RakudaLeader("/dev/ttyUSB0")
follower = RakudaFollower("/dev/ttyUSB1")
leader.connect()
follower.connect()
try:
# Leaderから観測データを取得
leader_obs = leader.get_obs()
# Followerに動作指令を送信
follower.set_action(leader_obs["action"])
finally:
leader.disconnect()
follower.disconnect()