This API is depreceted. Please use the rec::robotino::com API instead.
The application programming interface (API) for Robotino(r) from Festo Didactic permits full access to Robotino's sensors and actors. Communication between the control program and Robotino is handled via TCP and UDP and is therefor fully network transparent. It does not matter whether the control program runs direcly on Robotino or on a remote system.
The API is available in binary form for Windows and Linux and source code via svn.
To build your own program you need to
If you are familiry with cmake you might prefer using install/tools/FindOpenRobotino1.cmake.
include "robotinocom/robotinocom.h"
include "xutils.h"
include <iostream>
void errorCb( void* data, int error )
{
std::cout << std::endl << "Error " << RobotinoCom::errorString( error ) << std::endl;
}
void connectedCb( void* data )
{
std::cout << std::endl << "Connected" << std::endl;
}
void connectionClosedCb( void* data )
{
std::cout << std::endl << "Connection closed." << std::endl;
}
int main(int argc, char **argv)
{
std::string hostname = "172.26.1.1";
if( argc > 1 )
{
hostname = argv[1];
}
RobotinoCom com; unsigned int startTime;
if( false == com.init() )
{
return 1;
}
com.setErrorCallback( &errorCb, NULL ); com.setConnectedCallback( &connectedCb, NULL ); com.setConnectionClosedCallback( &connectionClosedCb, NULL );
std::cout << "Connecting to host " << hostname; com.connectToHost( hostname );
while( com.state() == ConnectingState )
{
std::cout << ".";
msleep( 200 );
}
std::cout << std::endl;
if( com.error() != NoError )
{
goto CLEANUP;
}
startTime = com.msecsElapsed();
com.stopAsyncCommunication();
while( false == com.bumper() )
{
unsigned int msecsElapsed = com.msecsElapsed() - startTime;
if( msecsElapsed < 10000 )
{
//drive forward with 100mm/s
com.setVelocity( 100, //vx=100 mm/s
0, //vy=0 mm/s
0 //omega=0 deg/s
);
}
else
{
break;
}
//sending the set values to Robotino and receiving the sensor readings
if( com.update() == false )
{
break;
}
}
CLEANUP: com.close();
return 0; }
1.5.5