icub-client
Classes

Module to detect touch activations to robot's body parts Version:1.0 More...

+ Collaboration diagram for touchDetector:

Classes

class  TouchDetectorModule
 
class  TouchDetectorThread
 

Detailed Description

Module to detect touch activations to robot's body parts Version:1.0

Author
Bertrand Higy bertr.nosp@m.and..nosp@m.higy@.nosp@m.iit..nosp@m.it

Description

This module provides wrappers of procedures to count the number of activations to robot 's body parts through some yarp ports.

Parameters

Input Ports

Output Ports

Services


Class Documentation

◆ TouchDetectorModule

class TouchDetectorModule

Definition at line 31 of file touchDetectorModule.h.

+ Inheritance diagram for TouchDetectorModule:

Public Member Functions

bool configure (yarp::os::ResourceFinder &rf)
 
bool interruptModule ()
 
bool close ()
 
bool updateModule ()
 

Protected Member Functions

void initializeParameters (yarp::os::ResourceFinder &rf)
 
bool openPorts ()
 

Protected Attributes

int period
 
double threshold
 
int taxelThreshold
 
std::string moduleName
 
std::string torsoPortName
 name of torso port More...
 
std::string leftArmPortName
 name of left arm port More...
 
std::string rightArmPortName
 name of right arm port More...
 
std::string leftForearmPortName
 name of left forearm port More...
 
std::string rightForearmPortName
 name of right forearm port More...
 
std::string leftHandPortName
 name of left hand port More...
 
std::string rightHandPortName
 name of right hand port More...
 
std::string touchPortName
 name of touchport More...
 
std::string touchPortCleanName
 name of touchportClean More...
 
std::string clustersConfFilepath
 string for path to cluster configure file More...
 
yarp::os::BufferedPort< yarp::os::Bottle > torsoPort
 Yarp BufferedPort of bottle for input torso activations. More...
 
yarp::os::BufferedPort< yarp::os::Bottle > leftArmPort
 Yarp BufferedPort of bottle for input left arm activations. More...
 
yarp::os::BufferedPort< yarp::os::Bottle > rightArmPort
 Yarp BufferedPort of bottle for input right arm activations. More...
 
yarp::os::BufferedPort< yarp::os::Bottle > leftForearmPort
 Yarp BufferedPort of bottle for input left forearm activations. More...
 
yarp::os::BufferedPort< yarp::os::Bottle > rightForearmPort
 Yarp BufferedPort of bottle for input right forearm activations. More...
 
yarp::os::BufferedPort< yarp::os::Bottle > leftHandPort
 Yarp BufferedPort of bottle for input left hand activations. More...
 
yarp::os::BufferedPort< yarp::os::Bottle > rightHandPort
 Yarp BufferedPort of bottle for input right hand activations. More...
 
yarp::os::BufferedPort< yarp::os::Bottle > touchPort
 Yarp BufferedPort of bottle for output touched activations. More...
 
yarp::os::BufferedPort< yarp::os::Bottle > touchPortCleaned
 Yarp BufferedPort of bottle for output touched taxel. More...
 
TouchDetectorThreadthread
 

Member Function Documentation

◆ close()

bool TouchDetectorModule::close ( )

Definition at line 60 of file touchDetectorModule.cpp.

◆ configure()

bool TouchDetectorModule::configure ( yarp::os::ResourceFinder &  rf)

Definition at line 24 of file touchDetectorModule.cpp.

◆ initializeParameters()

void TouchDetectorModule::initializeParameters ( yarp::os::ResourceFinder &  rf)
protected

Definition at line 80 of file touchDetectorModule.cpp.

◆ interruptModule()

bool TouchDetectorModule::interruptModule ( )

Definition at line 46 of file touchDetectorModule.cpp.

◆ openPorts()

bool TouchDetectorModule::openPorts ( )
protected

Definition at line 111 of file touchDetectorModule.cpp.

◆ updateModule()

bool TouchDetectorModule::updateModule ( )

Definition at line 41 of file touchDetectorModule.cpp.

