Acoustic Touch Recognition
|
Front-end to create instance objects step by step. More...
#include <libacoustic_touch.h>
Public Member Functions | |
InstanceBuilder (string mode) | |
Constructs the object. First sets up the ROS elements. More... | |
~InstanceBuilder () | |
Destroys the object. Now, since we're working with elements that auto-destroy properly its function is merely conventional. More... | |
void | startGestureCallback (const std_msgs::Int8::ConstPtr &msg) |
Starts a gesture callback. More... | |
void | endGestureCallback (const touch_gesture_msgs::SoundGesture::ConstPtr &msg) |
This callbacks first extract the info from the message, then modifies the appropriate sound gesture inside the class and finally triggers the timer that establish the end of the gesture. More... | |
bool | optionsCallback (acoustic_touch_recognition::MenuOptions::Request &req, acoustic_touch_recognition::MenuOptions::Response &res) |
This is the training service callback. In the request it can receive changes in the three one of the class attributes or a shutdown request, commanding this object to close the file and shutdown this node. More... | |
void | timerCallback (const ros::TimerEvent &) |
The timer callback ends when it is considered that the gesture is over. It is refreshed for each microphone that sends a gesture and once is finished, writes all the gestures in the file and cleans the container with the sound gestures. More... | |
void | shutdownCallback (const ros::TimerEvent &) |
This callback allows the system to shutdown properly. Once the timer is set, the node sends back the signal to the client that sent in the first place the shutdown signal. More... | |
void | setSoundGestures (vector< SoundGesture > s_gests) |
Sets the sound gestures at once. Might be unused but useful. More... | |
void | setSoundGestures (SoundGesture s_gest, int index) |
Sets the sound gestures individually. More... | |
void | clearSoundGestures () |
This function clear every sound gesture in the vector (sets zeros to its attributes) and set the empty flag to true. More... | |
void | clearSoundGestures (int index) |
Atomic function that erases all the attributes (substitutes them with zeros) from the selected sound gesture and set the empty flag to true. More... | |
void | setClassAttributes (string index, string c_att) |
Sets the class attributes. Checks if the key is already in the container. More... | |
void | setFile (string path) |
This function assigns the file path and opens the file. If the file was not created, the system will create the arff file from scratch. More... | |
void | closeFile () |
Closes the file. Used when receiving shutdown signal. More... | |
vector< SoundGesture > | getSoundGestures () const |
Gets the sound gestures. More... | |
SoundGesture | getSoundGestures (int index) const |
Gets the sound gestures. Atomic function. More... | |
void | init () |
Initializes the object by extracting the parameters from the parameter server, then the sound gesture-related and finally sets up the file that will be created or overwritten. More... | |
bool | fileExists (string path) |
This function checks if a file with a certain name exists. More... | |
void | createArffFile () |
Creates an arff file. The format associated is the Multi-target Meka format. More... | |
void | writeGestures () |
Writes a gesture in the file of the class. When it is done clear the containers, setting the empty flags to true. More... | |
Private Attributes | |
ros::NodeHandle | nh_ |
ros::Publisher | gesture_pub_ |
ros::Subscriber | gest_start_sub_ |
bool | flag_start_sub_ |
ros::Subscriber | gest_end_sub_ |
ros::ServiceServer | settings_srv_ |
ros::Timer | timer_ |
ros::Timer | shutdown_timer_ |
string | robot_ |
const string | mode_ |
int | mic_amount_ |
vector< SoundGesture > | sound_gestures_ |
XmlRpc::XmlRpcValue | class_labels_ |
XmlRpc::XmlRpcValue | train_labels_ |
vector< string > | label_names_ |
string | path_ |
fstream | sound_file_ |
Front-end to create instance objects step by step.
InstanceBuilder::InstanceBuilder | ( | string | mode | ) |
Constructs the object. First sets up the ROS elements.
[in] | mode | The mode. Can be "train" or "classify" |
InstanceBuilder::~InstanceBuilder | ( | ) |
Destroys the object. Now, since we're working with elements that auto-destroy properly its function is merely conventional.
void InstanceBuilder::clearSoundGestures | ( | ) |
This function clear every sound gesture in the vector (sets zeros to its attributes) and set the empty flag to true.
void InstanceBuilder::clearSoundGestures | ( | int | index | ) |
Atomic function that erases all the attributes (substitutes them with zeros) from the selected sound gesture and set the empty flag to true.
[in] | index | The index of the element |
void InstanceBuilder::closeFile | ( | ) |
Closes the file. Used when receiving shutdown signal.
void InstanceBuilder::createArffFile | ( | ) |
Creates an arff file. The format associated is the Multi-target Meka format.
void InstanceBuilder::endGestureCallback | ( | const touch_gesture_msgs::SoundGesture::ConstPtr & | msg | ) |
This callbacks first extract the info from the message, then modifies the appropriate sound gesture inside the class and finally triggers the timer that establish the end of the gesture.
[in] | msg | The message containing one sound gesture from one microphone |
bool InstanceBuilder::fileExists | ( | string | path | ) |
This function checks if a file with a certain name exists.
[in] | path | The path of the file with te name included |
vector< SoundGesture > InstanceBuilder::getSoundGestures | ( | ) | const |
Gets the sound gestures.
SoundGesture InstanceBuilder::getSoundGestures | ( | int | index | ) | const |
Gets the sound gestures. Atomic function.
[in] | index | The index |
void InstanceBuilder::init | ( | ) |
Initializes the object by extracting the parameters from the parameter server, then the sound gesture-related and finally sets up the file that will be created or overwritten.
bool InstanceBuilder::optionsCallback | ( | acoustic_touch_recognition::MenuOptions::Request & | req, |
acoustic_touch_recognition::MenuOptions::Response & | res | ||
) |
This is the training service callback. In the request it can receive changes in the three one of the class attributes or a shutdown request, commanding this object to close the file and shutdown this node.
req | The request containing the class attributes or the shutdown command |
res | The response is just an integer |
void InstanceBuilder::setClassAttributes | ( | string | index, |
string | c_att | ||
) |
Sets the class attributes. Checks if the key is already in the container.
[in] | c_att | The class attribute value |
[in] | index | The index, since is train_labels_ element is a map, the index is a string |
void InstanceBuilder::setFile | ( | string | path | ) |
This function assigns the file path and opens the file. If the file was not created, the system will create the arff file from scratch.
[in] | path | The path |
void InstanceBuilder::setSoundGestures | ( | vector< SoundGesture > | s_gests | ) |
Sets the sound gestures at once. Might be unused but useful.
[in] | s_gests | The sound gestures |
void InstanceBuilder::setSoundGestures | ( | SoundGesture | s_gest, |
int | index | ||
) |
Sets the sound gestures individually.
[in] | s_gest | The sound gesture which will be copied. |
[in] | index | The index. Check if it is out of bounds. |
void InstanceBuilder::shutdownCallback | ( | const ros::TimerEvent & | ) |
This callback allows the system to shutdown properly. Once the timer is set, the node sends back the signal to the client that sent in the first place the shutdown signal.
[in] | ros::TimerEvent | Contains info about the event (times, durations, etc.) |
void InstanceBuilder::startGestureCallback | ( | const std_msgs::Int8::ConstPtr & | msg | ) |
Starts a gesture callback.
[in] | msg | The message |
void InstanceBuilder::timerCallback | ( | const ros::TimerEvent & | ) |
The timer callback ends when it is considered that the gesture is over. It is refreshed for each microphone that sends a gesture and once is finished, writes all the gestures in the file and cleans the container with the sound gestures.
[in] | ros::TimerEvent | When the time is over the timer pops a timer event, starting the callbacks associated with this events. |
void InstanceBuilder::writeGestures | ( | ) |
Writes a gesture in the file of the class. When it is done clear the containers, setting the empty flags to true.
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |