Update of /cvsroot/playerstage/code/player/server/drivers/mixed/garcia
In directory 
sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4552/server/drivers/mixed/garcia

Modified Files:
      Tag: release-2-0-patches
        Makefile.am garcia_mixed.cc garcia_mixed.h 
Log Message:
backported lots of stuff from HEAD

Index: garcia_mixed.h
===================================================================
RCS file: 
/cvsroot/playerstage/code/player/server/drivers/mixed/garcia/garcia_mixed.h,v
retrieving revision 1.2
retrieving revision 1.2.2.1
diff -C2 -d -r1.2 -r1.2.2.1
*** garcia_mixed.h      18 Feb 2006 19:13:04 -0000      1.2
--- garcia_mixed.h      7 Jun 2006 16:12:51 -0000       1.2.2.1
***************
*** 36,39 ****
--- 36,41 ----
      GarciaDriver(ConfigFile* cf, int section);
  
+     virtual ~GarciaDriver();
+ 
      // Must implement the following methods.
      int Setup();
***************
*** 47,53 ****
                                 void * data);
      //void ProcessConfig();
!     void ProcessPos2dCommand(player_msghdr_t* hdr, player_position2d_cmd_t 
&data);
      void ProcessSpeechCommand(player_msghdr_t* hdr, player_speech_cmd_t 
&data);
      void ProcessDioCommand(player_msghdr_t* hdr, player_dio_cmd_t &data);
      void RefreshData();
  
--- 49,60 ----
                                 void * data);
      //void ProcessConfig();
!     void ProcessPos2dPosCmd(player_msghdr_t* hdr, player_position2d_cmd_pos_t 
&data);
!     void ProcessPos2dVelCmd(player_msghdr_t* hdr, player_position2d_cmd_vel_t 
&data);
      void ProcessSpeechCommand(player_msghdr_t* hdr, player_speech_cmd_t 
&data);
      void ProcessDioCommand(player_msghdr_t* hdr, player_dio_cmd_t &data);
+ 
+     void ProcessPos2dGeomReq(player_msghdr_t* hdr);
+     void ProcessIrPoseReq(player_msghdr_t* hdr);
+ 
      void RefreshData();
  
***************
*** 57,70 ****
      player_devaddr_t           mPos2dAddr;
      player_position2d_data_t   mPos2dData;
!     player_position2d_cmd_t    mPos2dCmd;
  
      // ir interface
      player_devaddr_t       mIrAddr;
      player_ir_data_t       mIrData;
-     player_ir_cmd_t        mIrCmd;
  
      // speech interface
      player_devaddr_t       mSpeechAddr;
-     player_speech_data_t   mSpeechData;
      player_speech_cmd_t    mSpeechCmd;
  
--- 64,76 ----
      player_devaddr_t           mPos2dAddr;
      player_position2d_data_t   mPos2dData;
!     player_position2d_cmd_pos_t    mPos2dPosCmd;
!     player_position2d_cmd_vel_t    mPos2dVelCmd;
  
      // ir interface
      player_devaddr_t       mIrAddr;
      player_ir_data_t       mIrData;
  
      // speech interface
      player_devaddr_t       mSpeechAddr;
      player_speech_cmd_t    mSpeechCmd;
  
***************
*** 74,81 ****
      player_dio_cmd_t       mDioCmd;
  
      int32_t mSleep;
  
!     acpGarcia* mGarcia;
  
!     const char *mConfigPath;
  };
--- 80,98 ----
      player_dio_cmd_t       mDioCmd;
  
+     // power interface
+     player_devaddr_t       mPowerAddr;
+     player_power_data_t      mPowerData;
+ 
      int32_t mSleep;
  
!     double mLength;
!     double mWidth;
!     double mWheelBase;
!     double mWheelRadius;
  
!     acpValue mSpeed;
!     acpValue mPitch;
!     acpValue mVolume;
! 
!     acpGarcia* mGarcia;
  };

