Public Member Functions | Protected Member Functions | Protected Attributes

CB::ConfigurationVariables Class Reference

This class instantiates the abstract ControlBasisResource class for a ConfigurationVariable type resource. More...

#include <ConfigurationVariables.h>

Inheritance diagram for CB::ConfigurationVariables:
CB::ControlBasisResource CB::iCubConfigurationReference CB::YARPConfigurationVariables CB::iCubEyeConfigurationVariables

Public Member Functions

int getNumDOF ()
 gets the number of DOFs of the device.
int getNumLinks ()
 gets the number of links of the device.
double getVal (int n)
 Gets the value of a particular DOF.
double getMinLimit (int n)
 gets the min joint limit for a specified DOF.
double getMaxLimit (int n)
 gets the max joint limit for a specified DOF.
bool isMoveable ()
 flag specifying if the resource accepts input commands that move the device.
 ConfigurationVariables ()
 constructor.
 ~ConfigurationVariables ()
 Destructor.
virtual void postData ()
 This is the function that posts the resource data to the output port.
virtual void getInputData ()
 This is the function that posts the input data to the hardware It is automatically called after the update() function in the main thread loop.
void setDesiredIncrement (const yarp::sig::Vector &Vinc)
 this function addes the input increment to the current joint position to get the desired position.
void setLock (bool b)
 sets the value of the lock
std::string getResourceName ()
 Getter for the resource name.
std::string getDeviceName ()
 Getter for the device name.
bool isResourceRunning ()
 is the resource running?
std::string getResourceType ()
 Getter for the resource type.
yarp::sig::Vector getResourceData ()
 Getter for the resource data.
int getResourceDataSize ()
 Getter for the resource data size.
void setUpdateDelay (double t)
 Setter for updated delay.
virtual bool updateResource ()=0
 virtual update function
virtual void startResource ()=0
 virtual start function
virtual void stopResource ()=0
 virtual stop function
void initPorts ()
 Initiallization function for starting ports.
void run ()
 main run function for resource (instatiates for thread)
void onStop ()
 onStop function

Protected Member Functions

void setNumDOF (int n)
 Setter for the number of DOFs.
void setNumLinks (int l)
 Setter for the number of Linkls.
yarp::sig::Vector trimInputData (const yarp::sig::Vector &Vdes)
 function to make sure input date is of safe values

Protected Attributes

int numDOFs
 The number of DOFs of the robot.
int numLinks
 The number of links of the robot.
bool moveable
 whether this set of variables can accept inputs
yarp::sig::Vector desiredValues
 The desired values if the variables are writeable.
double maxSetVal
 The max increment.
yarp::sig::Vector minLimits
 The min range limits of the variables.
yarp::sig::Vector maxLimits
 The max range limits of the variables.
yarp::sig::Matrix DHParameters
 The DH Parameters for this robot.
yarp::sig::Vector LinkTypes
 The link type for each link (prismatic, revolute, constant, non-interfering).
std::string deviceName
 the name of the device
std::string resourceName
 the name of the resource
bool running
 running flag
