Permalink
Browse files

moved the Tone and Blob classes to the EPuck header and namespace.

Now no need for global data classes or types.
  • Loading branch information...
1 parent ac10623 commit aa7463adbcad4ddc9b7d782c286b300139540b99 Jenny Owen committed Feb 10, 2012
Showing with 77 additions and 70 deletions.
  1. +4 −0 include/AudioHandler.h
  2. +0 −56 include/DataStructures.h
  3. +50 −1 include/EPuck.h
  4. +3 −2 include/EPuckReal.h
  5. +6 −3 include/EPuckSim.h
  6. +5 −0 src/AudioHandler.cc
  7. +5 −4 src/EPuckReal.cc
  8. +4 −4 src/EPuckSim.cc
View
@@ -128,10 +128,14 @@ class AudioHandler
virtual ~AudioHandler();
//methods.
+ /**Returns the number of blocks in the fourier transform we run.*/
+ int getFFTBlockSize(void);
void playTone(int freq, double duration, double volume, char* name);
int getNumberOfTones(void);
int getTones(char* robotName, audio_message_t *store, size_t storesize);
+
+
/** Test function to print all of the sound environment data to stdout.
* */
void dumpData_TEST(void);
View
@@ -1,56 +0,0 @@
-#ifndef DATASTRUCTURES_H
-#define DATASTRUCTURES_H
-
-/**
- * A substitute for the player_blobfinder_blob_t structure. This one has all the variables in nice units (mostly ints),
- * instead of sucky ones (mostly uint32_t). Plus it doesn't require and Player headers to be included outside of this API.
- * Data is stored as member variables in the class, they are all public so can be accessed using the dot operator (.).
- * As in blobobject.variableName eg blobobject.x or blobobject.area
- * */
-class Blob
-{
-public:
- /**Index reference that the blobfinder proxy gave to this blob*/
- int id;
- /**Colour of the blob in hex. Format is 0xaaRRGGBB, aa being the alpha component of the colour*/
- //TODO fix colours so that it works with the stuff you wrote for stage.
- uint32_t colour;
- /**area of the blob*/
- int area;
- /**Centre of the blob, coordinates referenced by top left corner of camera image*/
- int x;
- /**Centre of the blob, coordinates referenced by top left corner of camera image*/
- int y;
- /**Left edge of bounding box for the blob [pixels] referenced by the top left corner of camera image.*/
- int left;
- /**right edge of bounding box for the blob [pixels] referenced by the top left corner of camera image.*/
- int right;
- /**top edge of bounding box for the blob [pixels] referenced by the top left corner of camera image.*/
- int top;
- /**bottom edge of bounding box for the blob [pixels] referenced by the top left corner of camera image.*/
- int bottom;
-};
-
-/**
- * Stores information about the tones in a single frequency band that can be heard by the robot.
- * This is the information that the robot will be able to detect and is all robot-centric.
- * @see EPuck#getTone
- * @see EPuck#listenForTones
- * @see EPuck#getBlob
- * */
-class Tone
-{
-public:
- /**The lower bound on the frequency range this tone could be*/
- double frequency;
- /**The volume of the tone. This is some arbitrary number without a real measurement, but they are consistent with each other so can be
- * compared to other tones and volumes*/
- double volume;
- /**The bearing of the sound source with respect to the EPuck. If it is directly in front of the EPuck this will be 0,
- * bearings are then measured in DEGREES anticlockwise from the robot's front.*/
- int bearing;
-};
-
-
-
-#endif
View
@@ -2,7 +2,7 @@
#define EPUCK_H
#include "libplayerc++/playerc++.h"
-#include "DataStructures.h"
+//#include "DataStructures.h"
/**Debugging flag. If set to 1 the debugging functions are compiled and can be accessed.*/
#define DEBUGGING 0
@@ -25,6 +25,55 @@ class EPuck
public:
+ /**
+ * A substitute for the player_blobfinder_blob_t structure. This one has all the variables in nice units (mostly ints),
+ * instead of sucky ones (mostly uint32_t). Plus it doesn't require and Player headers to be included outside of this API.
+ * Data is stored as member variables in the class, they are all public so can be accessed using the dot operator (.).
+ * As in blobobject.variableName eg blobobject.x or blobobject.area
+ * */
+ class Blob
+ {
+ public:
+ /**Index reference that the blobfinder proxy gave to this blob*/
+ int id;
+ /**Colour of the blob in hex. Format is 0xaaRRGGBB, aa being the alpha component of the colour*/
+ uint32_t colour;
+ /**area of the blob*/
+ int area;
+ /**Centre of the blob, coordinates referenced by top left corner of camera image*/
+ int x;
+ /**Centre of the blob, coordinates referenced by top left corner of camera image*/
+ int y;
+ /**Left edge of bounding box for the blob [pixels] referenced by the top left corner of camera image.*/
+ int left;
+ /**right edge of bounding box for the blob [pixels] referenced by the top left corner of camera image.*/
+ int right;
+ /**top edge of bounding box for the blob [pixels] referenced by the top left corner of camera image.*/
+ int top;
+ /**bottom edge of bounding box for the blob [pixels] referenced by the top left corner of camera image.*/
+ int bottom;
+ };
+
+ /**
+ * Stores information about the tones in a single frequency band that can be heard by the robot.
+ * This is the information that the robot will be able to detect and is all robot-centric.
+ * @see EPuck#getTone
+ * @see EPuck#listenForTones
+ * @see EPuck#getBlob
+ * */
+ class Tone
+ {
+ public:
+ /**The lower bound on the frequency range this tone could be*/
+ double frequency;
+ /**The volume of the tone. This is some arbitrary number without a real measurement, but they are consistent with each other so can be
+ * compared to other tones and volumes*/
+ double volume;
+ /**The bearing of the sound source with respect to the EPuck. If it is directly in front of the EPuck this will be 0,
+ * bearings are then measured in DEGREES anticlockwise from the robot's front.*/
+ int bearing;
+ };
+
//==========================================================
// CONSTANTS
View
@@ -115,7 +115,7 @@ class EPuckReal : public EPuck
* @return blob information, in the form of a Blob object
* @see EPuck#Blob
* */
- Blob getBlob(int index);
+ EPuck::Blob getBlob(int index);
//==================== motor control methods ================================
@@ -209,8 +209,9 @@ class EPuckReal : public EPuck
* This list of tones is updated when {@link EPuck#listenForTones} is called. This function allows you to request a tone from this array.
* @param index the index of the tone you wish to get from the EPuck object
* @returns tone the tone.
+ * @see EPuck#Tone
* */
- Tone getTone(int index);
+ EPuck::Tone getTone(int index);
#if DEBUGGING == 1
void printLocation_TEST(void);
View
@@ -161,9 +161,9 @@ class EPuckSim : public EPuck
/**
* Returns data about a specific blob, referenced by an ID number
* @return blob information, in the form of a Blob object
- * @see Blob
+ * @see EPuck#Blob
* */
- Blob getBlob(int index);
+ EPuck::Blob getBlob(int index);
//==================== motor control methods ================================
@@ -254,6 +254,7 @@ class EPuckSim : public EPuck
* the resulting information is combined in a way that is physically plausible (because this is a simulation after all...)
* and stored in the EPuck object until requested by the user.
* @returns numberOfTones the number of different tones the robot can hear.
+ * @see #getTone
* */
int listenForTones(void);
@@ -262,8 +263,10 @@ class EPuckSim : public EPuck
* This list of tones is updated when {@link EPuck#listenForTones} is called. This function allows you to request a tone from this array.
* @param index the index of the tone you wish to get from the EPuck object
* @returns tone the tone.
+ * @see #listenForTones
+ * @see EPuck#Tone
* */
- Tone getTone(int index);
+ EPuck::Tone getTone(int index);
#if DEBUGGING == 1
void printLocation_TEST(void);
View
@@ -82,6 +82,11 @@ AudioHandler::~AudioHandler()
return;
}
+int AudioHandler::getFFTBlockSize(void)
+{
+ return fftBlockSize;
+}
+
/**
* Puts a tone of the desired frequency and duration into the audio environment.
* @param freq the frequency of the tone in Hz
View
@@ -168,10 +168,10 @@ int EPuckReal::getNumberBlobs(void)
* @return blob information, in the form of a Blob object
* @see EPuck.h#Blob Blob
* */
-Blob EPuckReal::getBlob(int index)
+EPuck::Blob EPuckReal::getBlob(int index)
{
player_blobfinder_blob_t oldBlob;
- Blob newBlob;
+ EPuck::Blob newBlob;
oldBlob = blobProxy->GetBlob(index);
newBlob.id = (int)oldBlob.id;
@@ -396,8 +396,9 @@ int EPuckReal::listenForTones(void)
}
-Tone EPuckReal::getTone(int index)
+EPuck::Tone EPuckReal::getTone(int index)
{
+ //TODO this is not yet coded
/* if(index < numberOfTones && index > -1)
{
return toneArray[index];
@@ -411,7 +412,7 @@ Tone EPuckReal::getTone(int index)
t.volume = 0;
return t;
}*/
- Tone t;
+ EPuck::Tone t;
return t;
}
/*
View
@@ -189,10 +189,10 @@ int EPuckSim::getNumberBlobs(void)
}
-Blob EPuckSim::getBlob(int index)
+EPuck::Blob EPuckSim::getBlob(int index)
{
player_blobfinder_blob_t oldBlob;
- Blob newBlob;
+ EPuck::Blob newBlob;
oldBlob = blobProxy->GetBlob(index);
newBlob.id = (int)oldBlob.id;
@@ -418,7 +418,7 @@ int EPuckSim::listenForTones(void)
}
-Tone EPuckSim::getTone(int index)
+EPuck::Tone EPuckSim::getTone(int index)
{
if(index < numberOfTones && index > -1)
{
@@ -427,7 +427,7 @@ Tone EPuckSim::getTone(int index)
else
{
printf("In EPuckSim::getTone, index %d does not exist.\n", index);
- Tone t;
+ EPuck::Tone t;
t.bearing = 0;
t.frequency = 0;
t.volume = 0;

0 comments on commit aa7463a

Please sign in to comment.