Revision: 6925
          http://playerstage.svn.sourceforge.net/playerstage/?rev=6925&view=rev
Author:   jeremy_asher
Date:     2008-07-24 23:28:58 +0000 (Thu, 24 Jul 2008)

Log Message:
-----------
libstageplugin: progress on p_simulation and test, 2D and 3D get/set 
implemented, properties need work

Modified Paths:
--------------
    code/stage/trunk/libstage/model.cc
    code/stage/trunk/libstageplugin/p_driver.cc
    code/stage/trunk/libstageplugin/p_simulation.cc
    code/stage/trunk/libstageplugin/test/CMakeLists.txt
    code/stage/trunk/worlds/lsp_test.world

Added Paths:
-----------
    code/stage/trunk/libstageplugin/test/lsp_test_simulation.cc
    code/stage/trunk/libstageplugin/test/lsp_test_simulation.hh

Modified: code/stage/trunk/libstage/model.cc
===================================================================
--- code/stage/trunk/libstage/model.cc  2008-07-24 19:34:14 UTC (rev 6924)
+++ code/stage/trunk/libstage/model.cc  2008-07-24 23:28:58 UTC (rev 6925)
@@ -225,6 +225,7 @@
   this->gui_mask = this->parent ? 0 : DEFAULT_MASK;
 
   this->callbacks = g_hash_table_new( g_int_hash, g_int_equal );
+  g_datalist_init( &this->props );
   this->flag_list = NULL;
   this->blinkenlights = g_ptr_array_new();
 
@@ -260,6 +261,8 @@
     world->children = g_list_remove( world->children, this );
   
   if( callbacks ) g_hash_table_destroy( callbacks );
+       
+  g_datalist_clear( &props );
 
   g_hash_table_remove( StgModel::modelsbyid, (void*)id );
 

Modified: code/stage/trunk/libstageplugin/p_driver.cc
===================================================================
--- code/stage/trunk/libstageplugin/p_driver.cc 2008-07-24 19:34:14 UTC (rev 
6924)
+++ code/stage/trunk/libstageplugin/p_driver.cc 2008-07-24 23:28:58 UTC (rev 
6925)
@@ -311,39 +311,31 @@
          ifsrc = new InterfaceBlobfinder( player_addr,  this, cf, section );
          break;
                        
-//     case PLAYER_CAMERA_CODE:          
-//       ifsrc = new InterfaceCamera( player_addr,  this, cf, section );
-//       break;
+       case PLAYER_FIDUCIAL_CODE:
+               ifsrc = new InterfaceFiducial( player_addr,  this, cf, section 
);
+               break;
                        
+       case PLAYER_LASER_CODE:   
+               ifsrc = new InterfaceLaser( player_addr,  this, cf, section );
+               break;
+                       
+       case PLAYER_POSITION2D_CODE:      
+               ifsrc = new InterfacePosition( player_addr, this,  cf, section 
);
+               break;
          
        case PLAYER_SIMULATION_CODE:
          ifsrc = new InterfaceSimulation( player_addr, this, cf, section );
-         break;
+         break;          
          
-       case PLAYER_LASER_CODE:   
-         ifsrc = new InterfaceLaser( player_addr,  this, cf, section );
-         break;
-         
-       case PLAYER_POSITION2D_CODE:      
-         ifsrc = new InterfacePosition( player_addr, this,  cf, section );
-         break;
-         
        case PLAYER_SONAR_CODE:
          ifsrc = new InterfaceSonar( player_addr,  this, cf, section );
          break;
-                                 
-//     case PLAYER_POWER_CODE:   
-//       ifsrc = new InterfacePower( player_addr,  this, cf, section );
-//       break;
+                       
+       case PLAYER_SPEECH_CODE:
+               ifsrc = new InterfaceSpeech( player_addr,  this, cf, section );
+               break;    
+                       
          
-//     case PLAYER_PTZ_CODE:
-//       ifsrc = new InterfacePtz( player_addr,  this, cf, section );
-//       break;
-         
-       case PLAYER_FIDUCIAL_CODE:
-         ifsrc = new InterfaceFiducial( player_addr,  this, cf, section );
-         break;          
-         
 //     case PLAYER_LOCALIZE_CODE:
 //       ifsrc = new InterfaceLocalize( player_addr,  this, cf, section );
 //       break;          
@@ -366,16 +358,25 @@
 
 //     case PLAYER_WIFI_CODE:
 //       ifsrc = new InterfaceWifi( player_addr,  this, cf, section );
-//       break;          
+//       break;
+                       
+//     case PLAYER_CAMERA_CODE:          
+//       ifsrc = new InterfaceCamera( player_addr,  this, cf, section );
+//       break;
 
-       case PLAYER_SPEECH_CODE:
-         ifsrc = new InterfaceSpeech( player_addr,  this, cf, section );
-         break;          
+//     case PLAYER_POWER_CODE:   
+//       ifsrc = new InterfacePower( player_addr,  this, cf, section );
+//       break;
 
+//     case PLAYER_PTZ_CODE:
+//       ifsrc = new InterfacePtz( player_addr,  this, cf, section );
+//       break;
+
 //     case PLAYER_BUMPER_CODE:
 //       ifsrc = new InterfaceBumper( player_addr,  this, cf, section );
 //       break;          
 
+
        default:
          PRINT_ERR1( "error: stage driver doesn't support interface type %d\n",
                      player_addr.interf );

Modified: code/stage/trunk/libstageplugin/p_simulation.cc
===================================================================
--- code/stage/trunk/libstageplugin/p_simulation.cc     2008-07-24 19:34:14 UTC 
(rev 6924)
+++ code/stage/trunk/libstageplugin/p_simulation.cc     2008-07-24 23:28:58 UTC 
(rev 6925)
@@ -46,7 +46,7 @@
 
 // CODE ------------------------------------------------------------
 
-#define DEBUG
+//#define DEBUG
 
 #include <libgen.h> // for dirname(3)
 #include <libplayercore/globals.h> // for player_argc & player_argv
