utils Package

class pypot.utils.Point2D(x, y)

Bases: tuple

Create new instance of Point2D(x, y)

x

Alias for field number 0

y

Alias for field number 1

class pypot.utils.Point3D(x, y, z)

Bases: tuple

Create new instance of Point3D(x, y, z)

x

Alias for field number 0

y

Alias for field number 1

z

Alias for field number 2

pypot.utils.Point

alias of pypot.utils.Point3D

class pypot.utils.Vector3D(x, y, z)

Bases: tuple

Create new instance of Vector3D(x, y, z)

x

Alias for field number 0

y

Alias for field number 1

z

Alias for field number 2

pypot.utils.Vector

alias of pypot.utils.Vector3D

class pypot.utils.Quaternion(x, y, z, w)

Bases: tuple

Create new instance of Quaternion(x, y, z, w)

w

Alias for field number 3

x

Alias for field number 0

y

Alias for field number 1

z

Alias for field number 2

pypot.utils.attrsetter(item)[source]
class pypot.utils.SyncEvent(period=0.1)[source]

Bases: object

request()[source]
done()[source]
is_recent
needed

stoppablethread Module

class pypot.utils.stoppablethread.StoppableThread(setup=None, target=None, teardown=None)[source]

Bases: object

Stoppable version of python Thread.

This class provides the following mechanism on top of “classical” python Thread:
  • you can stop the thread (if you defined your run method accordingly).
  • you can restart a thread (stop it and re-run it)
  • you can pause/resume a thread

Warning

It is up to the subclass to correctly respond to the stop, pause/resume signals (see run() for details).

Parameters:
  • setup (func) – specific setup function to use (otherwise self.setup)
  • target (func) – specific target function to use (otherwise self.run)
  • teardown (func) – specific teardown function to use (otherwise self.teardown)
start()[source]

Start the run method as a new thread.

It will first stop the thread if it is already running.

stop(wait=True)[source]

Stop the thread.

More precisely, sends the stopping signal to the thread. It is then up to the run method to correctly responds.

join()[source]

Wait for the thread termination.

running

Whether the thread is running.

started

Whether the thread has been started.

wait_to_start(allow_failure=False)[source]

Wait for the thread to actually starts.

should_stop()[source]

Signals if the thread should be stopped or not.

wait_to_stop()[source]

Wait for the thread to terminate.

setup()[source]

Setup method call just before the run.

run()[source]

Run method of the thread.

Note

In order to be stoppable (resp. pausable), this method has to check the running property - as often as possible to improve responsivness - and terminate when should_stop() (resp. should_pause()) becomes True. For instance:

while self.should_stop():
    do_atom_work()
    ...
teardown()[source]

Teardown method call just after the run.

should_pause()[source]

Signals if the thread should be paused or not.

paused
pause()[source]

Requests the thread to pause.

resume()[source]

Requests the thread to resume.

wait_to_resume()[source]

Waits until the thread is resumed.

pypot.utils.stoppablethread.make_update_loop(thread, update_func)[source]

Makes a run loop which calls an update function at a predefined frequency.

class pypot.utils.stoppablethread.StoppableLoopThread(frequency, update=None)[source]

Bases: pypot.utils.stoppablethread.StoppableThread

LoopThread calling an update method at a pre-defined frequency.

Note

This class does not mean to be accurate. The given frequency will be approximately followed - depending for instance on CPU load - and only reached if the update method takes less time than the chosen loop period.

Params float frequency:
 called frequency of the update() method
run()[source]

Called the update method at the pre-defined frequency.

update()[source]

Update method called at the pre-defined frequency.

trajectory Module

class pypot.utils.trajectory.MinimumJerkTrajectory(initial, final, duration, init_vel=0.0, init_acc=0.0, final_vel=0.0, final_acc=0.0)[source]

Bases: object

compute()[source]
get_value(t)[source]
domain(x)[source]
test_domain(x)[source]
fix_input(x)[source]
get_generator()[source]
class pypot.utils.trajectory.GotoMinJerk(motor, position, duration, frequency=50)[source]

Bases: pypot.utils.stoppablethread.StoppableLoopThread

setup()[source]

Setup method call just before the run.

update()[source]

Update method called at the pre-defined frequency.

elapsed_time
class pypot.utils.trajectory.GotoLinear(motor, position, duration, frequency=50)[source]

Bases: pypot.utils.stoppablethread.StoppableLoopThread

update()[source]

Update method called at the pre-defined frequency.