Example of a real robot control, the biclops robot (pan-tilt turret) by Traclabs. The robot is controlled first in position, then in velocity.
#include <visp3/io/vpParseArgv.h>
#include <visp3/core/vpConfig.h>
#include <visp3/core/vpDebug.h>
#include <visp3/core/vpColVector.h>
#include <visp3/core/vpTime.h>
#include <stdlib.h>
#ifdef VISP_HAVE_BICLOPS
#include <visp3/robot/vpRobotBiclops.h>
#define GETOPTARGS "c:h"
void usage(const char *name, const char *badparam, std::string conf)
{
fprintf(stdout, "\n\
Move the biclops robot\n\
\n\
SYNOPSIS\n\
%s [-c <Biclops configuration file>] [-h]\n \
", name);
fprintf(stdout, "\n\
OPTIONS: Default\n\
-c <Biclops configuration file> %s\n\
Sets the biclops robot configuration file.\n\n",
conf.c_str());
if (badparam) {
fprintf(stderr, "ERROR: \n" );
fprintf(stderr, "\nBad parameter [%s]\n", badparam);
}
}
bool getOptions(int argc, const char **argv, std::string& conf)
{
const char *optarg_;
int c;
switch (c) {
case 'c': conf = optarg_; break;
case 'h': usage(argv[0], NULL, conf); return false; break;
default:
usage(argv[0], optarg_, conf); return false; break;
}
}
if ((c == 1) || (c == -1)) {
usage(argv[0], NULL, conf);
std::cerr << "ERROR: " << std::endl;
std::cerr << " Bad argument " << optarg_ << std::endl << std::endl;
return false;
}
return true;
}
int
main(int argc, const char ** argv)
{
std::string opt_conf = "/usr/share/BiclopsDefault.cfg";
if (getOptions(argc, argv, opt_conf) == false) {
exit (-1);
}
try {
q = 0;
std::cout << "Set position in the articular frame: "
<<
" tilt: " <<
vpMath::deg(q[1]) <<
" deg" << std::endl ;
robot.setPositioningVelocity(30.) ;
std::cout << "Position in the articular frame: "
std::cout << "Velocity in the articular frame: "
std::cout << "Set position in the articular frame: "
<<
" tilt: " <<
vpMath::deg(q[1]) <<
" deg" << std::endl ;
robot.setPositioningVelocity(10) ;
std::cout << "Position in the articular frame: "
std::cout << "Velocity in the articular frame: "
std::cout << "Set STATE_VELOCITY_CONTROL" << std::endl;
std::cout << "Position in the articular frame: "
<<
" tilt: " <<
vpMath::deg(qm[1]) <<
" deg" << std::endl ;
std::cout << "Velocity in the articular frame: "
qdot = 0 ;
std::cout << "Set articular frame velocity "
<<
" tilt: " <<
vpMath::deg(qdot[1]) <<
" deg/s" << std::endl ;
std::cout << "Position in the articular frame: "
<<
" tilt: " <<
vpMath::deg(qm[1]) <<
" deg" << std::endl ;
std::cout << "Velocity in the articular frame: "
qdot = 0 ;
std::cout << "Set articular frame velocity "
<<
" tilt: " <<
vpMath::deg(qdot[1]) <<
" deg/s" << std::endl ;
std::cout << "Position in the articular frame: "
<<
" tilt: " <<
vpMath::deg(qm[1]) <<
" deg" << std::endl ;
std::cout << "Velocity in the articular frame: "
qdot = 0 ;
std::cout << "Set articular frame velocity "
<<
" tilt: " <<
vpMath::deg(qdot[1]) <<
" deg/s" << std::endl ;
std::cout << "Position in the articular frame: "
<<
" tilt: " <<
vpMath::deg(qm[1]) <<
" deg" << std::endl ;
std::cout << "Velocity in the articular frame: "
qdot = 0 ;
std::cout << "Set articular frame velocity "
<<
" tilt: " <<
vpMath::deg(qdot[1]) <<
" deg/s" << std::endl ;
std::cout << "Position in the articular frame: "
<<
" tilt: " <<
vpMath::deg(qm[1]) <<
" deg" << std::endl ;
std::cout << "Velocity in the articular frame: "
}
std::cout <<
"Catch an exception: " << e.
getMessage() << std::endl;
}
}
#else
int
main()
{
vpERROR_TRACE(
"You do not have a biclops robot connected to your computer...");
return 0;
}
#endif