@@ -147,123 +147,226 @@
                                         player_msghdr_t* hdr,
                                         void* data)
 {
-  // Is it a request to set a model's pose?
-  if(Message::MatchMessage(hdr, PLAYER_MSGTYPE_REQ, 
-                           PLAYER_SIMULATION_REQ_SET_POSE2D, 
-                           this->addr))
-  {
-    player_simulation_pose2d_req_t* req = 
-            (player_simulation_pose2d_req_t*)data;
+       // Is it a request to get a model's pose in 2D?
+       if(Message::MatchMessage(hdr, PLAYER_MSGTYPE_REQ, 
+                                                                 
PLAYER_SIMULATION_REQ_GET_POSE2D, 
+                                                                 this->addr))
+    {
+               player_simulation_pose2d_req_t* req = 
+                       (player_simulation_pose2d_req_t*)data;
+               
+               PRINT_DEBUG1( "Stage: received request for the 2D position of 
object \"%s\"\n", req->name );
+               
+               // look up the named model      
+               StgModel* mod = StgDriver::world->GetModel( req->name );
+               
+               if( mod )
+               {
+                       stg_pose_t pose = mod->GetPose();
+                       
+                       PRINT_DEBUG3( "Stage: returning location [ %.2f, %.2f, 
%.2f ]\n",
+                                                 pose.x, pose.y, pose.a );
+               
+                       player_simulation_pose2d_req_t reply;
+                       memcpy( &reply, req, sizeof(reply));
+                       reply.pose.px = pose.x;
+                       reply.pose.py = pose.y;
+                       reply.pose.pa = pose.a;
+                       
+                       this->driver->Publish( this->addr, resp_queue, 
+                                                                 
PLAYER_MSGTYPE_RESP_ACK, 
+                                                                 
PLAYER_SIMULATION_REQ_GET_POSE2D,
+                                                                 
(void*)&reply, sizeof(reply), NULL );
+                       return(0);
+               }
+               else
+               {
+                       PRINT_WARN1( "Stage: GET_POSE2D request: simulation 
model \"%s\" not found", req->name );
+                       return(-1);
+               }
+       }
+       
+       // Is it a request to set a model's pose in 2D?
+       if(Message::MatchMessage(hdr, PLAYER_MSGTYPE_REQ, 
+                                                  
PLAYER_SIMULATION_REQ_SET_POSE2D, 
+                                                  this->addr))
+       {
+               player_simulation_pose2d_req_t* req = 
+                               (player_simulation_pose2d_req_t*)data;
 
-    stg_pose_t pose;
-    pose.x = req->pose.px;
-    pose.y = req->pose.py;
-    pose.a = req->pose.pa;
+               // look up the named model
+               StgModel* mod = StgDriver::world->GetModel( req->name );
 
-    // look up the named model
+               if( mod )
+               {
+                       PRINT_DEBUG4( "Stage: moving \"%s\" to [ %.2f, %.2f, 
%.2f ]\n",
+                                                 req->name, req->pose.px, 
req->pose.py, req->pose.pa );
+                       
+                       stg_pose_t pose = mod->GetPose();
+                       pose.x = req->pose.px;
+                       pose.y = req->pose.py;
+                       pose.a = req->pose.pa;
+                       
+                       mod->SetPose( pose );
 
-    StgModel* mod = StgDriver::world->GetModel( req->name );
-
-    if( mod )
-      {
-       printf( "Stage: moving \"%s\" to (%.2f,%.2f,%.2f)\n",
-               req->name, pose.x, pose.y, pose.a );
+                       this->driver->Publish(this->addr, resp_queue,
+                                                 PLAYER_MSGTYPE_RESP_ACK,
+                                                 
PLAYER_SIMULATION_REQ_SET_POSE2D);
+                       return(0);
+               }
+               else
+               {
+                       PRINT_WARN1( "SETPOSE2D request: simulation model 
\"%s\" not found", req->name );
+                       return(-1);
+               }
+       }
        
-       mod->SetPose( pose );
-       
-       this->driver->Publish(this->addr, resp_queue,
-                             PLAYER_MSGTYPE_RESP_ACK,
-                             PLAYER_SIMULATION_REQ_SET_POSE2D);
-       return(0);
-      }
-    else
-      {
-       PRINT_WARN1( "SETPOSE2D request: simulation model \"%s\" not found", 
req->name );
-       return(-1);
-      }
-  }
-  // Is it a request to set a model's pose?
-  else if(Message::MatchMessage(hdr, PLAYER_MSGTYPE_REQ, 
-                               PLAYER_SIMULATION_REQ_SET_PROPERTY, 
-                               this->addr))
+       // Is it a request to get a model's pose in 3D?
+       else if(Message::MatchMessage(hdr, PLAYER_MSGTYPE_REQ, 
+                                                                 
PLAYER_SIMULATION_REQ_GET_POSE3D, 
+                                                                 this->addr))
     {
-
-      player_simulation_property_req_t* req = 
-       (player_simulation_property_req_t*)data;
-      
-      // look up the named model      
-      StgModel* mod = 
-       //stg_world_model_name_lookup( StgDriver::world, req->name );
-       StgDriver::world->GetModel( req->name );
-      
-      if( mod )
-       {
-         int ack = 
-           mod->SetProperty( req->prop, 
-                             (void*)req->value );
-         
-         this->driver->Publish(this->addr, resp_queue,
-                               ack==0 ? PLAYER_MSGTYPE_RESP_ACK : 
PLAYER_MSGTYPE_RESP_NACK,
-                               PLAYER_SIMULATION_REQ_SET_PROPERTY);
-         return(0);
+               player_simulation_pose3d_req_t* req = 
+               (player_simulation_pose3d_req_t*)data;
+               
+               PRINT_DEBUG1( "Stage: received request for the 3D position of 
object \"%s\"\n", req->name );
+               
+               // look up the named model      
+               StgModel* mod = StgDriver::world->GetModel( req->name );
+               
+               if( mod )
+               {
+                       stg_pose_t pose = mod->GetPose();
+                       
+                       PRINT_DEBUG4( "Stage: returning location [ %.2f, %.2f, 
%.2f, %.2f ]\n",
+                                                 pose.x, pose.y, pose.z, 
pose.a );
+                       
+                       player_simulation_pose3d_req_t reply;
+                       memcpy( &reply, req, sizeof(reply));
+                       reply.pose.px = pose.x;
+                       reply.pose.py = pose.y;
+                       reply.pose.pz = pose.z;
+                       reply.pose.proll = 0; // currently unused
+                       reply.pose.ppitch = 0; // currently unused
+                       reply.pose.pyaw = pose.a;
+                       reply.simtime = mod->GetWorld()->SimTimeNow(); // time 
in microseconds
+                       
+                       this->driver->Publish( this->addr, resp_queue, 
+                                                                 
PLAYER_MSGTYPE_RESP_ACK, 
+                                                                 
PLAYER_SIMULATION_REQ_GET_POSE3D,
+                                                                 
(void*)&reply, sizeof(reply), NULL );
+                       return(0);
+               }
+               else
+               {
+                       PRINT_WARN1( "Stage: GET_POSE3D request: simulation 
model \"%s\" not found", req->name );
+                       return(-1);
+               }
        }
