Revision: 7063
          http://playerstage.svn.sourceforge.net/playerstage/?rev=7063&view=rev
Author:   gbiggs
Date:     2008-10-06 01:22:47 +0000 (Mon, 06 Oct 2008)

Log Message:
-----------
Applied patch 2147767

Modified Paths:
--------------
    code/player/trunk/server/drivers/joystick/linuxjoy.cc

Modified: code/player/trunk/server/drivers/joystick/linuxjoy.cc
===================================================================
--- code/player/trunk/server/drivers/joystick/linuxjoy.cc       2008-10-06 
01:18:48 UTC (rev 7062)
+++ code/player/trunk/server/drivers/joystick/linuxjoy.cc       2008-10-06 
01:22:47 UTC (rev 7063)
@@ -223,7 +223,6 @@
 #include <replace/replace.h> // for poll(2)
 #include <libplayercore/playercore.h>
 #include <libplayercore/error.h>
-#include <iostream>
 
 extern PlayerTime *GlobalTime;
 
@@ -412,42 +411,18 @@
 
   this->position = NULL;
   // If we're asked, open the position2d device
-  if(this->cmd_position_addr.interf)
+  if (this->cmd_position_addr.interf)
   {
-    if(!(this->position = deviceTable->GetDevice(this->cmd_position_addr)))
+    if (!(this->position = deviceTable->GetDevice(this->cmd_position_addr)))
     {
       PLAYER_ERROR("unable to locate suitable position2d device");
       return -1;
     }
-    if(this->position->Subscribe(this->InQueue) != 0)
+    if (this->position->Subscribe(this->InQueue) != 0)
     {
       PLAYER_ERROR("unable to subscribe to position2d device");
       return -1;
     }
-
-    // Enable the motors
-    player_position2d_power_config_t motorconfig;
-    motorconfig.state = 1;
-    Message* msg;
-    if(!(msg = this->position->Request(this->InQueue,
-                                       PLAYER_MSGTYPE_REQ,
-                                       PLAYER_POSITION2D_REQ_MOTOR_POWER,
-                                       (void*)&motorconfig,
-                                       sizeof(motorconfig),NULL,false)))
-    {
-      PLAYER_WARN("failed to enable motors");
-    }
-    else
-      delete msg;
-
-    // Stop the robot
-    player_position2d_cmd_vel_t cmd;
-    memset(&cmd,0,sizeof(cmd));
-    this->position->PutMsg(this->InQueue,
-                           PLAYER_MSGTYPE_CMD,
-                           PLAYER_POSITION2D_CMD_VEL,
-                           (void*)&cmd, sizeof(player_position2d_cmd_vel_t),
-                           NULL);
   }
   this->gripper = NULL;
   // If we're asked, open the gripper device
@@ -503,6 +478,33 @@
 // Main function for device thread
 void LinuxJoystick::Main()
 {
+  if (this->cmd_position_addr.interf)
+  {
+    // Enable the motors
+    player_position2d_power_config_t motorconfig;
+    memset(&motorconfig, 0, sizeof motorconfig);
+    motorconfig.state = 1;
+    Message* msg;
+    if (!(msg = this->position->Request(this->InQueue,
+                                        PLAYER_MSGTYPE_REQ,
+                                        PLAYER_POSITION2D_REQ_MOTOR_POWER,
+                                        reinterpret_cast<void *>(&motorconfig),
+                                        sizeof motorconfig, NULL)))
+    {
+      PLAYER_WARN("failed to enable motors");
+    }
+    else
+      delete msg;
+
+    // Stop the robot
+    player_position2d_cmd_vel_t cmd;
+    memset(&cmd, 0, sizeof cmd);
+    this->position->PutMsg(this->InQueue,
+                           PLAYER_MSGTYPE_CMD,
+                           PLAYER_POSITION2D_CMD_VEL,
+                           reinterpret_cast<void *>(&cmd), sizeof cmd,
+                           NULL);
+  }
   // The main loop; interact with the device here
   while (true)
   {


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