spike.motionsensor

Hub motion sensor mock API

Classes

MotionSensor()

Motion sensor mocking class

class spike.motionsensor.MotionSensor

Motion sensor mocking class

Class is accessed simultaneously by the user side thread and the ground truth update thread. It is therefore protected by a mutex

__init__()

Contructor

get_roll_angle()

Retrieves the Hub’s roll angle. Roll is the rotation around the front-back (longitudinal) axis.

Returns:

the roll angle, specified in degrees.

Return type:

integer [-180,180]

get_pitch_angle()

Retrieves the Hub’s pitch angle. Pitch is the rotation around the left-right (transverse) axis.

Returns:

the pitch angle, specified in degrees.

Return type:

integer [-180,180]

get_yaw_angle()

Retrieves the Hub’s yaw angle. Yaw is the rotation around the front-back (vertical) axis

Returns:

the yaw angle, specified in degrees.

Return type:

integer [-180,180]

reset_yaw_angle()

Sets the yaw angle to “0.”

get_gesture()

Retrieves the most recently-detected gesture.

Returns:

last gesture

Return type:

string

was_gesture(gesture)

Tests whether a gesture has occurred since the last time was_gesture() was used, or since the beginning of the program (for the first use).

Parameters:

gesture (string ("shaken","tapped","double-tapped","falling","none")) – the name of the gesture.

Raises:
  • ValueError – gesture is not one of the allowed values.

  • TypeError – gesture is not a string

Returns:

True if the gesture has occurred since the last time was_gesture() was called, otherwise False.

Return type:

boolean

get_orientation()

Retrieves the Hub’s current orientation.

Returns:

the hub current orientation

Return type:

string (‘front’,’back’,’up’,’down’,’leftside’,’rightside’)

wait_for_new_gesture()

Waits until a new gesture happens.

wait_for_new_orientation()

Waits until the Hub’s orientation changes.

The first time this method is called, it will immediately return the current value. After that, calling this method will block the program until the Hub’s orientation has changed since the previous time this method was called.

Returns:

the hub new orientation

Return type:

string (‘front’,’back’,’up’,’down’,’leftside’,’rightside’)

c_reset()

Reset function

Warning

This function is not part of the spike API. It is provided to update the component from scenario data and shall not be used by the end-user.

c_read(yaw, pitch, roll, gesture)

Update the current orientation from scenario data

Warning

This function is not part of the spike API. It is provided to update the component from scenario data and shall not be used by the end-user.

Parameters:
  • yaw (integer [-180,180]) – the yaw angle, specified in degrees.

  • pitch (integer [-180,180]) – the pitch angle, specified in degrees.

  • roll (integer [-180,180]) – the roll angle, specified in degrees.

  • gesture (string ("shaken","tapped","double-tapped","falling","none")) – the name of the gesture.

Raises:

ValueError – Invalid gesture