roboglia.move.Motion

class Motion(name='MOTION', patience=1.0, frequency=None, warning=0.9, throttle=0.1, review=1.0, manager=None, joints=[])[source]

Bases: roboglia.base.thread.BaseLoop

Class that helps with the implementation of code-driven joint control. It is a subclass of BaseLoop and inherits all its properties. In addition it stores references to the robot and the joints that are used. For convenience it includes a ticks property that provides the number of seconds from the start of the loop. It is intended to be used to generate behavior that is dependent of time (ex. sinus / cosines) trajectories.

Parameters
  • name (str) – The name of the motion

  • patience (float) – A duration in seconds that the main thread will wait for the background thread to finish setup activities and indicate that it is in started mode.

  • frequency (float) – The loop frequency in [Hz]

  • warning (float) – Indicates a threshold in range [0..1] indicating when warnings should be logged to the logger in case the execution frequency is bellow the target. A 0.8 value indicates the real execution is less than 0.8 * target_frequency. The statistic is calculated over a period of time specified by the parameter review.

  • throttle (float) – Is a float (< 1.0) that is used by the monitoring of execution statistics to adjust the wait time in order to produce the desired processing frequency.

  • review (float) – The time in [s] to calculate the statistics for the frequency.

  • robot (JointManager or subclass) – The robot Joint Manager that controls the moves.

  • joints (list of Joint or subclass) – The joints used by the motion process.

__init__(name='MOTION', patience=1.0, frequency=None, warning=0.9, throttle=0.1, review=1.0, manager=None, joints=[])[source]

Initialize self. See help(type(self)) for accurate signature.

setup()[source]

Called when starting the loop. Resets the ticks counter.

manager()[source]

The robot associated with the motion.

joints()[source]

Joints used by the motion.

ticks()[source]

Seconds passed since the loop started.

atomic()[source]

Called with frequency frequency, this should be implemented in the subclass that implements the motion.

property actual_frequency

Returns the actual running frequency that is calculated by statistics.

property error_stat

(error in %, total errors, total items).

Type

Returns the error statistics as a tuple

property errors

Returns the number of errors logged by the statistics.

property frequency

Loop frequency.

inc_errors()

Used by subclasses to increment the number of errors.

inc_processed()

Used by subclasses to increment the number of processed items.

property name

Returns the name of the thread.

pause()

Requests the thread to pause.

property paused

Indicates the thread was paused.

property period

Loop period = 1 / frequency.

property processed

Returns the number of items processed in the current statistics. The items processed depends on the loop and might be different from the number of loops executed. For example the one execution loop might include several communication packets.

resume()

Requests the thread to resume.

property review

Indicates the amount of time in seconds before the thread will review the actual frequency against the target and take action.

run()

Run method of the thread.

property running

Indicates if the thread is running.

start(wait=True)

Starts the task in it’s own thread.

property started

Indicates if the thread was started.

stop(wait=True)

Sends the stopping signal to the thread. By default waits for the thread to finish.

property stopped

Indicates if the thread was stopped.

teardown()

Thread cleanup. Subclasses should override.

property warning

Control the warning level for the warning message, the setter is smart: if the value is larger than 2 it will assume it is a percentage and divied it by 100 and ignore if the number is higher than 110. The over 100 is available for testing purposes.