-      else
+       
+       // Is it a request to set a model's pose in 3D?
+       if(Message::MatchMessage(hdr, PLAYER_MSGTYPE_REQ, 
+                                                        
PLAYER_SIMULATION_REQ_SET_POSE3D, 
+                                                        this->addr))
        {
-         PRINT_WARN1( "SET_PROPERTY request: simulation model \"%s\" not 
found", req->name );
-         return(-1);
+               player_simulation_pose3d_req_t* req = 
+               (player_simulation_pose3d_req_t*)data;
+               
+               // look up the named model
+               StgModel* mod = StgDriver::world->GetModel( req->name );
+               
+               if( mod )
+               {
+                       PRINT_DEBUG5( "Stage: moving \"%s\" to [ %.2f, %.2f, 
%.2f %.2f ]\n",
+                                                 req->name, req->pose.px, 
req->pose.py, req->pose.pz, req->pose.pyaw );
+                       
+                       stg_pose_t pose = mod->GetPose();
+                       pose.x = req->pose.px;
+                       pose.y = req->pose.py;
+                       pose.z = req->pose.pz;
+                       pose.a = req->pose.pyaw;
+                       // roll and pitch are unused
+                       
+                       mod->SetPose( pose );
+                       
+                       this->driver->Publish(this->addr, resp_queue,
+                                                                 
PLAYER_MSGTYPE_RESP_ACK,
+                                                                 
PLAYER_SIMULATION_REQ_SET_POSE3D);
+                       return(0);
+               }
+               else
+               {
+                       PRINT_WARN1( "SETPOSE2D request: simulation model 
\"%s\" not found", req->name );
+                       return(-1);
+               }
        }
