PsiSwarm Library  0.8
Sensors Class Reference

#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)
 

Detailed Description

Sensors class Functions to read values from the Psi Swarm infrared, ultrasonic, temperature and power sensors

Example:

#include "psiswarm.h"
int main() {
init();
}

Definition at line 39 of file sensors.h.

Member Function Documentation

§ calculate_base_ir_value()

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

Parameters
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)
Returns
Unsigned short of compensated ir value (illuminated value - background value) (range 0 to 4095)

Definition at line 407 of file sensors.cpp.

§ calculate_side_ir_value()

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

Parameters
index- The index of the sensor to read (range 0 to 7, clockwise around robot from front-right)
Returns
Unsigned short of compensated ir value (illuminated value - background value) (range 0 to 4095)

Definition at line 420 of file sensors.cpp.

§ disable_ultrasonic_ticker()

void Sensors::disable_ultrasonic_ticker ( void  )

Disables the ultrasonic ticker

Definition at line 37 of file sensors.cpp.

§ enable_ultrasonic_ticker()

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.

§ get_background_base_ir_value()

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

Parameters
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)
Returns
Unsigned short of background IR reading (range 0 to 4095)

Definition at line 299 of file sensors.cpp.

§ get_background_raw_ir_value()

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

Parameters
index- The index of the sensor to read (range 0 to 7, clockwise around robot from front-right)
Returns
Unsigned short of background IR reading (range 0 to 4095)

Definition at line 175 of file sensors.cpp.

§ get_battery_voltage()

float Sensors::get_battery_voltage ( void  )

Returns the current battery voltage for the robot

Returns
The voltage (in V); this should range between 3.5V for a discharged battery and 4.2V for a fully charged battery

Definition at line 87 of file sensors.cpp.

§ get_current()

float Sensors::get_current ( void  )

Returns the current being used by the robot

Returns
The current (in A)

Definition at line 93 of file sensors.cpp.

§ get_dc_voltage()

float Sensors::get_dc_voltage ( void  )

Returns the voltage sensed from the DC input (post rectification)

Returns
The voltage (in V); note some back-voltage from the battery is expected even when no DC input is detected

Definition at line 101 of file sensors.cpp.

§ get_illuminated_base_ir_value()

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

Parameters
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)
Returns
Unsigned short of illuminated IR reading (range 0 to 4095)

Definition at line 307 of file sensors.cpp.

§ get_illuminated_raw_ir_value()

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

Parameters
index- The index of the sensor to read (range 0 to 7, clockwise around robot from front-right)
Returns
Unsigned short of illuminated IR reading (range 0 to 4095)

Definition at line 183 of file sensors.cpp.

§ get_temperature()

float Sensors::get_temperature ( void  )

Returns the temperature sensed by the digital thermometer placed near the front of the MBED socket

Returns
The temperature (in degrees C)

Definition at line 77 of file sensors.cpp.

§ read_illuminated_raw_ir_value()

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

Parameters
index- The index of the sensor to read (range 0 to 7, clockwise around robot from front-right)
Returns
Unsigned short of illuminated IR reading (range 0 to 4095)

Definition at line 256 of file sensors.cpp.

§ store_background_base_ir_values()

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.

§ store_background_raw_ir_values()

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.

§ store_base_ir_values()

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.

§ store_illuminated_base_ir_values()

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.

§ store_illuminated_raw_ir_values()

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.

§ store_ir_values()

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.

§ update_ultrasonic_measure()

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.


The documentation for this class was generated from the following files: