/usr/src/rpm/BUILD/libirobot-create-0.1/tests/drive-command-test.cc File Reference

#include "common.hh"

Include dependency graph for drive-command-test.cc:


Functions

int run_test (iRobot::Create &robot, std::stringstream &)

Function Documentation

int run_test ( iRobot::Create robot,
std::stringstream &   
)

00022 {
00023   using namespace iRobot;
00024 
00025   // Test Mode.
00026   CHECK_FAILURE
00027     (CommandNotAvailable,
00028      robot.sendDriveCommand (Create::VELOCITY_MIN, Create::RADIUS_MIN));
00029 
00030   // Switch to full mode and test a command.
00031   robot.sendFullCommand ();
00032   robot.sendDriveCommand (Create::VELOCITY_MIN, Create::RADIUS_MIN);
00033 
00034   // Switch to safe mode for the rest of the test.
00035   robot.sendSafeCommand ();
00036 
00037   // Send a couple of valid commands (test bounds).
00038   int vmean = (Create::VELOCITY_MAX - Create::VELOCITY_MIN) / 2;
00039   int rmean = (Create::RADIUS_MAX - Create::RADIUS_MIN) / 2;
00040   robot.sendDriveCommand (vmean, rmean);
00041   robot.sendDriveCommand (Create::VELOCITY_MIN, Create::RADIUS_MIN);
00042   robot.sendDriveCommand (Create::VELOCITY_MIN, Create::RADIUS_MAX);
00043   robot.sendDriveCommand (Create::VELOCITY_MAX, Create::RADIUS_MIN);
00044   robot.sendDriveCommand (Create::VELOCITY_MAX, Create::RADIUS_MAX);
00045 
00046   // Check velocity minimum - 1.
00047   CHECK_FAILURE
00048     (InvalidArgument,
00049      robot.sendDriveCommand (Create::VELOCITY_MIN - 1,
00050                              Create::RADIUS_MAX / 4));
00051 
00052   // Check velocity maximum + 1.
00053   CHECK_FAILURE
00054     (InvalidArgument,
00055      robot.sendDriveCommand (Create::VELOCITY_MAX + 1,
00056                              Create::RADIUS_MAX / 4));
00057 
00058   // Check radius minimum - 1.
00059   CHECK_FAILURE
00060     (InvalidArgument,
00061      robot.sendDriveCommand (Create::VELOCITY_MAX / 4,
00062                              Create::RADIUS_MIN - 1));
00063 
00064   // Check radius maximum + 1.
00065   CHECK_FAILURE
00066     (InvalidArgument,
00067      robot.sendDriveCommand (Create::VELOCITY_MAX / 4,
00068                              Create::RADIUS_MAX + 1));
00069 
00070   // Test special cases.
00071   robot.sendDriveCommand (vmean,
00072                           Create::DRIVE_STRAIGHT);
00073   robot.sendDriveCommand (Create::VELOCITY_MIN,
00074                           Create::DRIVE_STRAIGHT);
00075   robot.sendDriveCommand (Create::VELOCITY_MAX,
00076                           Create::DRIVE_STRAIGHT);
00077 
00078   robot.sendDriveCommand (vmean,
00079                           Create::DRIVE_INPLACE_CLOCKWISE);
00080   robot.sendDriveCommand (Create::VELOCITY_MIN,
00081                           Create::DRIVE_INPLACE_CLOCKWISE);
00082   robot.sendDriveCommand (Create::VELOCITY_MAX,
00083                           Create::DRIVE_INPLACE_CLOCKWISE);
00084 
00085   robot.sendDriveCommand (vmean,
00086                           Create::DRIVE_INPLACE_COUNTERCLOCKWISE);
00087   robot.sendDriveCommand (Create::VELOCITY_MIN,
00088                           Create::DRIVE_INPLACE_COUNTERCLOCKWISE);
00089   robot.sendDriveCommand (Create::VELOCITY_MAX,
00090                           Create::DRIVE_INPLACE_COUNTERCLOCKWISE);
00091 
00092   // Test special cases failures.
00093   CHECK_FAILURE
00094     (InvalidArgument,
00095      robot.sendDriveCommand (Create::VELOCITY_MIN - 1,
00096                              Create::DRIVE_STRAIGHT));
00097 
00098   CHECK_FAILURE
00099     (InvalidArgument,
00100      robot.sendDriveCommand (Create::VELOCITY_MAX + 1,
00101                              Create::DRIVE_STRAIGHT));
00102 
00103   CHECK_FAILURE
00104     (InvalidArgument,
00105      robot.sendDriveCommand (Create::VELOCITY_MIN - 1,
00106                              Create::DRIVE_INPLACE_CLOCKWISE));
00107 
00108   CHECK_FAILURE
00109     (InvalidArgument,
00110      robot.sendDriveCommand (Create::VELOCITY_MAX + 1,
00111                              Create::DRIVE_INPLACE_CLOCKWISE));
00112 
00113   CHECK_FAILURE
00114     (InvalidArgument,
00115      robot.sendDriveCommand (Create::VELOCITY_MIN - 1,
00116                              Create::DRIVE_INPLACE_COUNTERCLOCKWISE));
00117 
00118   CHECK_FAILURE
00119     (InvalidArgument,
00120      robot.sendDriveCommand (Create::VELOCITY_MAX + 1,
00121                              Create::DRIVE_INPLACE_COUNTERCLOCKWISE));
00122 
00123   return TEST_SUCCEED;
00124 }


Generated on Thu Aug 28 14:38:06 2008 for iRobot Create library by  doxygen 1.5.4