-    }
-  // Is it a request to get a model's pose?
-  else if(Message::MatchMessage(hdr, PLAYER_MSGTYPE_REQ, 
-                                PLAYER_SIMULATION_REQ_GET_POSE2D, 
-                                this->addr))
+       
+       
+       // Is it a request to set a model's property?
+       else if(Message::MatchMessage(hdr, PLAYER_MSGTYPE_REQ, 
+                               PLAYER_SIMULATION_REQ_SET_PROPERTY, 
+                               this->addr))
     {
-      player_simulation_pose2d_req_t* req = 
-       (player_simulation_pose2d_req_t*)data;
+               player_simulation_property_req_t* req = 
+                       (player_simulation_property_req_t*)data;
       
-      printf( "Stage: received request for position of object \"%s\"\n", 
req->name );
-      
-      // look up the named model       
-      StgModel* mod = 
-       //stg_world_model_name_lookup( StgDriver::world, req->name );
-       StgDriver::world->GetModel( req->name );
-      
-      if( mod )
-       {
-         stg_pose_t pose = mod->GetPose();
+               // look up the named model      
+               StgModel* mod = StgDriver::world->GetModel( req->name );
+                       
+               if( mod )
+               {
+                       int ack = 
+                       mod->SetProperty( req->prop, 
+                                         (void*)req->value );
 
-      printf( "Stage: returning location (%.2f,%.2f,%.2f)\n",
-              pose.x, pose.y, pose.a );
+                       this->driver->Publish(this->addr, resp_queue,
+                                       ack==0 ? PLAYER_MSGTYPE_RESP_ACK : 
PLAYER_MSGTYPE_RESP_NACK,
+                                       PLAYER_SIMULATION_REQ_SET_PROPERTY);
+                       return(0);
+               }
+               else
+               {
+                       PRINT_WARN1( "SET_PROPERTY request: simulation model 
\"%s\" not found", req->name );
+                       return(-1);
+               }
+       }
 
-
-      player_simulation_pose2d_req_t reply;
-      memcpy( &reply, req, sizeof(reply));
-      reply.pose.px = pose.x;
-      reply.pose.py = pose.y;
-      reply.pose.pa = pose.a;
-
-      /*
-         printf( "Stage: returning location (%d %d %d)\n",
-         reply.x, reply.y, reply.a );
-       */
-
-      this->driver->Publish( this->addr, resp_queue, 
-                             PLAYER_MSGTYPE_RESP_ACK, 
-                             PLAYER_SIMULATION_REQ_GET_POSE2D,
-                             (void*)&reply, sizeof(reply), NULL );
-      return(0);
-    }
-    else
+       // Is it a request to get a model's property?
+       else if(Message::MatchMessage(hdr, PLAYER_MSGTYPE_REQ, 
+                                                                 
PLAYER_SIMULATION_REQ_GET_PROPERTY, 
+                                                                 this->addr))
     {
-      PRINT_WARN1( "Stage: GET_POSE2D request: simulation model \"%s\" not 
found", req->name );
-      return(-1);
-    }
-  }
-  else
-  {
-    // Don't know how to handle this message.
-    PRINT_WARN2( "stg_simulation doesn't support msg with type/subtype %d/%d",
-                hdr->type, hdr->subtype);
-    return(-1);
-  }
+               player_simulation_property_req_t* req = 
+                       (player_simulation_property_req_t*)data;
+               
+               // look up the named model      
+               StgModel* mod = StgDriver::world->GetModel( req->name );
+               
+               if( mod )
+               {
+                       
+                       req->value = (char*)malloc( 2 );
+                       req->value[0] = NULL;
+                       //(char*)mod->GetProperty( req->prop );
+                       
+                       this->driver->Publish(this->addr, resp_queue,
+                                                                 
PLAYER_MSGTYPE_RESP_ACK,
+                                                                 
PLAYER_SIMULATION_REQ_GET_PROPERTY);
+                       return(0);
+               }
+               else
+               {
+                       PRINT_WARN1( "GET_PROPERTY request: simulation model 
\"%s\" not found", req->name );
+                       return(-1);
+               }
+       }
+       
+       
+       else
+       {
+               // Don't know how to handle this message.
+               PRINT_WARN2( "stg_simulation doesn't support msg with 
type/subtype %d/%d",
+                        hdr->type, hdr->subtype);
+               return(-1);
+       }
 }

Modified: code/stage/trunk/libstageplugin/test/CMakeLists.txt
===================================================================
--- code/stage/trunk/libstageplugin/test/CMakeLists.txt 2008-07-24 19:34:14 UTC 
(rev 6924)
+++ code/stage/trunk/libstageplugin/test/CMakeLists.txt 2008-07-24 23:28:58 UTC 
(rev 6925)
@@ -15,10 +15,12 @@
        lsp_test.cc
        lsp_test_proxy.cc
        lsp_test_proxy.hh
+       lsp_test_simulation.cc
+       lsp_test_simulation.hh
+       lsp_test_speech.cc
+       lsp_test_speech.hh
        lsp_test_laser.cc
        lsp_test_laser.hh
-       lsp_test_speech.cc
-       lsp_test_speech.hh
        lsp_test_sonar.cc
        lsp_test_sonar.hh
        lsp_test_fiducial.cc