Member Data Documentation

◆ clustersConfFilepath

std::string TouchDetectorModule::clustersConfFilepath
protected

string for path to cluster configure file

Definition at line 55 of file touchDetectorModule.h.

◆ leftArmPort

yarp::os::BufferedPort<yarp::os::Bottle> TouchDetectorModule::leftArmPort
protected

Yarp BufferedPort of bottle for input left arm activations.

Definition at line 59 of file touchDetectorModule.h.

◆ leftArmPortName

std::string TouchDetectorModule::leftArmPortName
protected

name of left arm port

Definition at line 47 of file touchDetectorModule.h.

◆ leftForearmPort

yarp::os::BufferedPort<yarp::os::Bottle> TouchDetectorModule::leftForearmPort
protected

Yarp BufferedPort of bottle for input left forearm activations.

Definition at line 61 of file touchDetectorModule.h.

◆ leftForearmPortName

std::string TouchDetectorModule::leftForearmPortName
protected

name of left forearm port

Definition at line 49 of file touchDetectorModule.h.

◆ leftHandPort

yarp::os::BufferedPort<yarp::os::Bottle> TouchDetectorModule::leftHandPort
protected

Yarp BufferedPort of bottle for input left hand activations.

Definition at line 63 of file touchDetectorModule.h.

◆ leftHandPortName

std::string TouchDetectorModule::leftHandPortName
protected

name of left hand port

Definition at line 51 of file touchDetectorModule.h.

◆ moduleName

std::string TouchDetectorModule::moduleName
protected

Definition at line 45 of file touchDetectorModule.h.

◆ period

int TouchDetectorModule::period
protected

Definition at line 42 of file touchDetectorModule.h.

◆ rightArmPort

yarp::os::BufferedPort<yarp::os::Bottle> TouchDetectorModule::rightArmPort
protected

Yarp BufferedPort of bottle for input right arm activations.

Definition at line 60 of file touchDetectorModule.h.

◆ rightArmPortName

std::string TouchDetectorModule::rightArmPortName
protected

name of right arm port

Definition at line 48 of file touchDetectorModule.h.

◆ rightForearmPort

yarp::os::BufferedPort<yarp::os::Bottle> TouchDetectorModule::rightForearmPort
protected

Yarp BufferedPort of bottle for input right forearm activations.

Definition at line 62 of file touchDetectorModule.h.

◆ rightForearmPortName

std::string TouchDetectorModule::rightForearmPortName
protected

name of right forearm port

Definition at line 50 of file touchDetectorModule.h.

◆ rightHandPort

yarp::os::BufferedPort<yarp::os::Bottle> TouchDetectorModule::rightHandPort
protected

Yarp BufferedPort of bottle for input right hand activations.

Definition at line 64 of file touchDetectorModule.h.

◆ rightHandPortName

std::string TouchDetectorModule::rightHandPortName
protected

name of right hand port

Definition at line 52 of file touchDetectorModule.h.

◆ taxelThreshold

int TouchDetectorModule::taxelThreshold
protected

Definition at line 44 of file touchDetectorModule.h.

◆ thread

TouchDetectorThread* TouchDetectorModule::thread
protected

Definition at line 67 of file touchDetectorModule.h.

◆ threshold

double TouchDetectorModule::threshold
protected

Definition at line 43 of file touchDetectorModule.h.

◆ torsoPort

yarp::os::BufferedPort<yarp::os::Bottle> TouchDetectorModule::torsoPort
protected

Yarp BufferedPort of bottle for input torso activations.

Definition at line 58 of file touchDetectorModule.h.

◆ torsoPortName

std::string TouchDetectorModule::torsoPortName
protected

name of torso port

Definition at line 46 of file touchDetectorModule.h.

◆ touchPort

yarp::os::BufferedPort<yarp::os::Bottle> TouchDetectorModule::touchPort
protected

Yarp BufferedPort of bottle for output touched activations.

Definition at line 65 of file touchDetectorModule.h.

◆ touchPortCleaned

