Update of /cvsroot/playerstage/code/player/server/drivers/position/vfh
In directory 
sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3155/server/drivers/position/vfh

Modified Files:
        vfh.cc 
Log Message:
re-adde global argc and argv vars

Index: vfh.cc
===================================================================
RCS file: /cvsroot/playerstage/code/player/server/drivers/position/vfh/vfh.cc,v
retrieving revision 1.82
retrieving revision 1.83
diff -C2 -d -r1.82 -r1.83
*** vfh.cc      7 Dec 2007 01:50:15 -0000       1.82
--- vfh.cc      22 Feb 2008 20:51:50 -0000      1.83
***************
*** 19,23 ****
   * @brief Vector Field Histogram local navigation algorithm
  
! @note This driver may take several seconds to start up, especially on slower 
machines.  You may want to set the 'alwayson' option for vfh to '1' in your 
configuration file in order to front-load this delay.  Otherwise, your client 
may experience a timeout in trying to subscribe to this device.
  
  The vfh driver implements the Vector Field Histogram Plus local
--- 19,27 ----
   * @brief Vector Field Histogram local navigation algorithm
  
! @note This driver may take several seconds to start up, especially on
! slower machines.  You may want to set the 'alwayson' option for vfh to
! '1' in your configuration file in order to front-load this delay.
! Otherwise, your client may experience a timeout in trying to subscribe
! to this device.
  
  The vfh driver implements the Vector Field Histogram Plus local
***************
*** 165,168 ****
--- 169,175 ----
      - If non-zero, the maximum angular velocity that will be used when 
        trying to escape.
+   - synchronous (int)
+     - default: 0
+     -  If zero (the default), VFH runs in its own thread. If non-zero, VFH 
runs in the main Player thread, which will make the server less responsive, but 
prevent nasty asynchronous behaviour under high CPU load. This is probably only 
useful when running demanding simulations. 
  
  @par Example
***************
*** 191,195 ****
  @endverbatim
  
! @author Chris Jones, Brian Gerkey, Alex Brooks
  
  */
--- 198,202 ----
  @endverbatim
  
! @author Chris Jones, Brian Gerkey, Alex Brooks, Richard Vaughan
  
  */
***************
*** 217,224 ****
--- 224,238 ----
      virtual void Main();
  
+     // Update method called in Player's main thread
+     virtual void Update();
+ 
    private:
      bool active_goal;
      bool turninginplace;
  
+     // most of the work is done in this method. It is either called
+     // from ::Main() or ::Update(), depending on ::synchronous_mode.
+     void DoOneUpdate(); 
+ 
      // Set up the odometry device.
      int SetupOdom();
***************
*** 295,298 ****
--- 309,337 ----
      int32_t goal_x, goal_y, goal_t;
      int cmd_state, cmd_type;
+ 
+ 
+   // iff true, run in the main Player thread instead of a dedicated
+   // thread. Useful under heavy CPU load, for example when using a
+   // simulator with lots of robots - rtv 
+   bool synchronous_mode;
+ 
+   /* the following vars used to be local to the Main() method. I moved
+      them here when implementing the synchronous mode - rtv */
+   
+   float dist; 
+   double angdiff; 
+   struct timeval startescape, curr; 
+   bool escaping; 
+   double timediff; int
+   escape_turnrate_deg;
+   
+   // bookkeeping to implement hysteresis when rotating at the goal
+   int rotatedir;
+ 
+   // bookkeeping to implement smarter escape policy
+   int escapedir;
+ 
+   /* end of moved vars - rtv*/
+ 
  };
  
***************
*** 330,335 ****
      return -1;
  
    // Start the driver thread.
!   this->StartThread();
  
    return 0;
--- 369,390 ----
      return -1;
  
+ 
+ /*
+ <<<<<<< vfh.cc
+   // FIXME
+   // Allocate and intialize
+   vfh_Algorithm->Init();
+ 
+   // initialize some navigation state
+   rotatedir = 1;
+   escapedir = 1;
+   escaping = 0;
+ 
+ =======
+ >>>>>>> 1.82
+ */
    // Start the driver thread.
!   if( ! synchronous_mode )
!     this->StartThread();
  
    return 0;
***************
*** 341,345 ****
  {
    // Stop the driver thread.
!   this->StopThread();
  
    // Stop the laser
--- 396,401 ----
  {
    // Stop the driver thread.
!   if( ! this->synchronous_mode )
!     this->StopThread();
  
    // Stop the laser
***************
*** 357,360 ****
--- 413,427 ----
  }
  
+ 
+ 
/////////////////////////////////////////////////////////////////////////////////
+ // Update the driver in the main Player thread
+ void VFH_Class::Update()
+ {
+   if( synchronous_mode )
+     this->DoOneUpdate();
+   // otherwise, a dedicated thread is running: see VFH_Class::Main()
+ }
+ 
+ 
  
////////////////////////////////////////////////////////////////////////////////
  // Set up the underlying odom device.
***************
*** 748,778 ****
  void VFH_Class::Main()
  {
!   float dist;
!   double angdiff;
!   struct timeval startescape, curr;
!   bool escaping = false;
!   double timediff;
!   int escape_turnrate_deg;
! 
!   // bookkeeping to implement hysteresis when rotating at the goal
!   int rotatedir = 1;
! 
!   // bookkeeping to implement smarter escape policy
!   int escapedir;
! 
!   escapedir = 1;
!   while (true)
!   {
!     // Wait till we get new data
!     this->Wait();
  
!     // Test if we are supposed to cancel this thread.
!     pthread_testcancel();
  
!     // Process any pending requests.
      this->ProcessMessages();
  
      if(!this->active_goal)
!       continue;
  
      // Figure how far, in distance and orientation, we are from the goal
--- 815,843 ----
  void VFH_Class::Main()
  {
!   // loop over the main VFH activity. If we were in synchronous mode,
!   // this would happen in VFH_Class::Update(), in the main Player
!   // thread instead.
!   while( true )
!     {
!       // Wait till we get new data
!       this->Wait();
!       // Test if we are supposed to cancel this thread.
!       pthread_testcancel();
!       this->DoOneUpdate();
!     }
! }
  
! 
////////////////////////////////////////////////////////////////////////////////
! //
! void VFH_Class::DoOneUpdate()
! {  
!   if( this->InQueue->Empty() )
!     return;
  
!   // Process any pending requests.
      this->ProcessMessages();
  
      if(!this->active_goal)
!       return;//continue;
  
      // Figure how far, in distance and orientation, we are from the goal
***************
*** 906,910 ****
        this->PutCommand( this->speed, this->turnrate );
      }
!   }
  }
  
--- 971,975 ----
        this->PutCommand( this->speed, this->turnrate );
      }
! 
  }
  
***************
*** 962,965 ****
--- 1027,1033 ----
    this->speed = 0;
    this->turnrate = 0;
+   
+   // read the synchronous flag from the cfg file: defaults to not synchronous
+   this->synchronous_mode = cf->ReadInt(section, "synchronous", 0 );
  
    cell_size = cf->ReadLength(section, "cell_size", 0.1) * 1e3;
***************
*** 1063,1066 ****
--- 1131,1136 ----
  
  
+ 
+ 
    return;
  }


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit

Reply via email to