std::string type
 The formal type of the resource (e.g., CartesianPosition, ConfigurationVariable, etc.
yarp::sig::Vector values
 The resource data vals.
int size
 the size of the data values
std::vector
< yarp::os::BufferedPort
< yarp::os::Bottle > * > 
outputPort
 The Yarp output ports.
std::vector
< yarp::os::BufferedPort
< yarp::os::Bottle > * > 
inputPort
 The Yarp input Ports.
int numOutputs
 num output ports
int numInputs
 num input ports
std::vector< std::string > outputPortName
 The Yarp output port names.
std::vector< std::string > inputPortName
 The YARP input port name.
std::vector< std::string > outputName
 The output names.
std::vector< std::string > inputName
 The input names.
bool lock
 Lock flag to prevent writing vals to hardware.
double updateDelay
 update delay (in seconds)

Detailed Description

This class instantiates the abstract ControlBasisResource class for a ConfigurationVariable type resource.

This type of resource can be used to read and write joint values to a robot manipulator of the position of a mobile robot. It is still abstract, in that it doesn't implement a runnable resource. This class must be extended for a specific device that implements the start, update, and stop functions.

Definition at line 18 of file ConfigurationVariables.h.


Constructor & Destructor Documentation

CB::ConfigurationVariables::ConfigurationVariables (  )  [inline]

constructor.

sets type and port names.

Definition at line 152 of file ConfigurationVariables.h.

References CB::ControlBasisResource::inputName, CB::ControlBasisResource::outputName, CB::ControlBasisResource::running, and CB::ControlBasisResource::type.

                                 :
            ControlBasisResource("configuration", 2, 3) 
        {        
            std::cout << "setting type of ConfigurationVariables to " << type.c_str() << std::endl;

            running=false;

            inputName.push_back("data");
            inputName.push_back("lock");        

            outputName.push_back("data");
            outputName.push_back("limits");
            outputName.push_back("params");

        }    


Member Function Documentation

std::string CB::ControlBasisResource::getDeviceName (  )  [inline, inherited]

Getter for the device name.

Returns:
the name

Definition at line 119 of file ControlBasisResource.h.

References CB::ControlBasisResource::deviceName.

{ return deviceName; }  

std::string CB::ControlBasisResource::getResourceName (  )  [inline, inherited]

Getter for the resource name.

Returns:
the name

Definition at line 113 of file ControlBasisResource.h.

References CB::ControlBasisResource::resourceName.

Referenced by CB::Controller::Controller().

{ return resourceName; }  

std::string CB::ControlBasisResource::getResourceType (  )  [inline, inherited]

Getter for the resource type.

Returns:
the type

Definition at line 131 of file ControlBasisResource.h.

References CB::ControlBasisResource::type.

Referenced by CB::Controller::Controller().

{ return type; }

bool CB::ControlBasisResource::isResourceRunning (  )  [inline, inherited]

is the resource running?

Returns:
running

Definition at line 125 of file ControlBasisResource.h.

References CB::ControlBasisResource::running.

Referenced by CB::Controller::startAction().

{ return running; }

virtual void CB::ConfigurationVariables::postData (  )  [inline, virtual]

This is the function that posts the resource data to the output port.

it is type specific, so it is defined here. it is automatically called after the update() function in the main thread loop.

Implements CB::ControlBasisResource.

Reimplemented in CB::iCubEyeConfigurationVariables.

Definition at line 178 of file ConfigurationVariables.h.

References DHParameters, LinkTypes, maxLimits, minLimits, numDOFs, numLinks, CB::ControlBasisResource::outputPort, and CB::ControlBasisResource::values.

                                {
            
            // prepare the output bottles to post information           
            yarp::os::Bottle &b0 = outputPort[0]->prepare();
            yarp::os::Bottle &b1 = outputPort[1]->prepare();
            yarp::os::Bottle &b2 = outputPort[2]->prepare();
 
            b0.clear();
            b1.clear();
            b2.clear();

            b0.addInt(numDOFs);
            b1.addInt(numDOFs);
            
            for(int i = 0; i < numDOFs; i++) {
                
                // add position to output port
                b0.addDouble(values[i]);
                
                // add limit information to output port
                b1.addDouble(minLimits[i]);
                b1.addDouble(maxLimits[i]);
                    
            }
            
            // write the information to the ports
            outputPort[0]->write();      
            outputPort[1]->write();      
            
            b2.addInt(numLinks);
            for(int i=0; i < numLinks; i++) {
                for(int j = 0; j < 4; j++) {
                    b2.addDouble(DHParameters[j][i]);
                }
                b2.addInt(LinkTypes[i]);
            }
            outputPort[2]->write();
            
        }

void CB::ConfigurationVariables::setDesiredIncrement ( const yarp::sig::Vector &  Vinc  )  [inline]

this function addes the input increment to the current joint position to get the desired position.

Parameters:
Vinc the desired increment to be added

Definition at line 268 of file ConfigurationVariables.h.

References desiredValues, numDOFs, and CB::ControlBasisResource::values.

Referenced by CB::iCubEyeConfigurationVariables::getInputData(), and getInputData().

                                                            {
            if(Vinc.size() != numDOFs) {
                std::cout << "ConfigurationVariables::setDesiredIncrement() -- MISMATCH -- size=" << Vinc.size() << std::endl;
                return;
            }
            for(int i=0; i<Vinc.size(); i++) {
                desiredValues[i] = values[i]+Vinc[i];
            }
        }

void CB::ConfigurationVariables::setNumDOF ( int  n  )  [inline, protected]

Setter for the number of DOFs.

Parameters:
the number of DOFs

Definition at line 71 of file ConfigurationVariables.h.

References numDOFs.

{ numDOFs = n; }

void CB::ConfigurationVariables::setNumLinks ( int  l  )  [inline, protected]

Setter for the number of Linkls.

Parameters:
the number of Links

Definition at line 77 of file ConfigurationVariables.h.

References numLinks.

{ numLinks = l; }

void CB::ControlBasisResource::setUpdateDelay ( double  t  )  [inline, inherited]

Setter for updated delay.

Parameters:
delay (in seconds)

Definition at line 147 of file ControlBasisResource.h.

References CB::ControlBasisResource::updateDelay.

{ updateDelay = t; }


Field Documentation


The documentation for this class was generated from the following file:
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Friends Defines