Added: code/stage/trunk/libstageplugin/test/lsp_test_simulation.cc
===================================================================
--- code/stage/trunk/libstageplugin/test/lsp_test_simulation.cc                 
        (rev 0)
+++ code/stage/trunk/libstageplugin/test/lsp_test_simulation.cc 2008-07-24 
23:28:58 UTC (rev 6925)
@@ -0,0 +1,88 @@
+#include "lsp_test_simulation.hh"
+
+using namespace lspTest;
+
+void Simulation::setUp() {
+       connect();
+       simProxy = playerc_simulation_create( client, 0 );
+       CPPUNIT_ASSERT( playerc_simulation_subscribe( simProxy, 
PLAYER_OPEN_MODE ) == 0 );
+}
+
+void Simulation::tearDown() {
+       CPPUNIT_ASSERT( playerc_simulation_unsubscribe( simProxy ) == 0 );
+       playerc_simulation_destroy( simProxy );
+       disconnect();
+}
+
+void Simulation::testPose2D() {
+       double x, y, a;
+       double x2, y2, a2;
+       
+       // See if the robot "r1" is where it should be according to 
lsp_test.world
+       CPPUNIT_ASSERT( playerc_simulation_get_pose2d( simProxy, "r1", &x, &y, 
&a ) == 0 );
+       CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( "pose (x)", -5.085, x, Delta );
+       CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( "pose (y)", -7.193, y, Delta );
+       CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( "pose (a)", 3*M_PI/4, a, Delta );
+
+       // Set pose to [ 0, 0, 0 ] and verify
+       CPPUNIT_ASSERT( playerc_simulation_set_pose2d( simProxy, "r1", 0, 0, 0 
) == 0 );
+       CPPUNIT_ASSERT( playerc_simulation_get_pose2d( simProxy, "r1", &x2, 
&y2, &a2 ) == 0 );
+       CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( "pose (x)", 0, x2, Delta );
+       CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( "pose (y)", 0, y2, Delta );
+       CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( "pose (a)", 0, a2, Delta );
+       
+       // Return the robot to its starting point
+       CPPUNIT_ASSERT( playerc_simulation_set_pose2d( simProxy, "r1", x, y, a 
) == 0 );
+}
+
+void Simulation::testPose3D() {
+       double x, y, z, roll, pitch, yaw, time;
+       double x2, y2, z2, roll2, pitch2, yaw2, time2;
+       
+       // See if the robot "r1" is where it should be according to 
lsp_test.world
+       CPPUNIT_ASSERT( playerc_simulation_get_pose3d( simProxy, "r1", &x, &y, 
&z, &roll, &pitch, &yaw, &time ) == 0 );
+       CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( "pose (x)", -5.085, x, Delta );
+       CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( "pose (y)", -7.193, y, Delta );
+       CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( "pose (z)", 0, z, Delta );
+       CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( "pose (roll)", 0, roll, Delta );
+       CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( "pose (pitch)", 0, pitch, Delta );
+       CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( "pose (yaw)", 3*M_PI/4, yaw, 
Delta );
+       CPPUNIT_ASSERT( time > 0 );
+       
+       // Set pose to [ 0, 0, 0.5, M_PI/4, M_PI/4, M_PI/4 ] and verify
+       CPPUNIT_ASSERT( playerc_simulation_set_pose3d( simProxy, "r1", 0, 0, 
0.5, M_PI/4, M_PI/4, M_PI/4 ) == 0 );
+       CPPUNIT_ASSERT( playerc_simulation_get_pose3d( simProxy, "r1", &x2, 
&y2, &z2, &roll2, &pitch2, &yaw2, &time2 ) == 0 );
+       CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( "pose (x)", 0, x2, Delta );
+       CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( "pose (y)", 0, y2, Delta );
+       CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( "pose (z)", 0.5, z2, Delta );
+       // roll and pitch are currently unused in stage ( returns set to 0 )
+       CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( "pose (roll)", 0, roll2, Delta );
+       CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( "pose (pitch)", 0, pitch2, Delta 
);
+       CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( "pose (yaw)", M_PI/4, yaw2, Delta 
);
+       CPPUNIT_ASSERT( time2 > time );
+       
+       // Return the robot to its starting point
+       CPPUNIT_ASSERT( playerc_simulation_set_pose3d( simProxy, "r1", x, y, z, 
roll, pitch, yaw ) == 0 );      
+}
+
+void Simulation::testProperties() {
+       int r0Agg = 5;
+       int r1Agg = 1;
+       int r1Pow = 125;
+       
+       // Set some properties
+       CPPUNIT_ASSERT( playerc_simulation_set_property( simProxy, "r0", 
"aggression", &r0Agg, sizeof(r0Agg) ) == 0 );
+       CPPUNIT_ASSERT( playerc_simulation_set_property( simProxy, "r1", 
"aggression", &r1Agg, sizeof(r0Agg) ) == 0 );
+       CPPUNIT_ASSERT( playerc_simulation_set_property( simProxy, "r1", 
"power", &r1Pow, sizeof(r1Pow) ) == 0 );
+
+       // Get the properties back
+       int r0Agg2, r1Agg2, r1Pow2;
+       CPPUNIT_ASSERT( playerc_simulation_get_property( simProxy, "r0", 
"aggression", &r0Agg2, sizeof(r0Agg2) ) == 0 );
+       CPPUNIT_ASSERT( playerc_simulation_get_property( simProxy, "r1", 
"aggression", &r1Agg2, sizeof(r0Agg2) ) == 0 );
+       CPPUNIT_ASSERT( playerc_simulation_get_property( simProxy, "r1", 
"power", &r1Pow2, sizeof(r1Pow2) ) == 0 );
+       
+       // Make sure they're the same
+       CPPUNIT_ASSERT( r0Agg == r0Agg2 );
+       CPPUNIT_ASSERT( r1Agg == r1Agg2 );
+       CPPUNIT_ASSERT( r1Pow == r1Pow2 );
+}
\ No newline at end of file

