Skip to content

Commit 1f2eda7

Browse files
authored
Merge pull request #274 from compas-dev/config_to_dict
Dictionary-like Configuration
2 parents 7ce4071 + 4d92312 commit 1f2eda7

File tree

14 files changed

+464
-190
lines changed

14 files changed

+464
-190
lines changed

CHANGELOG.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,13 @@ Unreleased
3333
* Added serialization methods to ``compas_fab.robots.CollisionMesh`` and ``compas_fab.robots.AttachedCollisionMesh``
3434
* Added ``attached_collision_meshes`` attribute to ``compas_fab.robots.JointTrajectory``
3535
* Added ``compas_fab.backends.ros.PlanningSceneComponents.__ne__``
36+
* Added dictionary behavior to ``compas_fab.robots.JointTrajectoryPoint.merge``
37+
* Added length limitations to attributes of ``compas_fab.robots.JointTrajectoryPoint.merge``
3638

3739
**Changed**
3840

3941
* Updated to ``COMPAS 1.1``
42+
* ``Configuration`` & ``JointTrajectoryPoint``: the attributes ``values`` and ``types`` changed to ``joint_values`` and `joint_types` respectively.
4043

4144
**Fixed**
4245

@@ -48,6 +51,8 @@ Unreleased
4851

4952
**Removed**
5053

54+
* Remove ``compas_fab.robots.JointTrajectoryPoint.merge``
55+
5156
0.16.0
5257
----------
5358

src/compas_fab/backends/pybullet/backend_features/pybullet_inverse_kinematics.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,5 +129,5 @@ def inverse_kinematics(self, robot, frame_WCF, start_configuration=None, group=N
129129
return joint_positions, joint_names
130130

131131
def _get_rest_poses(self, joint_names, configuration):
132-
name_value_map = {configuration.joint_names[i]: configuration.values[i] for i in range(len(configuration.joint_names))}
132+
name_value_map = {configuration.joint_names[i]: configuration.joint_values[i] for i in range(len(configuration.joint_names))}
133133
return [name_value_map[name] for name in joint_names]

src/compas_fab/backends/pybullet/client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ def check_collisions(self, robot, configuration=None):
425425
body_id = self.get_uid(cached_robot)
426426
if configuration:
427427
joint_ids = self._get_joint_ids_by_name(configuration.joint_names, cached_robot)
428-
self._set_joint_positions(joint_ids, configuration.values, body_id)
428+
self._set_joint_positions(joint_ids, configuration.joint_values, body_id)
429429
self.check_collision_with_objects(robot)
430430
self.check_robot_self_collision(robot)
431431

@@ -579,7 +579,7 @@ def set_robot_configuration(self, robot, configuration, group=None):
579579
default_config = robot.zero_configuration()
580580
full_configuration = robot.merge_group_with_full_configuration(configuration, default_config, group)
581581
joint_ids = self._get_joint_ids_by_name(full_configuration.joint_names, cached_robot)
582-
self._set_joint_positions(joint_ids, full_configuration.values, body_id)
582+
self._set_joint_positions(joint_ids, full_configuration.joint_values, body_id)
583583
return full_configuration
584584

585585
def get_robot_configuration(self, robot):
@@ -598,7 +598,7 @@ def get_robot_configuration(self, robot):
598598
default_config = robot.zero_configuration()
599599
joint_ids = self._get_joint_ids_by_name(default_config.joint_names, cached_robot)
600600
joint_values = self._get_joint_positions(joint_ids, body_id)
601-
default_config.values = joint_values
601+
default_config.joint_values = joint_values
602602
return default_config
603603

604604
# =======================================

src/compas_fab/backends/ros/backend_features/helpers.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@ def convert_constraints_to_rosmsg(constraints, header):
4141
return ros_constraints
4242

4343

44-
def convert_trajectory_points(points, types):
44+
def convert_trajectory_points(points, joint_types):
4545
result = []
4646

4747
for pt in points:
48-
jtp = JointTrajectoryPoint(values=pt.positions,
49-
types=types,
48+
jtp = JointTrajectoryPoint(joint_values=pt.positions,
49+
joint_types=joint_types,
5050
velocities=pt.velocities,
5151
accelerations=pt.accelerations,
5252
effort=pt.effort,

src/compas_fab/backends/ros/backend_features/move_it_forward_kinematics.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def forward_kinematics_async(self, callback, errback,
8484

8585
header = Header(frame_id=base_link)
8686
joint_state = JointState(
87-
name=configuration.joint_names, position=configuration.values, header=header)
87+
name=configuration.joint_names, position=configuration.joint_values, header=header)
8888
robot_state = RobotState(
8989
joint_state, MultiDOFJointState(header=header))
9090

src/compas_fab/backends/ros/backend_features/move_it_inverse_kinematics.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def inverse_kinematics_async(self, callback, errback,
9797
pose_stamped = PoseStamped(header, Pose.from_frame(frame_WCF))
9898

9999
joint_state = JointState(
100-
name=start_configuration.joint_names, position=start_configuration.values, header=header)
100+
name=start_configuration.joint_names, position=start_configuration.joint_values, header=header)
101101
start_state = RobotState(
102102
joint_state, MultiDOFJointState(header=header))
103103

src/compas_fab/backends/ros/backend_features/move_it_plan_cartesian_motion.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def plan_cartesian_motion_async(self, callback, errback,
113113
waypoints = [Pose.from_frame(frame) for frame in frames_WCF]
114114
joint_state = JointState(header=header,
115115
name=start_configuration.joint_names,
116-
position=start_configuration.values)
116+
position=start_configuration.joint_values)
117117
start_state = RobotState(joint_state, MultiDOFJointState(header=header), is_diff=True)
118118

119119
if options.get('attached_collision_meshes'):

src/compas_fab/backends/ros/backend_features/move_it_plan_motion.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ def plan_motion_async(self, callback, errback,
119119
joint_state = JointState(
120120
header=header,
121121
name=start_configuration.joint_names,
122-
position=start_configuration.values)
122+
position=start_configuration.joint_values)
123123
start_state = RobotState(
124124
joint_state, MultiDOFJointState(header=header), is_diff=True)
125125

src/compas_fab/backends/ros/client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,10 +219,10 @@ def follow_configurations(self, callback, joint_names, configurations, timesteps
219219
timeout = timesteps[-1] * 1000 * 2
220220

221221
points = []
222-
num_joints = len(configurations[0].values)
222+
num_joints = len(configurations[0].joint_values)
223223
for config, time in zip(configurations, timesteps):
224-
pt = RosMsgJointTrajectoryPoint(positions=config.values, velocities=[
225-
0]*num_joints, time_from_start=Time(secs=(time)))
224+
pt = RosMsgJointTrajectoryPoint(positions=config.joint_values, velocities=[
225+
0] * num_joints, time_from_start=Time(secs=(time)))
226226
points.append(pt)
227227

228228
joint_trajectory = RosMsgJointTrajectory(

src/compas_fab/backends/vrep/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ def set_robot_config(self, robot, config):
223223

224224
values = config_to_vrep(config, self.scale)
225225

226-
self.set_robot_metric(robot.model.attr['index'], [0.0] * len(config.values))
226+
self.set_robot_metric(robot.model.attr['index'], [0.0] * len(config.joint_values))
227227
self.run_child_script('moveRobotFK',
228228
[], values, ['robot' + robot.name])
229229

0 commit comments

Comments
 (0)