Repository navigation
Scripting RobotApi
Nishendra Singh edited this page Sep 16, 2026
·
2 revisions
Part of the Scripting API. RobotApi wraps one Robot object.
from freecad.robotics.App.rbt_api import get_robot
rob = get_robot()| Member | Value |
|---|---|
rob.n_joints |
Number of joints |
rob.joint_types |
Joint types of the kinematic chain |
rob.limits |
List of (min, max) for each joint |
rob.max_speeds |
Maximum speed of each joint |
rob.dof_mask |
Movable joints as a list of booleans |
rob.doc, rob.assembly
|
The document and the wrapped assembly |
for i, (lo, hi) in enumerate(rob.limits):
print(f"J{i+1}: {lo:g} .. {hi:g}")| Member | Function |
|---|---|
rob.q |
Joint values. Read and write. Degrees for revolute joints, millimeters for sliders |
rob.set_q(q, clamp=False, preview=False) |
Set all joints. clamp=True keeps the values in the limits |
rob.set_joint(i, value) |
Set one joint |
rob.jog(q) |
Preview only. A recompute sets the pose back |
rob.check_limits(q=None) |
Empty text when the values are in the limits. Else the violation text |
rob.q = [0, -30, 45, 0, 60, 0]
rob.set_joint(0, 15) # J1 to 15 deg
rob.set_q([0, -90, 90, 0, 0, 0], clamp=True)
msg = rob.check_limits([0, -200, 0, 0, 0, 0])
if msg:
print(msg) # the violation text| Member | Function |
|---|---|
rob.home |
The saved home pose |
rob.go_home() |
Move all joints to the home pose |
rob.save_home() |
Save the current pose as the home pose |
rob.save_zero() |
Make the current pose the zero pose ("mastering") |
rob.q = [0, -30, 45, 0, 60, 0]
rob.save_home()
rob.q = [90, 0, 0, 0, 0, 0]
rob.go_home() # back to the saved pose| Member | Function |
|---|---|
rob.tcp |
World TCP placement now (flange when no tool) |
rob.fk(q=None) |
World TCP for joint values q
|
rob.ik(target, q_seed=None) |
Joint values for a target placement. None when there is no solution |
rob.move_to(target) |
Solve IK and move the joints |
tgt = rob.tcp.copy()
tgt.Base.z -= 50 # 50 mm down
rob.move_to(tgt)
q = rob.ik(tgt) # solve only, no movement
if q is None:
print("no IK solution")| Member | Function |
|---|---|
rob.base |
The robot's BasePlacement. Write it to move the full robot |
rob.tool, rob.tools
|
The active tool and the list of all tools |
rob.add_tool(name, shape_file=None) |
Make a new active tool |
rob.kinematics_lib |
The IK backend name. See Kinematics |
import FreeCAD as App
rob.base = App.Placement(App.Vector(500, 0, 0), App.Rotation())
tool = rob.add_tool("Gripper", shape_file=r"C:\tools\gripper.FCStd")
rob.kinematics_lib = "numpy_dls"| Member | Function |
|---|---|
rob.recompute() |
Recompute the assembly and the tool |
rob.invalidate_cache() |
Discard the cached chain and backend |
rob.fpo |
The raw FeaturePython object |
Next: TrajectoryApi