Skip to content

Commit 63abeb1

Browse files
authored
Merge branch 'master' into pybullet_fk
2 parents 948c8f6 + f90d274 commit 63abeb1

File tree

6 files changed

+905
-385
lines changed

6 files changed

+905
-385
lines changed

.github/workflows/integration.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,14 @@ jobs:
4444
if: ${{ success() }}
4545
run: |
4646
invoke docs
47+
mkdir -p deploy/compas_fab/edge && mv -T dist/docs deploy/compas_fab/edge/
48+
- name: Deploy docs
49+
if: success()
50+
uses: crazy-max/ghaction-github-pages@v2
51+
with:
52+
repo: gramaziokohler/gramaziokohler.github.io
53+
target_branch: master
54+
build_dir: deploy
55+
keep_history: true
56+
env:
57+
GH_PAT: ${{ secrets.GH_PAT }}

src/compas_fab/robots/configuration.py

Lines changed: 57 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,36 @@
1111

1212
class Configuration(object):
1313
"""Represents the configuration of a robot based on the state of its joints.
14-
This concept is also refered to as `Joint State`.
1514
16-
Attributes
15+
This concept is also refered to as \"Joint State\".
16+
17+
Parameters
1718
----------
1819
values : :obj:`list` of :obj:`float`
19-
Joint values expressed in radians or meters, depending on the respective type.
20-
types : list of :class:`compas.robots.Joint.TYPE`
21-
Joint types, e.g. a list of `compas.robots.Joint.REVOLUTE` for revolute joints.
20+
Joint values expressed in radians or meters, depending on the respective
21+
type.
22+
types : :obj:`list` of :attr:`compas.robots.Joint.SUPPORTED_TYPES`
23+
Joint types, e.g. a list of :attr:`compas.robots.Joint.REVOLUTE` for
24+
revolute joints.
2225
joint_names : :obj:`list` of :obj:`str`, optional
23-
Joint names list
26+
List of joint names.
27+
28+
Attributes
29+
----------
30+
values : :obj:`list` of :obj:`float`
31+
Joint values expressed in radians or meters, depending on the respective
32+
type.
33+
types : :obj:`list` of :attr:`compas.robots.Joint.SUPPORTED_TYPES`
34+
Joint types, e.g. a list of :attr:`compas.robots.Joint.REVOLUTE` for
35+
revolute joints.
36+
joint_names : :obj:`list` of :obj:`str`
37+
List of joint names.
38+
data : :obj:`dict`
39+
The data representing the configuration.
40+
prismatic_values : :obj:`list` of :obj:`float`
41+
Prismatic joint values in meters.
42+
revolute_values : :obj:`list` of :obj:`float`
43+
Revolute joint values in radians.
2444
2545
Examples
2646
--------
@@ -52,13 +72,15 @@ def __init__(self, values=None, types=None, joint_names=None):
5272
len(self.values), len(self.values), len(self.types)))
5373

5474
def __str__(self):
75+
"""Return a human-readable string representation of the instance."""
5576
v_str = ('(' + ", ".join(['%.' + self._precision] * len(self.values)) + ')') % tuple(self.values)
5677
if len(self.joint_names):
5778
return "Configuration({}, {}, {})".format(v_str, tuple(self.types), tuple(self.joint_names))
5879
else:
5980
return "Configuration({}, {})".format(v_str, tuple(self.types))
6081

6182
def __repr__(self):
83+
"""Printable representation of :class:`Configuration`."""
6284
return self.__str__()
6385

6486
@classmethod
@@ -92,7 +114,7 @@ def from_prismatic_and_revolute_values(cls, prismatic_values, revolute_values):
92114
Returns
93115
-------
94116
:class:`Configuration`
95-
An instance of :class:`Configuration` instance.
117+
An instance of :class:`Configuration`.
96118
"""
97119
# Force iterables into lists
98120
prismatic_values = list(prismatic_values)
@@ -114,24 +136,33 @@ def from_data(cls, data):
114136
Returns
115137
-------
116138
:class:`Configuration`
117-
An instance of :class:`Configuration` instance.
139+
An instance of :class:`Configuration`.
118140
"""
119141
config = cls()
120142
config.data = data
121143
return config
122144

123145
def to_data(self):
124-
"""Return the data dictionary that represents the configuration, and from
125-
which it can be reconstructed."""
146+
"""Get the data dictionary that represents the configuration.
147+
148+
This data can also be used to reconstruct the :class:`Configuration`
149+
instance.
150+
151+
Returns
152+
-------
153+
:obj:`dict`
154+
The data representing the configuration.
155+
"""
126156
return self.data
127157

128158
@property
129159
def data(self):
130160
""":obj:`dict` : The data representing the configuration.
131161
132-
By assigning a data dictionary to this property, the current data of the
133-
configuration will be replaced by the data in the dict. The data getter
134-
and setter should always be used in combination with each other.
162+
By assigning a data dictionary to this property, the current data of
163+
the configuration will be replaced by the data in the :obj:`dict`. The
164+
data getter and setter should always be used in combination with each
165+
other.
135166
"""
136167
return {
137168
'values': self.values,
@@ -149,7 +180,8 @@ def data(self, data):
149180
def prismatic_values(self):
150181
""":obj:`list` of :obj:`float` : Prismatic joint values in meters.
151182
152-
E.g. positions on the external axis system."""
183+
E.g. positions on the external axis system.
184+
"""
153185
return [v for i, v in enumerate(self.values) if self.types[i] == Joint.PRISMATIC]
154186

155187
@property
@@ -158,6 +190,13 @@ def revolute_values(self):
158190
return [v for i, v in enumerate(self.values) if self.types[i] == Joint.REVOLUTE]
159191

160192
def copy(self):
193+
"""Create a copy of this :class:`Configuration`.
194+
195+
Returns
196+
-------
197+
:class:`Configuration`
198+
An instance of :class:`Configuration`
199+
"""
161200
cls = type(self)
162201
return cls(self.values[:], self.types[:], self.joint_names[:])
163202

@@ -168,8 +207,8 @@ def scale(self, scale_factor):
168207
169208
Parameters
170209
----------
171-
scale_factor : float
172-
Scale factor
210+
scale_factor : :obj:`float`
211+
Scale factor.
173212
174213
Returns
175214
-------
@@ -185,13 +224,13 @@ def scale(self, scale_factor):
185224
self.values = values_scaled
186225

187226
def scaled(self, scale_factor):
188-
"""Returns a scaled copy of this configuration.
227+
"""Return a scaled copy of this configuration.
189228
190229
Only scalable joints are scaled, i.e. planar and prismatic joints.
191230
192231
Parameters
193232
----------
194-
scale_factor : float
233+
scale_factor : :obj:`float`
195234
Scale factor
196235
197236
Returns

0 commit comments

Comments
 (0)