Skip to content

Commit 9968bab

Browse files
committed
Update FK & IK examples
1 parent a505613 commit 9968bab

File tree

3 files changed

+33
-7
lines changed

3 files changed

+33
-7
lines changed

docs/examples/03_backends_ros/02_forward_and_inverse_kinematics.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,19 @@ state of each joint in the articulated body of a robot needs to be defined.
2323
Joint states are described in **COMPAS FAB** with the
2424
:class:`compas_fab.robots.Configuration` class.
2525

26+
The simplest way to calculate forward kinematics is based on the properties defined
27+
by the robot model and does not require ROS to be running:
28+
2629
.. literalinclude :: files/02_forward_kinematics.py
2730
:language: python
2831
32+
Additionally, if the :class:`compas_fab.robots.Robot` is assigned a ``client``, it
33+
will try to use it to resolve forward kinematics. The following example shows the same
34+
solutions but calculated by ROS:
35+
36+
.. literalinclude :: files/02_forward_kinematics_ros.py
37+
:language: python
38+
2939
Inverse kinematics
3040
==================
3141

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
from compas_fab.backends import RosClient
21
from compas_fab.robots import Configuration
32
from compas_fab.robots.ur5 import Robot
43

5-
with RosClient() as client:
6-
robot = Robot(client)
7-
configuration = Configuration.from_revolute_values([-2.238, -1.153, -2.174, 0.185, 0.667, 0.])
4+
robot = Robot()
5+
configuration = Configuration.from_revolute_values([-2.238, -1.153, -2.174, 0.185, 0.667, 0.])
86

9-
response = robot.forward_kinematics(configuration)
7+
frame_RCF = robot.forward_kinematics(configuration)
8+
frame_WCF = robot.represent_frame_in_WCF(frame_RCF)
109

11-
print("Frame in the robot's coordinate system", response.frame_RCF)
12-
print("Frame in the world coordinate system", response.frame_WCF)
10+
print("Frame in the robot's coordinate system")
11+
print(frame_RCF)
12+
print("Frame in the world coordinate system")
13+
print(frame_WCF)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from compas_fab.backends import RosClient
2+
from compas_fab.robots import Configuration
3+
from compas_fab.robots.ur5 import Robot
4+
5+
with RosClient() as client:
6+
robot = Robot(client)
7+
configuration = Configuration.from_revolute_values([-2.238, -1.153, -2.174, 0.185, 0.667, 0.])
8+
9+
frame_RCF = robot.forward_kinematics(configuration)
10+
frame_WCF = robot.represent_frame_in_WCF(frame_RCF)
11+
12+
print("Frame in the robot's coordinate system")
13+
print(frame_RCF)
14+
print("Frame in the world coordinate system")
15+
print(frame_WCF)

0 commit comments

Comments
 (0)