Skip to content

Commit 55ce318

Browse files
committed
Fix ROS-only code in Robot
1 parent eeaefb2 commit 55ce318

File tree

2 files changed

+19
-11
lines changed

2 files changed

+19
-11
lines changed

src/compas_fab/backends/ros/planner_backend_moveit.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,18 @@ class MoveItPlanner(PlannerBackend):
9393
GetPlanningSceneResponse)
9494

9595
def init_planner(self):
96-
self.collision_object_topic = Topic(self, '/collision_object',
97-
'moveit_msgs/CollisionObject', queue_size=None)
96+
self.collision_object_topic = Topic(
97+
self,
98+
'/collision_object',
99+
'moveit_msgs/CollisionObject',
100+
queue_size=None)
98101
self.collision_object_topic.advertise()
99102

100103
self.attached_collision_object_topic = Topic(
101-
self, '/attached_collision_object',
102-
'moveit_msgs/AttachedCollisionObject', queue_size=None)
104+
self,
105+
'/attached_collision_object',
106+
'moveit_msgs/AttachedCollisionObject',
107+
queue_size=None)
103108
self.attached_collision_object_topic.advertise()
104109

105110
def dispose_planner(self):
@@ -133,7 +138,10 @@ def inverse_kinematics_async(self, callback, errback, frame, base_link, group,
133138
avoid_collisions=avoid_collisions,
134139
attempts=attempts)
135140

136-
self.GET_POSITION_IK(self, (ik_request, ), callback, errback)
141+
def convert_to_positions(response):
142+
callback(response.solution.joint_state.position)
143+
144+
self.GET_POSITION_IK(self, (ik_request, ), convert_to_positions, errback)
137145

138146
def forward_kinematics_async(self, callback, errback, joint_positions, base_link,
139147
group, joint_names, ee_link):
@@ -145,8 +153,11 @@ def forward_kinematics_async(self, callback, errback, joint_positions, base_link
145153
robot_state = RobotState(
146154
joint_state, MultiDOFJointState(header=header))
147155

156+
def convert_to_frame(response):
157+
callback(response.pose_stamped[0].pose.frame)
158+
148159
self.GET_POSITION_FK(self, (header, fk_link_names,
149-
robot_state), callback, errback)
160+
robot_state), convert_to_frame, errback)
150161

151162
def plan_cartesian_motion_async(self, callback, errback, frames, base_link,
152163
ee_link, group, joint_names, joint_types,

src/compas_fab/robots/robot.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -833,12 +833,10 @@ def inverse_kinematics(self, frame_WCF, start_configuration=None,
833833
frame_RCF = self.represent_frame_in_RCF(frame_WCF, group)
834834
frame_RCF.point /= self.scale_factor # must be in meters
835835

836-
response = self.client.inverse_kinematics(frame_RCF, base_link,
836+
joint_positions = self.client.inverse_kinematics(frame_RCF, base_link,
837837
group, joint_names, joint_positions,
838838
avoid_collisions, constraints, attempts,
839839
attached_collision_meshes)
840-
841-
joint_positions = response.solution.joint_state.position
842840
joint_positions = self._scale_joint_values(joint_positions, self.scale_factor)
843841
# full configuration # TODO group config?
844842
configuration = Configuration(joint_positions, self.get_configurable_joint_types())
@@ -900,8 +898,7 @@ def forward_kinematics(self, configuration, group=None, backend=None, link_name=
900898

901899
if not backend:
902900
if self.client:
903-
response = self.client.forward_kinematics(full_joint_positions, base_link_name, group, full_joint_names, link_name)
904-
frame_RCF = response.pose_stamped[0].pose.frame
901+
frame_RCF = self.client.forward_kinematics(full_joint_positions, base_link_name, group, full_joint_names, link_name)
905902
frame_RCF.point *= self.scale_factor
906903
else:
907904
frame_WCF = self.model.forward_kinematics(group_joint_state, link_name)

0 commit comments

Comments
 (0)