yarp::os::BufferedPort<yarp::os::Bottle> TouchDetectorModule::touchPortCleaned
protected

Yarp BufferedPort of bottle for output touched taxel.

Definition at line 66 of file touchDetectorModule.h.

◆ touchPortCleanName

std::string TouchDetectorModule::touchPortCleanName
protected

name of touchportClean

Definition at line 54 of file touchDetectorModule.h.

◆ touchPortName

std::string TouchDetectorModule::touchPortName
protected

name of touchport

Definition at line 53 of file touchDetectorModule.h.

◆ TouchDetectorThread

class TouchDetectorThread

Definition at line 32 of file touchDetectorThread.h.

+ Inheritance diagram for TouchDetectorThread:

Public Member Functions

 TouchDetectorThread (yarp::os::BufferedPort< yarp::os::Bottle > *torsoPort, yarp::os::BufferedPort< yarp::os::Bottle > *leftArmPort, yarp::os::BufferedPort< yarp::os::Bottle > *rightArmPort, yarp::os::BufferedPort< yarp::os::Bottle > *leftForearmPort, yarp::os::BufferedPort< yarp::os::Bottle > *rightForearmPort, yarp::os::BufferedPort< yarp::os::Bottle > *leftHandPort, yarp::os::BufferedPort< yarp::os::Bottle > *rightHandPort, yarp::os::BufferedPort< yarp::os::Bottle > *touchPort, yarp::os::BufferedPort< yarp::os::Bottle > *touchPortCleaned, int period, std::string clustersConfFilepath, double threshold, int taxelThreshold)
 
void run ()
 
bool threadInit ()
 

Protected Member Functions

bool readTaxelsMapping (std::string filename)
 readTaxelsMapping Read taxels map from configure file, which relates to nbBodyParts and bodyParts More...
 
int getBodyPartId (std::string bodyPartName)
 getBodyPartId Obtain the ID of body parts, which are "torso", "left_arm", "right_arm", "left_forearm", "right_forearm", "left_hand", "right_hand" More...
 
void updateMapping (int bodyPart, int firstTaxel, int lastTaxel, int cluster)
 updateMapping Change all taxels of a body part to clusterID More...
 
void countActivations (int bodyPart, yarp::os::Bottle *data, std::vector< int > &activations)
 countActivations Counts number of activations to a body part through a buffered port of that part More...
 
void processPort (int portNum, yarp::os::BufferedPort< yarp::os::Bottle > *port, std::vector< int > &activations)
 processPort Process port of body part to receive activations to that body part More...
 

Protected Attributes

int nbClusters
 
double threshold
 
int taxelThreshold
 integer value of touched threshold More...
 
std::string clustersConfFilepath
 string value of the path to configure file of clusters More...
 
std::vector< int > taxels2Clusters [7]
 standard vector of integer containing the taxel IDs in form of cluster ID More...
 
yarp::os::BufferedPort< yarp::os::Bottle > * torsoPort
 Yarp BufferedPort of bottle for input torso activations. More...
 
yarp::os::BufferedPort< yarp::os::Bottle > * leftArmPort
 Yarp BufferedPort of bottle for input left arm activations. More...
 
yarp::os::BufferedPort< yarp::os::Bottle > * rightArmPort
 Yarp BufferedPort of bottle for input right arm activations. More...
 
yarp::os::BufferedPort< yarp::os::Bottle > * leftForearmPort
 Yarp BufferedPort of bottle for input left forearm activations. More...
 
yarp::os::BufferedPort< yarp::os::Bottle > * rightForearmPort
 Yarp BufferedPort of bottle for input right forearm activations. More...
 
yarp::os::BufferedPort< yarp::os::Bottle > * leftHandPort
 Yarp BufferedPort of bottle for input left hand activations. More...
 
yarp::os::BufferedPort< yarp::os::Bottle > * rightHandPort
 Yarp BufferedPort of bottle for input right hand activations. More...
 
yarp::os::BufferedPort< yarp::os::Bottle > * touchPort
 Yarp BufferedPort of bottle for output touched activations. More...
 