Index: Makefile.am
===================================================================
RCS file: 
/cvsroot/playerstage/code/player/server/drivers/mixed/garcia/Makefile.am,v
retrieving revision 1.2
retrieving revision 1.2.2.1
diff -C2 -d -r1.2 -r1.2.2.1
*** Makefile.am 28 Feb 2006 05:15:41 -0000      1.2
--- Makefile.am 7 Jun 2006 16:12:51 -0000       1.2.2.1
***************
*** 1,8 ****
! AM_CPPFLAGS = -Wall -I$(top_srcdir)
  
  noinst_LTLIBRARIES =
  if INCLUDE_GARCIA
  noinst_LTLIBRARIES += libgarcia.la
  endif
  
  libgarcia_la_SOURCES = garcia_mixed.cc garcia_mixed.h
--- 1,11 ----
! AM_CPPFLAGS = -Wall -I$(top_srcdir) @GARCIA_CFLAGS@
  
  noinst_LTLIBRARIES =
  if INCLUDE_GARCIA
  noinst_LTLIBRARIES += libgarcia.la
+ #EXTRA_LIBRARIES = libaIO.a libaUI.a libaStem.a libaTEAvm.a libaRobot.a
  endif
  
  libgarcia_la_SOURCES = garcia_mixed.cc garcia_mixed.h
+ #libgarcia_la_LIBADD = @GARCIA_LIBS@
+ #PLAYER_DRIVER_EXTRA_LIBS += @GARCIA_LIBS@
\ No newline at end of file

Index: garcia_mixed.cc
===================================================================
RCS file: 
/cvsroot/playerstage/code/player/server/drivers/mixed/garcia/garcia_mixed.cc,v
retrieving revision 1.5
retrieving revision 1.5.2.1
diff -C2 -d -r1.5 -r1.5.2.1
*** garcia_mixed.cc     27 Feb 2006 18:19:03 -0000      1.5
--- garcia_mixed.cc     7 Jun 2006 16:12:51 -0000       1.5.2.1
***************
*** 45,48 ****
--- 45,52 ----
  - @ref interface_speech
  - @ref interface_dio
+ - @ref interface_power
+ - @ref interface_ptz (not yet implemented)
+ - @ref interface_position1d (not yet implemented)
+ 
  
  @par Requires
***************
*** 52,62 ****
  @par Configuration requests
  
! - none
  
  @par Configuration file options
  
! - config_path (filename)
!   - Default: "garcia.config"
!   - Path to Garcia configuration file
  
  @par Example
--- 56,92 ----
  @par Configuration requests
  
! - @ref interface_position2d
!   - PLAYER_POSITION_GET_GEOM_REQ
!   - PLAYER_POSITION_SET_ODOM_REQ :
!   - PLAYER_POSITION_RESET_ODOM_REQ :
!   - PLAYER_POSITION_POWER_REQ :
!   - PLAYER_POSITION_SPEED_PID_REQ :
!   - PLAYER_POSITION_POSITION_PID_REQ :
!   - PLAYER_POSITION_SPEED_PROF_REQ :
!   - PLAYER_IR_GET_GEOM_REQ :
  
  @par Configuration file options
  
! - port (filename)
!   - Default: "ttyS0"
!   - Path to the serial port
! - baud (int)
!   - Default: 38400
!   - Baudrate of the serial port
! - speed (float)
!   - Default: 0.7f
!   - The speed for speaking the phrase.  Values have a range of 0.0 to 1.0 and
!     will be clamped to this range. 0.0 is the slowest and 1.0 is the fastest
!     speed for saying the phrase.
! - pitch (float)
!   - Default: 0.6f
!   - The pitch for speaking the phrase.  Values have a range of 0.0 to 1.0 and
!     will be clamped to this range. 0.0 is the lowest and 1.0 is the highest
!     pitch for saying the phrase.
! - volume (float)
!   - Default: 1.0f
!   - The volume for speaking the phrase.  Values have a range of 0.0 to 1.0 and
!     will be clamped to this range. 0.0 is the quietest and 1.0 is the loudest
!     volume for saying the phrase.
  
  @par Example
