compas.robots.Configuration
- class compas.robots.Configuration(joint_values=None, joint_types=None, joint_names=None)[source]
Bases:
compas.data.data.DataRepresents 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
- Attributes
joint_values (
listoffloat) – Joint values expressed in radians or meters, depending on the respective type.joint_types (
listofcompas.robots.Joint.SUPPORTED_TYPES) – Joint types, e.g. a list ofcompas.robots.Joint.REVOLUTEfor revolute joints.data (
dict) – The data representing the configuration.prismatic_values (
listoffloat) – Prismatic joint values in meters.revolute_values (
listoffloat) – Revolute joint values in radians.
Examples
>>> config = Configuration.from_revolute_values([math.pi/2, 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., 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 import Joint >>> config = Configuration([math.pi/2, 3., 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(other[, tol])Returns
Trueif the other Configuration’s joint_values are within a certain range.copy()Create a copy of this
Configuration.from_data(data)Construct a configuration from its data representation.
from_json(filepath)Construct an object from serialized data contained in a JSON file.
from_jsonstring(string)Construct an object from serialized data contained in a JSON string.
from_prismatic_and_revolute_values(…[, …])Construct a configuration from prismatic and revolute joint values.
from_revolute_values(values[, joint_names])Construct a configuration from revolute joint values in radians.
get(key[, default])items()iter_differences(other)Generator over the differences to another Configuration’s joint_values.
keys()max_difference(other)Returns the maximum difference to another Configuration’s joint values.
merge(other)Merge the configuration with another configuration in place along joint names.
merged(other)Get a new
Configurationwith this configuration merged with another configuration.scale(scale_factor)Scales the joint positions of the current configuration.
scaled(scale_factor)Return a scaled copy of this configuration.
to_data()Get the data dictionary that represents the configuration.
to_json(filepath[, pretty])Serialize the data representation of an object to a JSON file.
to_jsonstring([pretty])Serialize the data representation of an object to a JSON string.
validate_data()Validate the object’s data against its data schema (self.DATASCHEMA).
validate_json()Validate the object’s data against its json schema (self.JSONSCHEMA).
values()Attributes
DATASCHEMAThe schema of the data of this object.
JSONSCHEMAThe schema of the JSON representation of the data of this object.
dataThe data representing the configuration.
dtypeThe type of the object in the form of a “2-level” import and a class name.
guidThe globally unique identifier of the object.
has_joint_namesReturns
Truewhen there is a joint name for every value.joint_dictA dictionary of joint values by joint name.
joint_names“List of joint names.
joint_typesJoint joint_types, e.g.
joint_valuesJoint values expressed in radians or meters, depending on the respective type.
nameThe name of the object.
prismatic_valuesPrismatic joint values in meters.
revolute_valuesRevolute joint values in radians.
type_dictA dictionary of joint types by joint name.