Skip to content

Commit 003ab05

Browse files
authored
Merge pull request #225 from compas-dev/config_from_group_state
Configuration from group states
2 parents 6b0edcd + 7eb73d8 commit 003ab05

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

CHANGELOG.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Unreleased
2626
* Added ``compas_fab.robots.Configuration.merge``
2727
* Added ``compas_fab.robots.JointTrajectoryPoint.merge``
2828
* Added ``compas_fab.robots.Semantics.group_states``
29+
* Added ``compas_fab.robots.Robot.get_configuration_from_group_state``
2930

3031
**Changed**
3132

src/compas_fab/robots/robot.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,27 @@ def _check_full_configuration_and_scale(self, full_configuration=None):
607607
configuration.joint_names = joint_names
608608
return configuration, configuration.scaled(1. / self.scale_factor)
609609

610+
def get_configuration_from_group_state(self, group, group_state):
611+
"""Get a ``Configuration`` from a group's group state.
612+
613+
Parameters
614+
----------
615+
group : :obj:`str`
616+
The name of the planning group.
617+
group_state : :obj:`str
618+
The name of the ``group_state``.
619+
620+
Returns
621+
-------
622+
:class:`Configuration`
623+
The configuration specified by the ``group_state``.
624+
"""
625+
joint_dict = self.group_states[group][group_state]
626+
group_joint_names = self.get_configurable_joint_names(group)
627+
group_joint_types = self.get_configurable_joint_types(group)
628+
values = [joint_dict[name] for name in group_joint_names]
629+
return Configuration(values, group_joint_types, group_joint_names)
630+
610631
# ==========================================================================
611632
# transformations, coordinate frames
612633
# ==========================================================================

0 commit comments

Comments
 (0)