***************
*** 65,74 ****
  driver
  (
!   name "garciadriver"
    provides ["position2d:0"
              "ir:0"
              "dio:0"
              "speech:0"]
!   port "/dev/ttyS0"
  )
  @endverbatim
--- 95,105 ----
  driver
  (
!   name "garcia"
    provides ["position2d:0"
              "ir:0"
              "dio:0"
              "speech:0"]
!   port "ttyS0"
!   baud "38400"
  )
  @endverbatim
***************
*** 98,104 ****
  #include <assert.h>
  #include <math.h>
  using namespace std;
  
! const timespec NSLEEP_TIME = {0, 10000000}; // (0s, 10 ms) => max 100 fps
  
  
////////////////////////////////////////////////////////////////////////////////
--- 129,138 ----
  #include <assert.h>
  #include <math.h>
+ #include <stdio.h>
  using namespace std;
  
! #include <iostream> // only used for debugging, so remove when done
! 
! const timespec NSLEEP_TIME = {0, 20000000}; // (0s, 20 ms) => max 50 hz
  
  
////////////////////////////////////////////////////////////////////////////////
***************
*** 131,139 ****
  // pre-Setup() setup.
  GarciaDriver::GarciaDriver(ConfigFile* cf, int section)
!     : Driver(cf, section)
  {
    // Create position2d interface
!   if (0 != cf->ReadDeviceAddr(&(mPos2dAddr),section,"provides",
!                               PLAYER_POSITION2D_CODE,-1,NULL))
    {
      PLAYER_ERROR("Could not read position2d ID ");
--- 165,177 ----
  // pre-Setup() setup.
  GarciaDriver::GarciaDriver(ConfigFile* cf, int section)
!     : Driver(cf, section),
!       mLength(0.28),
!       mWidth(0.20),
!       mWheelBase(0.182),
!       mWheelRadius(0.1)
  {
    // Create position2d interface
!   if (0 != cf->ReadDeviceAddr(&mPos2dAddr, section, "provides",
!                               PLAYER_POSITION2D_CODE, -1, NULL))
    {
      PLAYER_ERROR("Could not read position2d ID ");
***************
*** 149,154 ****
  
    // Create ir interface
!   if (0 != cf->ReadDeviceAddr(&(mIrAddr),section,"provides",
!                               PLAYER_IR_CODE,-1,NULL))
    {
      PLAYER_ERROR("Could not read ir ID ");
--- 187,192 ----
  
    // Create ir interface
!   if (0 != cf->ReadDeviceAddr(&mIrAddr, section, "provides",
!                               PLAYER_IR_CODE, -1, NULL))
    {
      PLAYER_ERROR("Could not read ir ID ");
***************
*** 164,169 ****
  
    // Create speech interface
!   if (0 != cf->ReadDeviceAddr(&(mSpeechAddr),section,"provides",
!                               PLAYER_SPEECH_CODE,-1,NULL))
    {
      PLAYER_ERROR("Could not read speech ID ");
--- 202,207 ----
  
    // Create speech interface
!   if (0 != cf->ReadDeviceAddr(&mSpeechAddr, section, "provides",
!                               PLAYER_SPEECH_CODE, -1, NULL))
    {
      PLAYER_ERROR("Could not read speech ID ");
***************
*** 180,184 ****
    // Create dio interface
    if (0 != cf->ReadDeviceAddr(&(mDioAddr),section,"provides",
!                               PLAYER_Dio_CODE,-1,NULL))
    {
      PLAYER_ERROR("Could not read dio ID ");
--- 218,222 ----
    // Create dio interface
    if (0 != cf->ReadDeviceAddr(&(mDioAddr),section,"provides",
!                               PLAYER_DIO_CODE,-1,NULL))
    {
      PLAYER_ERROR("Could not read dio ID ");
***************
*** 193,205 ****
    }
  
!   /// @todo is there a replacement clear command?
!   //ClearCommand(mPosition2dAddr);
  
    // Read options from the configuration file
!   mConfigPath = cf->ReadFilename(section, "config_path", "garcia.config");
  
    return;
  }
  
  
////////////////////////////////////////////////////////////////////////////////
  // Set up the device.  Return 0 if things go well, and -1 otherwise.
--- 231,280 ----
    }
  
!   // Create power interface
!   if (0 != cf->ReadDeviceAddr(&mPowerAddr,
!                             section,
!                             "provides",
!                             PLAYER_POWER_CODE,
!                             -1,
!                             NULL))
!   {
!     PLAYER_ERROR("could not read power address");
!     SetError(-1);
!     return;
!   }
! 
!   if (0 != AddInterface(mPowerAddr))
!   {
!     PLAYER_ERROR("could not add power interface");
!     SetError(-1);
!     return;
!   }
  
    // Read options from the configuration file
!   const char* portname = cf->ReadFilename(section, "portname", "ttyS0");
!   int baudrate = cf->ReadInt(section, "baudrate", 38400);
! 
!   // let's just create the config file wherever we are:
!   static FILE* config_file;
!   config_file = fopen("garcia_api.config", "a+");
! 
!   fprintf(config_file, "portname=%s\n", portname);
!   fprintf(config_file, "baudrate=%i\n", baudrate);
! 
!   mSpeed = static_cast<float>(cf->ReadFloat(section, "speed", 0.7f));
!   mPitch = static_cast<float>(cf->ReadFloat(section, "pitch", 0.6f));
!   mVolume = static_cast<float>(cf->ReadFloat(section, "volume", 1.0f));
! 
!   fclose(config_file);
  
    return;
  }
  
+ GarciaDriver::~GarciaDriver()
+ {
+   // get rid of the Acroname config file
+   //remove("garcia_api.config");
+ }
+ 
  
////////////////////////////////////////////////////////////////////////////////
  // Set up the device.  Return 0 if things go well, and -1 otherwise.
***************
*** 208,211 ****
--- 283,304 ----
  {
  
+   cout << "Setting up Garcia driver" << flush;
+   mGarcia = new acpGarcia;
+ 
+   while (!mGarcia->getNamedValue("active")->getBoolVal())
+   {
+     cout << "." << flush;
+     nanosleep(&NSLEEP_TIME, NULL);
+   }
+ 
+   // enable the IR sensors
+   acpValue enable(1);
+   mGarcia->setNamedValue("front-ranger-enable", &enable);
+   mGarcia->setNamedValue("side-ranger-enable", &enable);
+   mGarcia->setNamedValue("rear-ranger-enable", &enable);
+ 
+ 
+   puts("finished!");
+ 
    // Start the device thread; spawns a new thread and executes
    // GarciaDriver::Main(), which contains the main loop for the driver.
***************
*** 241,255 ****
  GarciaDriver::Main()
  {
-   puts("Setting up Garcia driver");
-   mGarcia = new acpRobot("garcia", mConfigPath);
- 
-   puts("waiting for garcia");
-   while (!mGarcia.isActive())
-   {
-     puts("still waiting");
-     nanosleep(&NSLEEP_TIME, NULL);
-   }
-   puts("Garcia driver ready");
- 
  
    // The main loop; interact with the device here
--- 334,337 ----
***************
*** 282,294 ****
    assert(data);
  
!   if(Message::MatchMessage(hdr, PLAYER_MSGTYPE_DATA,
!                            PLAYER_PTZ_CMD_STATE, mPos2dAddr))
    {
!     assert(hdr->size == sizeof(player_position2d_cmd_t));
!     ProcessPos2dCommand(hdr, *reinterpret_cast<player_position2d_cmd_t 
*>(data));
      return(0);
    }
!   else if(Message::MatchMessage(hdr, PLAYER_MSGTYPE_DATA,
!                                 PLAYER_SPEECH_CMD_STATE, mSpeechAddr))
    {
      assert(hdr->size == sizeof(player_speech_cmd_t));
--- 364,383 ----
    assert(data);
  
!   if(Message::MatchMessage(hdr, PLAYER_MSGTYPE_CMD,
!                            PLAYER_POSITION2D_CMD_POS, mPos2dAddr))
    {
!     assert(hdr->size == sizeof(player_position2d_cmd_pos_t));
!     ProcessPos2dPosCmd(hdr, *reinterpret_cast<player_position2d_cmd_pos_t 
*>(data));
      return(0);
    }
!   if(Message::MatchMessage(hdr, PLAYER_MSGTYPE_CMD,
!                            PLAYER_POSITION2D_CMD_VEL, mPos2dAddr))
!   {
!     assert(hdr->size == sizeof(player_position2d_cmd_vel_t));
!     ProcessPos2dVelCmd(hdr, *reinterpret_cast<player_position2d_cmd_vel_t 
*>(data));
!     return(0);
!   }
!   else if(Message::MatchMessage(hdr, PLAYER_MSGTYPE_CMD,
!                                 PLAYER_SPEECH_CMD_SAY, mSpeechAddr))
    {
      assert(hdr->size == sizeof(player_speech_cmd_t));
***************
*** 297,301 ****
    }
    else if(Message::MatchMessage(hdr, PLAYER_MSGTYPE_DATA,
!                                 PLAYER_DIO_CMD_STATE, mDioAddr))
    {
      assert(hdr->size == sizeof(player_dio_cmd_t));
--- 386,390 ----
    }
    else if(Message::MatchMessage(hdr, PLAYER_MSGTYPE_DATA,
!                                 PLAYER_DIO_CMD_VALUES, mDioAddr))
    {
      assert(hdr->size == sizeof(player_dio_cmd_t));
***************
*** 303,306 ****
--- 392,407 ----
      return(0);
    }
+   else if(Message::MatchMessage(hdr, PLAYER_MSGTYPE_REQ,
+                                 PLAYER_POSITION2D_REQ_GET_GEOM, mPos2dAddr))
+   {
+     ProcessPos2dGeomReq(hdr);
+     return(0);
+   }
+   else if(Message::MatchMessage(hdr, PLAYER_MSGTYPE_REQ,
+                                 PLAYER_IR_POSE, mIrAddr))
+   {
+     ProcessIrPoseReq(hdr);
+     return(0);
+   }
    else
    {
***************
*** 312,319 ****
  
  void
! GarciaDriver::ProcessPos2dCommand(player_msghdr_t* hdr,
!                                   player_position2d_cmd_t &data)
  {
  
  }
  
--- 413,492 ----
  
  void
! GarciaDriver::ProcessPos2dPosCmd(player_msghdr_t* hdr,
!                                  player_position2d_cmd_pos_t &data)
  {
+   printf("Position commands currently not implemented\n");
+ 
+ /*
+   // this code could be used to implement the position control,
+   // but it will need to be modified
  
+   double rho(0),alpha(0),beta(0);
+   double delta_x(0),delta_y(0);
+   double v, omega;
+   // To be locally exponentially stable:
+   //  k_rho  > 0
+   //  k_beta < 0
+   //  k_alpha-k_rho > 0
+ 
+   delta_x = x-mPosX;
+   delta_y = y-mPosY;
+ 
+   // If we're within 1 cm, stop (for now)
+   if ((fabs(delta_x) > mTranslateDeadzone)||
+       (fabs(delta_y) > mTranslateDeadzone)||
+       (fabs(mPosTheta-theta) > mRotateDeadzone))
+   {
+     rho   = sqrt(pow(delta_x,2) + pow(delta_y,2));
+ 
+     if (fabs(atan2(delta_y, delta_x) - mPosTheta) < M_PI/2)
+     {
+ 
+       alpha = atan2(delta_y,delta_x) - mPosTheta;
+       alpha = fmod(alpha, M_PI_2); // M_PI/2 == M_PI_2
+ 
+       beta  = -fmod(alpha,M_PI) - mPosTheta + theta;
+       beta  = fmod(beta, M_PI);
+ 
+       v     = mKRho * rho;
+       omega = mKAlpha * alpha + mKBeta*beta;
+     }
+     else
+     {
+       alpha = atan2(-delta_y,-delta_x) - mPosTheta;
+       alpha = fmod(alpha, M_PI_2); // M_PI/2 == M_PI_2
+ 
+       beta  = -alpha - mPosTheta + theta;
+       beta  = fmod(beta, M_PI);
+ 
+       v     = -mKRho * rho;
+       omega = mKAlpha * alpha + mKBeta*beta;
+     }
+ 
+     SetTargetVelocity(v, omega);
+   }
+   else
+     SetTargetVelocity(0,0);
+ */
+ 
+ }
+ 
+ void
+ GarciaDriver::ProcessPos2dVelCmd(player_msghdr_t* hdr,
+                                  player_position2d_cmd_vel_t &data)
+ {
+   double v(data.vel.px);
+   double omega(data.vel.pa);
+ 
+   acpValue vl(static_cast<float>(v - mWheelBase*omega/2.0));
+   acpValue vr(static_cast<float>(v + mWheelBase*omega/2.0));
+ 
+   mGarcia->setNamedValue("damped-speed-left", &vl);
+   mGarcia->setNamedValue("damped-speed-right", &vr);
+ 
+   // do we have to do this each time, or only once?
+   acpObject* behavior;
+   behavior = mGarcia->createNamedBehavior("null", "vel");
+   mGarcia->queueBehavior(behavior);
  }
  
***************
*** 322,326 ****
--- 495,510 ----
                                     player_speech_cmd_t &data)
  {
+   // todo, there is currently a problem if we receive messages too quickly
+   cout << data.string << endl;
+ 
+   acpValue phrase(data.string);
+   acpObject* behavior;
  
+   behavior = mGarcia->createNamedBehavior("say", data.string);
+   behavior->setNamedValue("phrase", &phrase);
+   behavior->setNamedValue("speed", &mSpeed);
+   behavior->setNamedValue("pitch", &mPitch);
+   behavior->setNamedValue("volume", &mVolume);
+   mGarcia->queueBehavior(behavior);
  }
  
***************
*** 329,332 ****
--- 513,554 ----
                                  player_dio_cmd_t &data)
  {
+   PLAYER_WARN("Garcia driver currently doesn't support DIO commands");
+ }
+ 
+ void
+ GarciaDriver::ProcessPos2dGeomReq(player_msghdr_t* hdr)
+ {
+   player_position2d_geom_t geom;
+ 
+   geom.pose.px = 0.03; // [m]
+   geom.pose.py = 0.00; // [m]
+   geom.pose.pa = 0;    // [rad]
+   geom.size.sl = mLength;  // [m]
+   geom.size.sw = mWidth;  // [m]
+ 
+   Publish(mPos2dAddr, NULL,
+           PLAYER_MSGTYPE_RESP_ACK,
+           PLAYER_POSITION2D_REQ_GET_GEOM,
+           &geom, sizeof(geom), NULL);
+ }
+ 
+ void
+ GarciaDriver::ProcessIrPoseReq(player_msghdr_t* hdr)
+ {
+   player_pose_t poses[6] = {{ 0.105, 0.045, M_PI/6}, //   front-left
+                             { 0.105,-0.045,-M_PI/6}, //   front-right
+                             { 0.080, 0.020, M_PI_2}, //   side-left
+                             { 0.080,-0.020,-M_PI_2}, //   side-right
+                             {-0.050, 0.070, M_PI},   //   rear-left
+                             {-0.050,-0.070,-M_PI}};  //   rear-right
+ 
+   player_ir_pose_t pose;
+   pose.poses_count = 6;
+   memcpy(pose.poses, poses, 6*sizeof(player_pose_t));
+ 
+   Publish(mIrAddr, NULL,
+           PLAYER_MSGTYPE_RESP_ACK,
+           PLAYER_IR_POSE,
+           &pose, sizeof(pose), NULL);
  
  }
***************
*** 335,353 ****
  GarciaDriver::RefreshData()
  {
    Publish(mPos2dAddr, NULL,
            PLAYER_MSGTYPE_DATA, PLAYER_POSITION2D_DATA_STATE,
!           reinterpret_cast<void*>(&mPos2dData), size, NULL);
  
    Publish(mIrAddr, NULL,
!           PLAYER_MSGTYPE_DATA, PLAYER_IR_DATA_STATE,
            reinterpret_cast<void*>(&mIrData), sizeof(mIrData), NULL);
  
!   Publish(mSpeechAddr, NULL,
!           PLAYER_MSGTYPE_DATA, PLAYER_SPEECH_DATA_STATE,
!           reinterpret_cast<void*>(&mSpeechData), sizeof(mSpeechData), NULL);
  
    Publish(mDioAddr, NULL,
!           PLAYER_MSGTYPE_DATA, PLAYER_DIO_DATA_STATE,
            reinterpret_cast<void*>(&mDioData), sizeof(mDioData), NULL);
  
  }
--- 557,603 ----
  GarciaDriver::RefreshData()
  {
+   // how do we update these?
+   mPos2dData.pos.px  = 0.0;
+   mPos2dData.pos.py  = 0.0;
+   mPos2dData.pos.pa  = 0.0;
+ 
+   mPos2dData.vel.px  = 0.0;
+   mPos2dData.vel.py  = 0.0;
+   mPos2dData.vel.pa  = 0.0;
+ 
    Publish(mPos2dAddr, NULL,
            PLAYER_MSGTYPE_DATA, PLAYER_POSITION2D_DATA_STATE,
!           reinterpret_cast<void*>(&mPos2dData), sizeof(mPos2dData), NULL);
! 
!   // update the IR data
!   mIrData.voltages_count = 0;
!   mIrData.ranges_count = 6;
! 
!   mIrData.ranges[0] = 
mGarcia->getNamedValue("front-ranger-left")->getFloatVal();
!   mIrData.ranges[1] = 
mGarcia->getNamedValue("front-ranger-right")->getFloatVal();
!   mIrData.ranges[2] = 
mGarcia->getNamedValue("side-ranger-left")->getFloatVal();
!   mIrData.ranges[3] = 
mGarcia->getNamedValue("side-ranger-right")->getFloatVal();
!   mIrData.ranges[4] = 
mGarcia->getNamedValue("rear-ranger-left")->getFloatVal();
!   mIrData.ranges[5] = 
mGarcia->getNamedValue("rear-ranger-right")->getFloatVal();
  
    Publish(mIrAddr, NULL,
!           PLAYER_MSGTYPE_DATA, PLAYER_IR_DATA_RANGES,
            reinterpret_cast<void*>(&mIrData), sizeof(mIrData), NULL);
  
!   // do we currently have a dio device?
!   static int dio_test = 0;
!   mDioData.count = 16;
!   mDioData.digin = ++dio_test;
  
    Publish(mDioAddr, NULL,
!           PLAYER_MSGTYPE_DATA, PLAYER_DIO_DATA_VALUES,
            reinterpret_cast<void*>(&mDioData), sizeof(mDioData), NULL);
  
+   mPowerData.valid = PLAYER_POWER_MASK_VOLTS | PLAYER_POWER_MASK_PERCENT;
+   mPowerData.volts = mGarcia->getNamedValue("battery-voltage")->getFloatVal();
+   mPowerData.percent = mGarcia->getNamedValue("battery-level")->getFloatVal();
+ 
+   Publish(mPowerAddr, NULL,
+           PLAYER_MSGTYPE_DATA, PLAYER_POWER_DATA_STATE,
+           reinterpret_cast<void*>(&mPowerData), sizeof(mPowerData), NULL);
  }



_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit

Reply via email to