Configuration

class compas_robots.Configuration[source]

Bases: Data

Represents the configuration of a robot based on the state of its joints. If the names of joints are also provided, the configuration behaves as a dictionary of joint name-value pairs.

This concept is also refered to as “Joint State”.

Parameters:
joint_valueslist of float

Joint values expressed in radians or meters, depending on the respective type.

joint_typeslist of compas_robots.model.Joint.SUPPORTED_TYPES

Joint types, e.g. a list of compas_robots.model.Joint.REVOLUTE for revolute joints.

joint_nameslist[str], optional

List of joint names.

Attributes:
joint_valueslist of float

Joint values expressed in radians or meters, depending on the respective type.

joint_typeslist of compas_robots.model.Joint.SUPPORTED_TYPES

Joint joint_types, e.g.

joint_nameslist[str]

“List of joint names.

datadict

The data representing the configuration.

prismatic_valueslist of float

list of float : Prismatic joint values in meters.

revolute_valueslist of float

list of float : Revolute joint values in radians.

Examples

>>> config = Configuration.from_revolute_values([math.pi / 2, 0.0, 0.0])
>>> config.joint_values
[1.5707963267948966, 0.0, 0.0]
>>> config = Configuration.from_prismatic_and_revolute_values([8.312], [math.pi / 2, 0.0, 0.0, 0.0, 2 * math.pi, 0.8])
>>> str(config)
'Configuration((8.312, 1.571, 0.000, 0.000, 0.000, 6.283, 0.800), (2, 0, 0, 0, 0, 0, 0))'
>>> from compas_robots.model import Joint
>>> config = Configuration([math.pi / 2, 3.0, 0.1], [Joint.REVOLUTE, Joint.PRISMATIC, Joint.PLANAR])
>>> str(config)
'Configuration((1.571, 3.000, 0.100), (0, 2, 5))'

Methods

check_joint_names

Raises an error if there is not a joint name for every value.

close_to

Returns True if the other Configuration's joint_values are within a certain range.

from_prismatic_and_revolute_values

Construct a configuration from prismatic and revolute joint values.

from_revolute_values

Construct a configuration from revolute joint values in radians.

get

items

iter_differences

Generator over the differences to another Configuration's joint_values.

keys

max_difference

Returns the maximum difference to another Configuration's joint values.

merge

Merge the configuration with another configuration in place along joint names.

merged

Get a new Configuration with this configuration merged with another configuration.

scale

Scales the joint positions of the current configuration.

scaled

Return a scaled copy of this configuration.

values

Inherited Methods

ToString

Converts the instance to a string.

copy

Make an independent copy of the data object.

from_json

Construct an object of this type from a JSON file.

from_jsonstring

Construct an object of this type from a JSON string.

sha256

Compute a hash of the data for comparison during version control using the sha256 algorithm.

to_json

Convert an object to its native data representation and save it to a JSON file.

to_jsonstring

Convert an object to its native data representation and save it to a JSON string.

validate_data

Validate the data against the object's data schema.