yarp::os::BufferedPort< yarp::os::Bottle > * touchPortCleaned
 Yarp BufferedPort of bottle for output touched taxel. More...
 

Static Protected Attributes

static const int noCluster = -1
 
static const int nbBodyParts = 7
 
static const char * bodyParts [7] = {"torso", "left_arm", "right_arm", "left_forearm", "right_forearm", "left_hand", "right_hand"}
 
static const int nbTaxels [7] = {4 * 192, 4 * 192, 4 * 192, 2 * 192, 2 * 192, 192, 192}
 

Constructor & Destructor Documentation

◆ TouchDetectorThread()

TouchDetectorThread::TouchDetectorThread ( yarp::os::BufferedPort< yarp::os::Bottle > *  torsoPort,
yarp::os::BufferedPort< yarp::os::Bottle > *  leftArmPort,
yarp::os::BufferedPort< yarp::os::Bottle > *  rightArmPort,
yarp::os::BufferedPort< yarp::os::Bottle > *  leftForearmPort,
yarp::os::BufferedPort< yarp::os::Bottle > *  rightForearmPort,
yarp::os::BufferedPort< yarp::os::Bottle > *  leftHandPort,
yarp::os::BufferedPort< yarp::os::Bottle > *  rightHandPort,
yarp::os::BufferedPort< yarp::os::Bottle > *  touchPort,
yarp::os::BufferedPort< yarp::os::Bottle > *  touchPortCleaned,
int  period,
std::string  clustersConfFilepath,
double  threshold,
int  taxelThreshold 
)

Definition at line 37 of file touchDetectorThread.cpp.

Member Function Documentation

◆ countActivations()

void TouchDetectorThread::countActivations ( int  bodyPart,
yarp::os::Bottle *  data,
std::vector< int > &  activations 
)
protected

countActivations Counts number of activations to a body part through a buffered port of that part

Parameters
bodyPartAn integer value of body part ID to count
dataYARP bottle contains data from the port of the body part
activationsAn integer value for number of activations

Definition at line 186 of file touchDetectorThread.cpp.

◆ getBodyPartId()

int TouchDetectorThread::getBodyPartId ( std::string  bodyPartName)
protected

getBodyPartId Obtain the ID of body parts, which are "torso", "left_arm", "right_arm", "left_forearm", "right_forearm", "left_hand", "right_hand"

Parameters
bodyPartNameString value of the name of body part to get ID
Returns
Integer value of ID

Definition at line 100 of file touchDetectorThread.cpp.

◆ processPort()

void TouchDetectorThread::processPort ( int  portNum,
yarp::os::BufferedPort< yarp::os::Bottle > *  port,
std::vector< int > &  activations 
)
protected

processPort Process port of body part to receive activations to that body part

Parameters
portNumAn integer value of body part ID to count
activationsA vector of integer values for number of activations
portThe port from which to process data from
See also
countActivations();

Definition at line 173 of file touchDetectorThread.cpp.

◆ readTaxelsMapping()

bool TouchDetectorThread::readTaxelsMapping ( std::string  filename)
protected

readTaxelsMapping Read taxels map from configure file, which relates to nbBodyParts and bodyParts

Parameters
filenameName of configure file of taxels
Returns
True for all case

Definition at line 65 of file touchDetectorThread.cpp.

◆ run()

void TouchDetectorThread::run ( )

Definition at line 127 of file touchDetectorThread.cpp.

◆ threadInit()

bool TouchDetectorThread::threadInit ( )

Definition at line 50 of file touchDetectorThread.cpp.

◆ updateMapping()

void TouchDetectorThread::updateMapping ( int  bodyPart,
int  firstTaxel,
int  lastTaxel,
int  cluster 
)
protected

updateMapping Change all taxels of a body part to clusterID

Parameters
bodyPartAn integer value of body part ID
firstTaxelAn integer value of the 1st taxel of the body part
lastTaxelAn integer value of the last taxel of the body part
clusterAn integer value of the cluster ID
See also
taxels2Clusters

