Skip to content

Commit f1d90f0

Browse files
committed
Add ROS loader examples for FK and IK
1 parent 687d159 commit f1d90f0

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
from compas.robots import RobotModel
2+
3+
from compas_fab.backends import RosClient
4+
from compas_fab.backends import RosFileServerLoader
5+
from compas_fab.robots import Configuration
6+
from compas_fab.robots import Robot
7+
from compas_fab.robots import RobotSemantics
8+
9+
with RosClient() as client:
10+
loader = RosFileServerLoader(client)
11+
12+
urdf = loader.load_urdf()
13+
srdf = loader.load_srdf()
14+
15+
model = RobotModel.from_urdf_string(urdf)
16+
semantics = RobotSemantics.from_srdf_string(srdf, model)
17+
18+
robot = Robot(model, semantics=semantics, client=client)
19+
20+
configuration = Configuration.from_revolute_values([-2.238, -1.153, -2.174, 0.185, 0.667, 0.])
21+
22+
frame_RCF = robot.forward_kinematics(configuration)
23+
frame_WCF = robot.to_world_coords(frame_RCF)
24+
25+
print("Frame in the robot's coordinate system")
26+
print(frame_RCF)
27+
print("Frame in the world coordinate system")
28+
print(frame_WCF)
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
from compas.geometry import Frame
2+
from compas.robots import RobotModel
3+
4+
from compas_fab.backends import RosClient
5+
from compas_fab.backends import RosFileServerLoader
6+
from compas_fab.robots import Robot
7+
from compas_fab.robots import RobotSemantics
8+
9+
with RosClient() as client:
10+
loader = RosFileServerLoader(client)
11+
12+
urdf = loader.load_urdf()
13+
srdf = loader.load_srdf()
14+
15+
model = RobotModel.from_urdf_string(urdf)
16+
semantics = RobotSemantics.from_srdf_string(srdf, model)
17+
18+
robot = Robot(model, semantics=semantics, client=client)
19+
20+
frame_WCF = Frame([0.3, 0.1, 0.5], [1, 0, 0], [0, 1, 0])
21+
start_configuration = robot.init_configuration()
22+
23+
configuration = robot.inverse_kinematics(frame_WCF, start_configuration)
24+
25+
print("Found configuration", configuration)

0 commit comments

Comments
 (0)