lsp_test_simulation.cc
Go to the documentation of this file.
00001 #include "lsp_test_simulation.hh"
00002 
00003 using namespace lspTest;
00004 
00005 void Simulation::setUp() {
00006         connect();
00007         simProxy = playerc_simulation_create( client, 0 );
00008         CPPUNIT_ASSERT( playerc_simulation_subscribe( simProxy, PLAYER_OPEN_MODE ) == 0 );
00009 }
00010 
00011 void Simulation::tearDown() {
00012         CPPUNIT_ASSERT( playerc_simulation_unsubscribe( simProxy ) == 0 );
00013         playerc_simulation_destroy( simProxy );
00014         disconnect();
00015 }
00016 
00017 void Simulation::testPose2D() {
00018         double x, y, a;
00019         double x2, y2, a2;
00020         
00021         // See if the robot "r1" is where it should be according to lsp_test.world
00022         CPPUNIT_ASSERT( playerc_simulation_get_pose2d( simProxy, "r1", &x, &y, &a ) == 0 );
00023         CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( "pose (x)", -4.19, x, Delta );
00024         CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( "pose (y)", -5.71, y, Delta );
00025         CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( "pose (a)", 3*M_PI/4, a, Delta );
00026 
00027         // Set pose to [ 0, 0, 0 ] and verify
00028         CPPUNIT_ASSERT( playerc_simulation_set_pose2d( simProxy, "r1", 0, 0, 0 ) == 0 );
00029         CPPUNIT_ASSERT( playerc_simulation_get_pose2d( simProxy, "r1", &x2, &y2, &a2 ) == 0 );
00030         CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( "pose (x)", 0, x2, Delta );
00031         CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( "pose (y)", 0, y2, Delta );
00032         CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( "pose (a)", 0, a2, Delta );
00033         
00034         // Return the robot to its starting point
00035         CPPUNIT_ASSERT( playerc_simulation_set_pose2d( simProxy, "r1", x, y, a ) == 0 );
00036 }
00037 
00038 void Simulation::testPose3D() {
00039         double x, y, z, roll, pitch, yaw, time;
00040         double x2, y2, z2, roll2, pitch2, yaw2, time2;
00041         
00042         // See if the robot "r1" is where it should be according to lsp_test.world
00043         CPPUNIT_ASSERT( playerc_simulation_get_pose3d( simProxy, "r1", &x, &y, &z, &roll, &pitch, &yaw, &time ) == 0 );
00044         CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( "pose (x)", -4.19, x, Delta );
00045         CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( "pose (y)", -5.71, y, Delta );
00046         CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( "pose (z)", 0, z, Delta );
00047         CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( "pose (roll)", 0, roll, Delta );
00048         CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( "pose (pitch)", 0, pitch, Delta );
00049         CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( "pose (yaw)", 3*M_PI/4, yaw, Delta );
00050         CPPUNIT_ASSERT( time > 0 );
00051         
00052         // Set pose to [ 0, 0, 0.5, M_PI/4, M_PI/4, M_PI/4 ] and verify
00053         CPPUNIT_ASSERT( playerc_simulation_set_pose3d( simProxy, "r1", 0, 0, 0.5, M_PI/4, M_PI/4, M_PI/4 ) == 0 );
00054         CPPUNIT_ASSERT( playerc_simulation_get_pose3d( simProxy, "r1", &x2, &y2, &z2, &roll2, &pitch2, &yaw2, &time2 ) == 0 );
00055         CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( "pose (x)", 0, x2, Delta );
00056         CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( "pose (y)", 0, y2, Delta );
00057         CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( "pose (z)", 0.5, z2, Delta );
00058         // roll and pitch are currently unused in stage ( returns set to 0 )
00059         CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( "pose (roll)", 0, roll2, Delta );
00060         CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( "pose (pitch)", 0, pitch2, Delta );
00061         CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( "pose (yaw)", M_PI/4, yaw2, Delta );
00062         CPPUNIT_ASSERT( time2 > time );
00063         
00064         // Return the robot to its starting point
00065         CPPUNIT_ASSERT( playerc_simulation_set_pose3d( simProxy, "r1", x, y, z, roll, pitch, yaw ) == 0 );      
00066 }
00067 
00068 void Simulation::testProperties() {     
00069         int r0Agg = 5;
00070         int r1Agg = 1;
00071         int r1Pow = 125;
00072         
00073         // Set some properties
00074         CPPUNIT_ASSERT( playerc_simulation_set_property( simProxy, "r0", "aggression", &r0Agg, sizeof(void*) ) == 0 );
00075         CPPUNIT_ASSERT( playerc_simulation_set_property( simProxy, "r1", "aggression", &r1Agg, sizeof(void*) ) == 0 );
00076         CPPUNIT_ASSERT( playerc_simulation_set_property( simProxy, "r1", "power", &r1Pow, sizeof(void*) ) == 0 );
00077 
00078         // Get the properties back
00079 //      int r0Agg2, r1Agg2, r1Pow2;
00080 //      CPPUNIT_ASSERT( playerc_simulation_get_property( simProxy, "r0", "aggression", &r0Agg2, sizeof(void*) ) == 0 );
00081 //      CPPUNIT_ASSERT( playerc_simulation_get_property( simProxy, "r1", "aggression", &r1Agg2, sizeof(void*) ) == 0 );
00082 //      CPPUNIT_ASSERT( playerc_simulation_get_property( simProxy, "r1", "power", &r1Pow2, sizeof(void*) ) == 0 );
00083         
00084         // Make sure they're the same
00085 //      CPPUNIT_ASSERT_EQUAL_MESSAGE( "r0Agg", r0Agg, r0Agg2 );
00086 //      CPPUNIT_ASSERT_EQUAL_MESSAGE( "r1Agg", r1Agg, r1Agg2 );
00087 //      CPPUNIT_ASSERT_EQUAL_MESSAGE( "r1Pow", r1Pow, r1Pow2 );
00088 }


stage
Author(s): Richard Vaughan , Brian Gerkey , Reed Hedges , Andrew Howard , Toby Collett , Pooya Karimian , Jeremy Asher , Alex Couture-Beil , Geoff Biggs , Rich Mattes , Abbas Sadat
autogenerated on Thu Aug 27 2015 15:20:57