example showing how to connect and send direct basic motion commands to a Pioneer mobile robot.
WARNING: this program does no sensing or avoiding of obstacles, the robot WILL collide with any objects in the way! Make sure the robot has about 2-3 meters of free space around it before starting the program.
This program will work either with the MobileSim simulator or on a real robot's onboard computer. (Or use -remoteHost to connect to a wireless ethernet-serial bridge.)
#include <iostream>
#include <visp3/core/vpConfig.h>
#include <visp3/core/vpTime.h>
#include <visp3/robot/vpRobotPioneer.h>
#ifndef VISP_HAVE_PIONEER
int main()
{
std::cout << "\nThis example requires Aria 3rd party library. You should "
"install it.\n"
<< std::endl;
return EXIT_SUCCESS;
}
#else
int main(int argc, char **argv)
{
try {
std::cout << "\nWARNING: this program does no sensing or avoiding of "
"obstacles, \n"
"the robot WILL collide with any objects in the way! Make sure "
"the \n"
"robot has approximately 3 meters of free space on all sides.\n"
<< std::endl;
ArArgumentParser parser(&argc, argv);
parser.loadDefaultArguments();
ArRobotConnector robotConnector(&parser, &robot);
if (!robotConnector.connectRobot()) {
ArLog::log(ArLog::Terse, "Could not connect to the robot.");
if (parser.checkHelpAndWarnUnparsed()) {
Aria::logOptions();
Aria::exit(1);
}
}
if (!Aria::parseArgs()) {
Aria::logOptions();
Aria::shutdown();
return false;
}
std::cout << "Robot connected" << std::endl;
for (int i = 0; i < 100; i++) {
v = 0;
v[0] = i / 1000.;
std::cout <<
"Trans. vel= " << v_mes[0] <<
" m/s, Rot. vel=" <<
vpMath::deg(v_mes[1]) <<
" deg/s" << std::endl;
std::cout << "Left wheel vel= " << v_mes[0] << " m/s, Right wheel vel=" << v_mes[1] << " m/s" << std::endl;
std::cout << "Battery=" << robot.getBatteryVoltage() << std::endl;
}
ArLog::log(ArLog::Normal, "simpleMotionCommands: Stopping.");
robot.lock();
robot.stop();
robot.unlock();
ArUtil::sleep(1000);
robot.lock();
ArLog::log(ArLog::Normal,
"simpleMotionCommands: Pose=(%.2f,%.2f,%.2f), Trans. "
"Vel=%.2f, Rot. Vel=%.2f, Battery=%.2fV",
robot.getX(), robot.getY(), robot.getTh(), robot.getVel(), robot.getRotVel(), robot.getBatteryVoltage());
robot.unlock();
std::cout << "Ending robot thread..." << std::endl;
robot.stopRunning();
robot.waitForRunExit();
ArLog::log(ArLog::Normal, "simpleMotionCommands: Exiting.");
return EXIT_SUCCESS;
std::cout << "Catch an exception: " << e << std::endl;
return EXIT_FAILURE;
}
}
#endif
Implementation of column vector and the associated operations.
error that can be emitted by ViSP classes.
static double deg(double rad)
Interface for Pioneer mobile robots based on Aria 3rd party library.
void useSonar(bool usage)
void setVelocity(const vpRobot::vpControlFrameType frame, const vpColVector &vel)
void getVelocity(const vpRobot::vpControlFrameType frame, vpColVector &velocity)
VISP_EXPORT int wait(double t0, double t)
VISP_EXPORT double measureTimeMs()