Public Member Functions | Protected Attributes

CB::EndEffectorCartesianPosition Class Reference

Implements the CartesianPosition abstract interface to retun the EndEffector position of a serial Kinematic chain. More...

#include <EndEffectorCartesianPosition.h>

Inheritance diagram for CB::EndEffectorCartesianPosition:
CB::CartesianPosition CB::ControlBasisResource

Public Member Functions

 EndEffectorCartesianPosition (std::string name)
 Constructor.
 ~EndEffectorCartesianPosition ()
 Destructor.
bool updateResource ()
 Inherited update function.
void startResource ()
 Inherited start function.
void stopResource ()
 Inherited stop function.
bool connectToConfiguration ()
 A functon that connects the EndEffector resource to the CB configuration device resource device it represents.
double getX ()
 returns the X coordinate of the position
double getY ()
 returns the Y coordinate of the position
double getZ ()
 returns the Z coordinate of the position
void postData ()
 This is the function that posts the resource data to the output port.
virtual void getInputData ()
 getInputData() function.
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.
void setLock (bool l)
 Setter for locking/unlocking the ability to set output variables.
void initPorts ()
 Initiallization function for starting ports.
void run ()
 main run function for resource (instatiates for thread)
void onStop ()
 onStop function

Protected Attributes

bool connectedToConfiguration
 flag for whether the resource is connected to a configuration resource.
iKin::iKinLimb kinLimb
 the iKinLimb to store kinematic data.
iKin::iKinChainkinChain
 the pointer to the iKinChain storing kinematic data.
yarp::sig::Vector configVals
yarp::sig::Matrix DHParams
 storage for DH parameters
yarp::sig::Vector LinkTypes
 storage for link type information
bool paramsSet
 indicator flag concerning whether DH parameter info has been set
std::deque< iKin::iKinLink * > linkList
 linked list to the kinematic links
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

Implements the CartesianPosition abstract interface to retun the EndEffector position of a serial Kinematic chain.

This is determined using the iCub iKin library.

Definition at line 18 of file EndEffectorCartesianPosition.h.


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; }

void CB::CartesianPosition::postData (  )  [inline, virtual, inherited]

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.

Definition at line 56 of file CartesianPosition.h.

References CB::CartesianPosition::getX(), CB::CartesianPosition::getY(), CB::CartesianPosition::getZ(), CB::ControlBasisResource::outputPort, and CB::ControlBasisResource::resourceName.

                        {
            yarp::os::Bottle &b = outputPort[0]->prepare();
            b.clear();
            b.addString(resourceName.c_str());
            b.addDouble(getX());
            b.addDouble(getY());
            b.addDouble(getZ());      
            outputPort[0]->write();
        }

void CB::ControlBasisResource::setLock ( bool  l  )  [inline, inherited]

Setter for locking/unlocking the ability to set output variables.

Parameters:
lock 

Reimplemented in CB::ConfigurationVariables.

Definition at line 154 of file ControlBasisResource.h.

References CB::ControlBasisResource::lock.

{ lock = 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; }

bool CB::EndEffectorCartesianPosition::updateResource (  )  [virtual]

Inherited update function.

Returns:
success on update

Implements CB::ControlBasisResource.

Definition at line 26 of file EndEffectorCartesianPosition.cpp.

References iKin::iKinChain::EndEffPose(), CB::ControlBasisResource::inputPort, kinChain, iKin::iKinChain::setAng(), and CB::ControlBasisResource::values.

                                                    {
  
    Bottle *b;
    int nj;
    int offset;
    bool ok = true;
    Vector xf, q0;
    int idx = 0;

    // read the current configuration variables from the input port
    b = inputPort[0]->read(false);
    if(b!=NULL) {

        nj = b->get(0).asInt();
        offset = 1;

        configVals.resize(nj);
        //cout << endl;
        for(int i=0; i<nj; i++) {            
            configVals[i] = b->get(i+offset).asDouble();
            //cout << "config[" << i << "]: " << configVals[i] << endl;
        }

        // set the angles and get the axis-angle end-effector pose using iKin
        configVals=kinChain->setAng(configVals);
        xf=kinChain->EndEffPose(false);     

        // copy position
        values[0] = xf[0];
        values[1] = xf[1];
        values[2] = xf[2];

        //cout << "Pos=[" << values[0] << " " << values[1] << " " << values[2] << "]" << endl;
    } 

    return ok;
    
}


Field Documentation


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