Goulib.motion module¶
motion simulation (kinematics)
-
class
Goulib.motion.
PVA
(funcs)[source]¶ Bases:
Goulib.plot.Plot
represents a function of time returning position, velocity, and acceleration
-
__class__
¶ alias of
builtins.type
-
__delattr__
¶ Implement delattr(self, name).
-
__dir__
()¶ Default dir() implementation.
-
__eq__
¶ Return self==value.
-
__format__
()¶ Default object formatter.
-
__ge__
¶ Return self>=value.
-
__getattribute__
¶ Return getattr(self, name).
-
__gt__
¶ Return self>value.
-
__hash__
¶ Return hash(self).
-
__init_subclass__
()¶ This method is called when a class is subclassed.
The default implementation does nothing. It may be overridden to extend subclasses.
-
__le__
¶ Return self<=value.
-
__lt__
¶ Return self<value.
-
__ne__
¶ Return self!=value.
-
__new__
()¶ Create and return a new object. See help(type) for accurate signature.
-
__reduce__
()¶ Helper for pickle.
-
__reduce_ex__
()¶ Helper for pickle.
-
__repr__
¶ Return repr(self).
-
__setattr__
¶ Implement setattr(self, name, value).
-
__sizeof__
()¶ Size of object in memory, in bytes.
-
__str__
¶ Return str(self).
-
html
(**kwargs)¶
-
plot
(**kwargs)¶ renders on IPython Notebook (alias to make usage more straightforward)
-
png
(**kwargs)¶
-
render
(fmt='svg', **kwargs)¶
-
save
(filename, **kwargs)¶
-
svg
(**kwargs)¶
-
-
class
Goulib.motion.
Segment
(t0, t1, funcs)[source]¶ Bases:
Goulib.motion.PVA
a PVA defined between 2 times, null elsewhere
-
timeWhenPosBiggerThan
(pos, resolution=0.01)[source]¶ search the first time when the position is bigger than pos :params pos: the pos that must at least be reached :params resolution: the time resolution in sec
-
__class__
¶ alias of
builtins.type
-
__delattr__
¶ Implement delattr(self, name).
-
__dir__
()¶ Default dir() implementation.
-
__eq__
¶ Return self==value.
-
__format__
()¶ Default object formatter.
-
__ge__
¶ Return self>=value.
-
__getattribute__
¶ Return getattr(self, name).
-
__gt__
¶ Return self>value.
-
__hash__
¶ Return hash(self).
-
__init_subclass__
()¶ This method is called when a class is subclassed.
The default implementation does nothing. It may be overridden to extend subclasses.
-
__le__
¶ Return self<=value.
-
__lt__
¶ Return self<value.
-
__ne__
¶ Return self!=value.
-
__new__
()¶ Create and return a new object. See help(type) for accurate signature.
-
__reduce__
()¶ Helper for pickle.
-
__reduce_ex__
()¶ Helper for pickle.
-
__repr__
¶ Return repr(self).
-
__setattr__
¶ Implement setattr(self, name, value).
-
__sizeof__
()¶ Size of object in memory, in bytes.
-
__str__
¶ Return str(self).
-
html
(**kwargs)¶
-
plot
(**kwargs)¶ renders on IPython Notebook (alias to make usage more straightforward)
-
png
(**kwargs)¶
-
render
(fmt='svg', **kwargs)¶
-
save
(filename, **kwargs)¶
-
svg
(**kwargs)¶
-
-
class
Goulib.motion.
Segments
(segments=[], label='Segments')[source]¶ Bases:
Goulib.motion.Segment
can be initialized with a list of segment (that of course can also be a Segments) :param label: a label can be given
-
__init__
(segments=[], label='Segments')[source]¶ can be initialized with a list of segment (that of course can also be a Segments) :param label: a label can be given
-
insert
(segment, autoJoin=True)[source]¶ insert a segment into Segments :param segment: the segment to add. must be in a range that is not already defined or it will rise a value error exception :param autoJoin: if True and the added segment has the same starting position as the last segment’s end
and both velocity are 0 then a segment of (pos,v=0,a=0) is automatically added. this help discribing movements only where there is curently a movement
-
__class__
¶ alias of
builtins.type
-
__delattr__
¶ Implement delattr(self, name).
-
__dir__
()¶ Default dir() implementation.
-
__eq__
¶ Return self==value.
-
__format__
()¶ Default object formatter.
-
__ge__
¶ Return self>=value.
-
__getattribute__
¶ Return getattr(self, name).
-
__gt__
¶ Return self>value.
-
__hash__
¶ Return hash(self).
-
__init_subclass__
()¶ This method is called when a class is subclassed.
The default implementation does nothing. It may be overridden to extend subclasses.
-
__le__
¶ Return self<=value.
-
__lt__
¶ Return self<value.
-
__ne__
¶ Return self!=value.
-
__new__
()¶ Create and return a new object. See help(type) for accurate signature.
-
__reduce__
()¶ Helper for pickle.
-
__reduce_ex__
()¶ Helper for pickle.
-
__repr__
¶ Return repr(self).
-
__setattr__
¶ Implement setattr(self, name, value).
-
__sizeof__
()¶ Size of object in memory, in bytes.
-
dt
()¶
-
endAcc
()¶
-
endJerk
()¶
-
endPos
()¶
-
endSpeed
()¶
-
endTime
()¶
-
plot
(**kwargs)¶ renders on IPython Notebook (alias to make usage more straightforward)
-
png
(**kwargs)¶
-
render
(fmt='svg', **kwargs)¶
-
save
(filename, **kwargs)¶
-
startAcc
()¶
-
startJerk
()¶
-
startPos
()¶
-
startSpeed
()¶
-
startTime
()¶
-
svg
(**kwargs)¶
-
timeWhenPosBiggerThan
(pos, resolution=0.01)¶ search the first time when the position is bigger than pos :params pos: the pos that must at least be reached :params resolution: the time resolution in sec
-
-
class
Goulib.motion.
SegmentPoly
(t0, t1, p)[source]¶ Bases:
Goulib.motion.Segment
a segment defined by a polynomial position law
-
__call__
(t)¶ Call self as a function.
-
__class__
¶ alias of
builtins.type
-
__delattr__
¶ Implement delattr(self, name).
-
__dir__
()¶ Default dir() implementation.
-
__eq__
¶ Return self==value.
-
__format__
()¶ Default object formatter.
-
__ge__
¶ Return self>=value.
-
__getattribute__
¶ Return getattr(self, name).
-
__gt__
¶ Return self>value.
-
__hash__
¶ Return hash(self).
-
__init_subclass__
()¶ This method is called when a class is subclassed.
The default implementation does nothing. It may be overridden to extend subclasses.
-
__le__
¶ Return self<=value.
-
__lt__
¶ Return self<value.
-
__ne__
¶ Return self!=value.
-
__new__
()¶ Create and return a new object. See help(type) for accurate signature.
-
__reduce__
()¶ Helper for pickle.
-
__reduce_ex__
()¶ Helper for pickle.
-
__repr__
¶ Return repr(self).
-
__setattr__
¶ Implement setattr(self, name, value).
-
__sizeof__
()¶ Size of object in memory, in bytes.
-
__str__
¶ Return str(self).
-
dt
()¶
-
end
()¶
-
endAcc
()¶
-
endJerk
()¶
-
endPos
()¶
-
endSpeed
()¶
-
endTime
()¶
-
html
(**kwargs)¶
-
plot
(**kwargs)¶ renders on IPython Notebook (alias to make usage more straightforward)
-
png
(**kwargs)¶
-
render
(fmt='svg', **kwargs)¶
-
save
(filename, **kwargs)¶
-
start
()¶
-
startAcc
()¶
-
startJerk
()¶
-
startPos
()¶
-
startSpeed
()¶
-
startTime
()¶
-
svg
(**kwargs)¶
-
timeWhenPosBiggerThan
(pos, resolution=0.01)¶ search the first time when the position is bigger than pos :params pos: the pos that must at least be reached :params resolution: the time resolution in sec
-
-
Goulib.motion.
ramp
(dp, v0, v1, a)[source]¶ Parameters: - dp – float delta position or None if unknown
- v0 – float initial velocity or None if unknown
- v1 – float final velocity or None if unknown
- a – float acceleration
Returns: float shortest time to accelerate between constraints
-
Goulib.motion.
trapeze
(dp, vmax, a, v0=0, v2=0)[source]¶ Parameters: - dp – float delta position
- vmax – float maximal velocity
- a – float acceleration
- v0 – float initial velocity, 0 by default
- v2 – float final velocity, 0 by default
Returns: tuple of 6 values:
- time at end of acceleration
- position at end of acceleration
- velocity at end of acceleration
- time at begin of deceleration
- position at begin of deceleration
- total time
-
Goulib.motion.
Segment2ndDegree
(t0, t1, start, end=None)[source]¶ calculates a constant acceleration Segment between start and end
Parameters: - t0,t1 – float start,end time. one of both may be None for undefined
- start – (position, velocity, acceleration) float tuple. some values may be None for undefined
- end – (position, velocity, acceleration) float tuple. some values may be None for undefined
Returns: the function can cope with almost any combination of defined/undefined parameters, among others (see tests):
- Segment2ndDegree(t0,t1,(p0,v0),p1) # time interval and start + end positions + initial speed
- Segment2ndDegree(t0,t1,(p0,v0,a)) # time interval and start with acceleration
- Segment2ndDegree(t0,t1,None,(p1,v1,a)) # time interval and end pva
- Segment2ndDegree(t0,None,(p0,v0),(p1,v1)) # start + end positions + velocities
- Segment2ndDegree(t0,None,(p0,v0,a),(None,v1)) # start pva + end velocity
- Segment2ndDegree(None,t1,p0,(p1,v1,a)) # end pva + start position
the function also accepts some combinations of overconstraining parameters:
- Segment2ndDegree(t0,t1,(p0,v0,a),p1) # time interval, start pva, end position => adjust t1
- Segment2ndDegree(t0,t1,(p0,v0,a),(None,v1)) # time interval, start pva, v1=max vel => adjust t1
Raises: ValueError – when not enough parameters are specified to define the Segment univoquely
-
Goulib.motion.
Segment4thDegree
(t0, t1, start, end)[source]¶ smooth trajectory from an initial position and initial speed (p0,v0) to a final position and speed (p1,v1) * if t1<=t0, t1 is calculated
-
Goulib.motion.
SegmentsTrapezoidalSpeed
(t0, p0, p3, a, T=0, vmax=inf, v0=0, v3=0)[source]¶ Parameters: - t0 – float start time
- p0 – float start position
- p3 – float end position
- a – float specified acceleration. if =0, use specified time
- T – float specified time. if =0 (default), use specified acceleration
- vmax – float max speed. default is infinity (i.e. triangular speed)
- v0 – initial speed
- v3 –
final speed if T <> 0 then v3 = v0 v1 +——-+
/ / + v3
- v0 +
- | | |
t0 t1 t2 t3