pyzenbo.modules.sensor module¶
- class pyzenbo.modules.sensor.Sensor(inter_comm)¶
Bases:
object
- register_capacity_touch_sensor_event(event_type=0, sync=True, timeout=None)¶
Register the capacity touch sensor event callback, the result is returned by on_result_callback.
- Parameters
event_type – event type 1 to 4, 0 means receive all event 0: receive all event type 1: 0.35 sec. > touch time ≥ 0.005 sec. 2: 1 sec. > touch time ≥ 0.35 sec. 3: 3 sec. > touch time ≥ 1 sec. 4: touch time > 3 sec.
sync – True if this command is blocking
timeout – maximum blocking time in second, None means infinity
- Returns
serial number of the command, if command is blocking also return a dict, it include two key, ‘state’ indicate execute result and ‘error’ will contain error code
- unregister_capacity_touch_sensor_event(event_type=0, sync=True, timeout=None)¶
Unregister the capacity touch sensor event callback.
- Parameters
event_type – event type 1 to 4, 0 means receive all event 0: receive all event type 1: 0.35 sec. > touch time ≥ 0.005 sec. 2: 1 sec. > touch time ≥ 0.35 sec. 3: 3 sec. > touch time ≥ 1 sec. 4: touch time > 3 sec.
sync – True if this command is blocking
timeout – maximum blocking time in second, None means infinity
- Returns
serial number of the command, if command is blocking also return a dict, it include two key, ‘state’ indicate execute result and ‘error’ will contain error code
- wait_for_capacity_touch_sensor_event(event_type=0, timeout=10)¶
Wait for capacity touch event occur and return sensor result.
- Parameters
event_type – event type 1 to 4, 0 means receive all event 0: receive all event type 1: 0.35 sec. > touch time ≥ 0.005 sec. 2: 1 sec. > touch time ≥ 0.35 sec. 3: 3 sec. > touch time ≥ 1 sec. 4: touch time > 3 sec.
timeout – maximum blocking time in second, None means infinity
- Returns
sensor result, if timeout will return None
- get_sonar(position, sync=True, timeout=None)¶
Get sonar sensor value, the result is returned by on_result_callback.
- Parameters
position – sonar position 0: front right 1: front left 2 :front center
sync – True if this command is blocking
timeout – maximum blocking time in second, None means infinity
- Returns
serial number of the command, if command is blocking also return a dict, it include two key, ‘state’ indicate execute result and ‘error’ will contain error code
- register_sonar(position, interval=0.5, sync=True, timeout=None)¶
Register the sonar sensor callback, the result is returned by on_result_callback.
- Parameters
position – sonar position 0: front right 1: front left 2: front center 255: all sonar
interval – callback interval accept only positive numeric in seconds, default and minimum value is 0.5 second
sync – True if this command is blocking
timeout – maximum blocking time in second, None means infinity
- Returns
serial number of the command, if command is blocking also return a dict, it include two key, ‘state’ indicate execute result and ‘error’ will contain error code
- unregister_sonar(position, sync=True, timeout=None)¶
Unregister the sonar sensor callback.
- Parameters
position – sonar position 0: front right 1: front left 2: front center
sync – True if this command is blocking
timeout – maximum blocking time in second, None means infinity
- Returns
serial number of the command, if command is blocking also return a dict, it include two key, ‘state’ indicate execute result and ‘error’ will contain error code
- register_sonar_event(position, operator, value, sync=True, timeout=None)¶
Register the sonar sensor event callback, when sensor reach the condition that specified, the result is returned by on_result_callback.
- Parameters
position – sonar position 0: front right 1: front left 2 :front center
operator – comparison type with a threshold value. 0: = (Equal) 1: ≠ (Not Equal) 2: > (Greater Than) 3: ≥ (Greater Than or Equal To) 4: < (Less Than) 5: ≤ (Less Than or Equal To)
value – threshold value to compare sensor data (meter)
sync – True if this command is blocking
timeout – maximum blocking time in second, None means infinity
- Returns
serial number of the command, if command is blocking also return a dict, it include two key, ‘state’ indicate execute result and ‘error’ will contain error code
- unregister_sonar_event(position, operator, value, sync=True, timeout=None)¶
Unregister the sonar sensor event callback.
- Parameters
position – sonar position 0: front right 1: front left 2 :front center
operator – comparison type with a threshold value. 0: = (Equal) 1: ≠ (Not Equal) 2: > (Greater Than) 3: ≥ (Greater Than or Equal To) 4: < (Less Than) 5: ≤ (Less Than or Equal To)
value – threshold value to compare sensor data (meter)
sync – True if this command is blocking
timeout – maximum blocking time in second, None means infinity
- Returns
serial number of the command, if command is blocking also return a dict, it include two key, ‘state’ indicate execute result and ‘error’ will contain error code
- get_neck_encoder(sync=True, timeout=None)¶
Get neck encoder value, the result is returned by on_result_callback.
- Parameters
sync – True if this command is blocking
timeout – maximum blocking time in second, None means infinity
- Returns
serial number of the command, if command is blocking also return a dict, it include two key, ‘state’ indicate execute result and ‘error’ will contain error code
- register_neck_encoder(interval=0.5, sync=True, timeout=None)¶
Register the neck encoder callback, the result is returned by on_result_callback.
- Parameters
interval – callback interval accept only positive numeric in seconds, default and minimum value is 0.5 second
sync – True if this command is blocking
timeout – maximum blocking time in second, None means infinity
- Returns
serial number of the command, if command is blocking also return a dict, it include two key, ‘state’ indicate execute result and ‘error’ will contain error code
- unregister_neck_encoder(sync=True, timeout=None)¶
Unregister the neck encoder callback.
- Parameters
sync – True if this command is blocking
timeout – maximum blocking time in second, None means infinity
- Returns
serial number of the command, if command is blocking also return a dict, it include two key, ‘state’ indicate execute result and ‘error’ will contain error code
- register_neck_encoder_event(operator, value, sync=True, timeout=None)¶
Register the neck encoder event callback, when neck encoder reach the condition that specified, the result is returned by on_result_callback.
- Parameters
operator – comparison type with a threshold value. 0: = (Equal) 1: ≠ (Not Equal) 2: > (Greater Than) 3: ≥ (Greater Than or Equal To) 4: < (Less Than) 5: ≤ (Less Than or Equal To)
value – threshold value to compare sensor data
sync – True if this command is blocking
timeout – maximum blocking time in second, None means infinity
- Returns
serial number of the command, if command is blocking also return a dict, it include two key, ‘state’ indicate execute result and ‘error’ will contain error code
- unregister_neck_encoder_event(operator, value, sync=True, timeout=None)¶
Unregister the neck encoder event callback.
- Parameters
operator – comparison type with a threshold value. 0: = (Equal) 1: ≠ (Not Equal) 2: > (Greater Than) 3: ≥ (Greater Than or Equal To) 4: < (Less Than) 5: ≤ (Less Than or Equal To)
value – threshold value to compare sensor data
sync – True if this command is blocking
timeout – maximum blocking time in second, None means infinity
- Returns
serial number of the command, if command is blocking also return a dict, it include two key, ‘state’ indicate execute result and ‘error’ will contain error code
- register_trigger_key_event(sync=True, timeout=None)¶
Register the trigger key event callback, the result is returned by on_result_callback.
- Parameters
sync – True if this command is blocking
timeout – maximum blocking time in second, None means infinity
- Returns
serial number of the command, if command is blocking also return a dict, it include two key, ‘state’ indicate execute result and ‘error’ will contain error code
- unregister_trigger_key_event(sync=True, timeout=None)¶
Unregister the trigger key event callback.
- Parameters
sync – True if this command is blocking
timeout – maximum blocking time in second, None means infinity
- Returns
serial number of the command, if command is blocking also return a dict, it include two key, ‘state’ indicate execute result and ‘error’ will contain error code
- register_volume_up_key_event(sync=True, timeout=None)¶
Register the volume up key event callback, the result is returned by on_result_callback.
- Parameters
sync – True if this command is blocking
timeout – maximum blocking time in second, None means infinity
- Returns
serial number of the command, if command is blocking also return a dict, it include two key, ‘state’ indicate execute result and ‘error’ will contain error code
- unregister_volume_up_key_event(sync=True, timeout=None)¶
Unregister the volume up key event callback.
- Parameters
sync – True if this command is blocking
timeout – maximum blocking time in second, None means infinity
- Returns
serial number of the command, if command is blocking also return a dict, it include two key, ‘state’ indicate execute result and ‘error’ will contain error code
- register_volume_down_key_event(sync=True, timeout=None)¶
Register the volume down key event callback, the result is returned by on_result_callback.
- Parameters
sync – True if this command is blocking
timeout – maximum blocking time in second, None means infinity
- Returns
serial number of the command, if command is blocking also return a dict, it include two key, ‘state’ indicate execute result and ‘error’ will contain error code
- unregister_volume_down_key_event(sync=True, timeout=None)¶
Unregister the volume down key event callback.
- Parameters
sync – True if this command is blocking
timeout – maximum blocking time in second, None means infinity
- Returns
serial number of the command, if command is blocking also return a dict, it include two key, ‘state’ indicate execute result and ‘error’ will contain error code
- wait_for_trigger_key_event(timeout=10)¶
Wait for trigger key event occur and return sensor result.
- Parameters
timeout – maximum blocking time in second, None means infinity
- Returns
sensor result, if timeout will return None