Added: code/stage/trunk/libstageplugin/test/lsp_test_simulation.hh
===================================================================
--- code/stage/trunk/libstageplugin/test/lsp_test_simulation.hh                 
        (rev 0)
+++ code/stage/trunk/libstageplugin/test/lsp_test_simulation.hh 2008-07-24 
23:28:58 UTC (rev 6925)
@@ -0,0 +1,33 @@
+#ifndef _LSP_SIMULATION_TEST_H_
+#define _LSP_SIMULATION_TEST_H_
+
+#include <cppunit/extensions/HelperMacros.h>
+#include <libplayerc/playerc.h>
+
+#include "lsp_test_proxy.hh"
+
+namespace lspTest {
+       class Simulation : public Proxy
+               {
+                       CPPUNIT_TEST_SUB_SUITE( Simulation, Proxy );
+                       CPPUNIT_TEST( testPose2D );
+                       CPPUNIT_TEST( testPose3D );
+                       CPPUNIT_TEST( testProperties );
+                       CPPUNIT_TEST_SUITE_END();
+                       
+               protected:
+                       playerc_simulation_t* simProxy;
+                       
+                       void testPose2D();
+                       void testPose3D();
+                       void testProperties();
+                       
+               public:
+                       void setUp();
+                       void tearDown();
+               };
+};
+
+CPPUNIT_TEST_SUITE_REGISTRATION( lspTest::Simulation );
+
+#endif
\ No newline at end of file

Modified: code/stage/trunk/worlds/lsp_test.world
===================================================================
--- code/stage/trunk/worlds/lsp_test.world      2008-07-24 19:34:14 UTC (rev 
6924)
+++ code/stage/trunk/worlds/lsp_test.world      2008-07-24 23:28:58 UTC (rev 
6925)
@@ -64,5 +64,5 @@
   name "r1"
 
   fiducial_return 2
-  pose [ -5.085 -7.193 0 144.304 ] 
+  pose [ -5.085 -7.193 0 135 ] 
 )
\ No newline at end of file


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Playerstage-commit mailing list
Playerstage-commit@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/playerstage-commit

Reply via email to