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
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
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
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
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
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
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
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
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
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088 }