![]() |
PsiSwarm Library
0.8
|
#include <sensors.h>
Public Member Functions | |
float | get_battery_voltage (void) |
float | get_current (void) |
float | get_dc_voltage (void) |
float | get_temperature (void) |
void | enable_ultrasonic_ticker (void) |
void | disable_ultrasonic_ticker (void) |
void | update_ultrasonic_measure (void) |
void | IF_read_ultrasonic_measure (void) |
void | store_background_raw_ir_values (void) |
void | store_illuminated_raw_ir_values (void) |
void | store_ir_values (void) |
unsigned short | get_background_raw_ir_value (char index) |
unsigned short | get_illuminated_raw_ir_value (char index) |
unsigned short | calculate_side_ir_value (char index) |
unsigned short | read_illuminated_raw_ir_value (char index) |
void | store_background_base_ir_values (void) |
void | store_illuminated_base_ir_values (void) |
void | store_base_ir_values (void) |
unsigned short | get_background_base_ir_value (char index) |
unsigned short | get_illuminated_base_ir_value (char index) |
unsigned short | calculate_base_ir_value (char index) |
void | store_reflected_ir_distances (void) |
float | read_reflected_ir_distance (char index) |
float | get_reflected_ir_distance (char index) |
float | calculate_reflected_distance (unsigned short background_value, unsigned short illuminated_value) |
int | get_bearing_from_ir_array (unsigned short *ir_sensor_readings) |
void | store_line_position (void) |
void | calibrate_base_ir_sensors (void) |
Sensors class Functions to read values from the Psi Swarm infrared, ultrasonic, temperature and power sensors
Example:
unsigned short Sensors::calculate_base_ir_value | ( | char | index | ) |
Returns the subtraction of the background base IR value from the reflection based on last call of store_base_ir_values() For most purposes this is the best method of getting values from the base IR sensor as it mitigates for background levels of IR
index | - The index of the sensor to read (range 0 to 4, sensor from left to right viewed from above - 2 is in middle of front) |
Definition at line 407 of file sensors.cpp.
unsigned short Sensors::calculate_side_ir_value | ( | char | index | ) |
Returns the subtraction of the background side IR value from the reflection based on last call of store_ir_values() For most purposes this is the best method of detected obstacles etc as it mitigates for varying background levels of IR
index | - The index of the sensor to read (range 0 to 7, clockwise around robot from front-right) |
Definition at line 420 of file sensors.cpp.
void Sensors::disable_ultrasonic_ticker | ( | void | ) |
Disables the ultrasonic ticker
Definition at line 37 of file sensors.cpp.
void Sensors::enable_ultrasonic_ticker | ( | void | ) |
Enables a 10Hz ticker that automatically takes readings from the SRF-02 ultrasonic sensor (if fitted)
Definition at line 32 of file sensors.cpp.
unsigned short Sensors::get_background_base_ir_value | ( | char | index | ) |
Returns the stored value of the non-illuminated base IR sensor value based on last call of store_background_base_ir_values Call either store_base_ir_values() or store_background_base_ir_values() before using this function to update reading
index | - The index of the sensor to read (range 0 to 4, sensor from left to right viewed from above - 2 is in middle of front) |
Definition at line 299 of file sensors.cpp.
unsigned short Sensors::get_background_raw_ir_value | ( | char | index | ) |
Returns the stored value of the non-illuminated side-facing IR sensor value based on last call of store_background_raw_ir_values Call either store_ir_values() or store_background_raw_ir_values() before using this function to update reading
index | - The index of the sensor to read (range 0 to 7, clockwise around robot from front-right) |
Definition at line 175 of file sensors.cpp.
float Sensors::get_battery_voltage | ( | void | ) |
Returns the current battery voltage for the robot
Definition at line 87 of file sensors.cpp.
float Sensors::get_current | ( | void | ) |
Returns the current being used by the robot
Definition at line 93 of file sensors.cpp.
float Sensors::get_dc_voltage | ( | void | ) |
Returns the voltage sensed from the DC input (post rectification)
Definition at line 101 of file sensors.cpp.
unsigned short Sensors::get_illuminated_base_ir_value | ( | char | index | ) |
Returns the stored value of the illuminated base IR sensor value based on last call of store_illuminated_base_ir_values Call either store_base_ir_values() or store_illuminated_base_ir_values() before using this function to update reading
index | - The index of the sensor to read (range 0 to 4, sensor from left to right viewed from above - 2 is in middle of front) |
Definition at line 307 of file sensors.cpp.
unsigned short Sensors::get_illuminated_raw_ir_value | ( | char | index | ) |
Returns the stored value of the illuminated side-facing IR sensor value based on last call of store_illuminated_raw_ir_values Call either store_ir_values() or store_illuminated_raw_ir_values() before using this function to update reading
index | - The index of the sensor to read (range 0 to 7, clockwise around robot from front-right) |
Definition at line 183 of file sensors.cpp.
float Sensors::get_temperature | ( | void | ) |
Returns the temperature sensed by the digital thermometer placed near the front of the MBED socket
Definition at line 77 of file sensors.cpp.
unsigned short Sensors::read_illuminated_raw_ir_value | ( | char | index | ) |
Enables the IR emitter then returns the value of the given side-facing IR sensor This function is used when just one sensor is needed to be read; in general using store_ir_values() and get_illuminated_raw_ir_value(index) is preferable
index | - The index of the sensor to read (range 0 to 7, clockwise around robot from front-right) |
Definition at line 256 of file sensors.cpp.
void Sensors::store_background_base_ir_values | ( | void | ) |
Stores the raw ADC values for all 5 base IR sensors without enabling IR emitters
Definition at line 325 of file sensors.cpp.
void Sensors::store_background_raw_ir_values | ( | void | ) |
Stores the raw ADC values for all 8 IR side-facing sensors without enabling IR emitters
Definition at line 207 of file sensors.cpp.
void Sensors::store_base_ir_values | ( | void | ) |
Stores the raw ADC values for all 5 base IR sensors both before and after enabling IR emitters Calls store_background_base_ir_values() then store_illuminated_base_ir_values()
Definition at line 315 of file sensors.cpp.
void Sensors::store_illuminated_base_ir_values | ( | void | ) |
Stores the raw ADC values for all 5 base IR sensors after enabling IR emitters
Definition at line 334 of file sensors.cpp.
void Sensors::store_illuminated_raw_ir_values | ( | void | ) |
Stores the raw ADC values for all 8 IR side-facing sensors after enabling IR emitters
Definition at line 216 of file sensors.cpp.
void Sensors::store_ir_values | ( | void | ) |
Stores the raw ADC values for all 8 IR side-facing sensors both before and after enabling IR emitters Calls store_background_raw_ir_values() then store_illuminated_raw_ir_values()
Definition at line 200 of file sensors.cpp.
void Sensors::update_ultrasonic_measure | ( | void | ) |
Sends a message to SRF-02 ultrasonic sensor (if fitted) to instruct it to take a new reading. The result is available approx 70ms later
Definition at line 42 of file sensors.cpp.