Definition at line 119 of file touchDetectorThread.cpp.

Member Data Documentation

◆ bodyParts

const char * TouchDetectorThread::bodyParts = {"torso", "left_arm", "right_arm", "left_forearm", "right_forearm", "left_hand", "right_hand"}
staticprotected

Definition at line 42 of file touchDetectorThread.h.

◆ clustersConfFilepath

std::string TouchDetectorThread::clustersConfFilepath
protected

string value of the path to configure file of clusters

Definition at line 48 of file touchDetectorThread.h.

◆ leftArmPort

yarp::os::BufferedPort<yarp::os::Bottle>* TouchDetectorThread::leftArmPort
protected

Yarp BufferedPort of bottle for input left arm activations.

Definition at line 53 of file touchDetectorThread.h.

◆ leftForearmPort

yarp::os::BufferedPort<yarp::os::Bottle>* TouchDetectorThread::leftForearmPort
protected

Yarp BufferedPort of bottle for input left forearm activations.

Definition at line 55 of file touchDetectorThread.h.

◆ leftHandPort

yarp::os::BufferedPort<yarp::os::Bottle>* TouchDetectorThread::leftHandPort
protected

Yarp BufferedPort of bottle for input left hand activations.

Definition at line 57 of file touchDetectorThread.h.

◆ nbBodyParts

const int TouchDetectorThread::nbBodyParts = 7
staticprotected

Definition at line 41 of file touchDetectorThread.h.

◆ nbClusters

int TouchDetectorThread::nbClusters
protected

Definition at line 45 of file touchDetectorThread.h.

◆ nbTaxels

const int TouchDetectorThread::nbTaxels = {4 * 192, 4 * 192, 4 * 192, 2 * 192, 2 * 192, 192, 192}
staticprotected

Definition at line 43 of file touchDetectorThread.h.

◆ noCluster

const int TouchDetectorThread::noCluster = -1
staticprotected

Definition at line 40 of file touchDetectorThread.h.

◆ rightArmPort

yarp::os::BufferedPort<yarp::os::Bottle>* TouchDetectorThread::rightArmPort
protected

Yarp BufferedPort of bottle for input right arm activations.

Definition at line 54 of file touchDetectorThread.h.

◆ rightForearmPort

yarp::os::BufferedPort<yarp::os::Bottle>* TouchDetectorThread::rightForearmPort
protected

Yarp BufferedPort of bottle for input right forearm activations.

Definition at line 56 of file touchDetectorThread.h.

◆ rightHandPort

yarp::os::BufferedPort<yarp::os::Bottle>* TouchDetectorThread::rightHandPort
protected

Yarp BufferedPort of bottle for input right hand activations.

Definition at line 58 of file touchDetectorThread.h.

◆ taxels2Clusters

std::vector<int> TouchDetectorThread::taxels2Clusters[7]
protected

standard vector of integer containing the taxel IDs in form of cluster ID

Definition at line 49 of file touchDetectorThread.h.

◆ taxelThreshold

int TouchDetectorThread::taxelThreshold
protected

integer value of touched threshold

Definition at line 47 of file touchDetectorThread.h.

◆ threshold

double TouchDetectorThread::threshold
protected

Definition at line 46 of file touchDetectorThread.h.

◆ torsoPort

yarp::os::BufferedPort<yarp::os::Bottle>* TouchDetectorThread::torsoPort
protected

Yarp BufferedPort of bottle for input torso activations.

Definition at line 52 of file touchDetectorThread.h.

◆ touchPort

yarp::os::BufferedPort<yarp::os::Bottle>* TouchDetectorThread::touchPort
protected

Yarp BufferedPort of bottle for output touched activations.

Definition at line 59 of file touchDetectorThread.h.

◆ touchPortCleaned

yarp::os::BufferedPort<yarp::os::Bottle>* TouchDetectorThread::touchPortCleaned
protected

Yarp BufferedPort of bottle for output touched taxel.

Definition at line 60 of file touchDetectorThread.h.