Skip to main content

Movement

OLEM has 3 holonomic wheels which allow him to move in any direction and to freely combine movements in (x, y, theta).

NB: OLEM does his best to follow your instructions but if he can detect the edge of the board or table, he will make sure not to fall.

OLEM seen from above, with its x and y axes

With the exception of wait_stop_moving(), all movement functions are non-blocking.

Movements can be requested in the cartesian or the polar space.

Movements can be requested using the current position as a referential or the starting position.

Examples​

Speed control​

OLEM goes back and forth 10 times, faster each time.

import olem

for i in range(10):
print(i)
olem.set_move_speed((i + 1) / 10)
olem.move(100, 0, 0)
olem.wait_stop_moving()
olem.move(-100, 0, 0)
olem.wait_stop_moving()

Moving in a square​

OLEM goes around the same square twice, first with relative movements (move()) then with absolute ones (move_to()).

import olem

def square_path_relative(side_length, speed):
"""
OLEM move in a square of specified width at requested speed
always facing the same direction. OLEM's current position is
used as the bottom left corner.
:param side_length: square width in mm
:param speed: between 0 and 1.0
"""
olem.set_move_speed(speed)
olem.move(side_length, 0, 0)
olem.wait_stop_moving()
olem.move(0, side_length, 0)
olem.wait_stop_moving()
olem.move(-side_length, 0, 0)
olem.wait_stop_moving()
olem.move(0, -side_length, 0)
olem.wait_stop_moving()

def square_path_absolute(side_length, speed):
"""
OLEM move in a square of specified width at requested speed
always facing the same direction.
:param side_length: square width in mm
:param speed: between 0 and 1.0
"""
olem.set_move_speed(speed)
olem.move_to(side_length, 0, 0)
olem.wait_stop_moving()
olem.move_to(side_length, side_length, 0)
olem.wait_stop_moving()
olem.move_to(0, side_length, 0)
olem.wait_stop_moving()
olem.move_to(0, 0, 0)
olem.wait_stop_moving()

square_width = 100
speed = 8 / 10

square_path_relative(square_width, speed)
square_path_absolute(square_width, speed)

Constants and functions​

Constants​

ConstantValueDescription
MOVE_CORR_X_MASK1Correction along the x axis, based on the lines of the tiles.
MOVE_CORR_Y_MASK2Correction along the y axis, based on the lines of the tiles.
MOVE_CORR_DISTANCE_MASK4Correction of the travelled distance, based on the spacing between the lines of the tiles. Requires MOVE_CORR_X_MASK.
MOVE_CORR_IWJ_MASK32
MOVE_CORR_ISS_MASK64
MOVE_CORR_MSAFE_MASK128Refuse movements that would make OLEM fall off the board or table.

move(x, y, rotation)​

Move OLEM by the requested amount in cartesian space, relative to its current position.

Returns immediately, use wait_stop_moving() to wait for the end of the movement.

ParameterDescription
xtranslation along the x axis in mm
ytranslation along the y axis in mm
rotationrotation in degrees

move_to(x, y, orientation)​

Move OLEM to a position in cartesian space, relative to its position at startup or at the last reset_position().

Returns immediately, use wait_stop_moving() to wait for the end of the movement.

ParameterDescription
xposition along the x axis in mm
yposition along the y axis in mm
orientationorientation in degrees

wait_stop_moving()​

Block until OLEM stops moving.

The wait ends if the game is stopped.

stop_moving()​

Stop the current movement.

turn(rotation)​

Turn OLEM on itself by the requested angle.

Returns immediately, use wait_stop_moving() to wait for the end of the rotation.

ParameterDescription
rotationrotation in degrees

turn_to(orientation)​

Turn OLEM on itself to the requested orientation.

Returns immediately, use wait_stop_moving() to wait for the end of the rotation.

ParameterDescription
orientationorientation in degrees

move_polar(distance, direction, rotation)​

Move OLEM by the requested amount in polar space, relative to its current position.

Returns immediately, use wait_stop_moving() to wait for the end of the movement.

ParameterDescription
distancedistance to travel in mm
directiondirection of the movement in degrees
rotationrotation in degrees

move_to_polar(distance, direction, orientation)​

Move OLEM to a position given in polar space, relative to its position at startup or at the last reset_position().

Returns immediately, use wait_stop_moving() to wait for the end of the movement.

ParameterDescription
distancedistance from the origin in mm
directiondirection from the origin in degrees
orientationorientation in degrees

move_towards(direction)​

Move OLEM in a direction until stop_moving() is called.

ParameterDescription
directiondirection in degrees, relative to OLEM's current orientation

set_move_speed(speed)​

Set the speed of the movements requested after this call.

The default speed is 1.0.

ParameterDescription
speedfraction of the maximum speed, from 0.0 to 1.0

get_move_speed()​

Returns: speed set with set_move_speed(), from 0.0 to 1.0

get_position_x()​

Returns: position along the x axis in mm, relative to the position at startup or at the last reset_position()

get_position_y()​

Returns: position along the y axis in mm, relative to the position at startup or at the last reset_position()

get_orientation()​

Returns: orientation in degrees, from 0 to 359

get_orientation_absolute()​

Unlike get_orientation(), the orientation is not brought back between 0 and 359: it keeps counting full turns and can be above 360 or negative.

Returns: orientation in degrees, as an integer

reset_position()​

Stop the current movement and use the current position as the new origin: position (0, 0) and orientation 0.

is_moving()​

Returns: True if OLEM is moving, False otherwise

center_on_rotate(angle)​

Re-center OLEM on its tile: OLEM turns on itself and uses the lines of the tile seen by its floor sensors to correct its position.

Returns immediately. Has no effect if a centering is already running.

ParameterDescription
anglerotation to perform in degrees, 90 is recommended

move_correction_enable(mask)​

Enable automatic corrections of the movements.

ParameterDescription
maskcorrections to enable, combine MOVE_CORR_* constants with |

move_correction_disable(mask)​

Disable automatic corrections of the movements.

ParameterDescription
maskcorrections to disable, combine MOVE_CORR_* constants with |