当前位置: 首页>>代码示例>>C++>>正文


C++ ArNetPacket::finalizePacket方法代码示例

本文整理汇总了C++中ArNetPacket::finalizePacket方法的典型用法代码示例。如果您正苦于以下问题:C++ ArNetPacket::finalizePacket方法的具体用法?C++ ArNetPacket::finalizePacket怎么用?C++ ArNetPacket::finalizePacket使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ArNetPacket的用法示例。


在下文中一共展示了ArNetPacket::finalizePacket方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: laserRequest_and_odom

void laserRequest_and_odom(ArServerClient *client, ArNetPacket *packet)
{ 
  robot.lock();
  ArNetPacket sending;
  sending.empty();
  ArLaser* laser = robot.findLaser(1);
  if(!laser){
      printf("Could not connect to Laser... exiting\n");
      Aria::exit(1);}	
  laser->lockDevice();
  const std::list<ArSensorReading*> *sensorReadings = laser->getRawReadings(); // see ArRangeDevice interface doc
  sending.byte4ToBuf((ArTypes::Byte4)(sensorReadings->size()));
  for (std::list<ArSensorReading*>::const_iterator it2= sensorReadings->begin(); it2 != sensorReadings->end(); ++it2){
	ArSensorReading* laserRead =*it2;
        sending.byte4ToBuf((ArTypes::Byte4)(laserRead->getRange()));
	//printf("%i,%i:",laserRead->getRange(),laserRead->getIgnoreThisReading());
  }
  sending.byte4ToBuf((ArTypes::Byte4)(robot.getX()));
  sending.byte4ToBuf((ArTypes::Byte4)(robot.getY()));
  sending.byte4ToBuf((ArTypes::Byte4)(robot.getTh()));
  sending.byte4ToBuf((ArTypes::Byte4)(robot.getVel()));
  sending.byte4ToBuf((ArTypes::Byte4)(robot.getRotVel()));
  //printf("%1f,%1f,%1f\n",robot.getX(),robot.getY(),robot.getTh());
  laser->unlockDevice();
  robot.unlock();
  sending.finalizePacket();
  //sending.printHex();
  client->sendPacketTcp(&sending);
}
开发者ID:sendtooscar,项目名称:ariaClientDriver,代码行数:29,代码来源:serverDemo2.cpp

示例2: requestOnceUdp

AREXPORT bool ArCentralForwarder::requestOnceUdp(const char *name,
        ArNetPacket *packet,
        bool quiet)
{
    if (myClient != NULL)
    {
        unsigned int commandNum = myClient->findCommandFromName(name);
        if (commandNum == 0)
        {
            if (!quiet)
                ArLog::log(ArLog::Normal,
                           "ArCentralForwarder::%s::requestOnce: Can't find commandNum for %s",
                           getRobotName(), name);
            return false;
        }
        //return myClient->requestOnceUdp(name, packet, quiet);
        if (packet != NULL)
        {
            packet->setCommand(commandNum);
            packet->finalizePacket();
            return internalRequestOnce(NULL, packet, false);
        }
        else
        {
            ArNetPacket tempPacket;
            tempPacket.setCommand(commandNum);
            tempPacket.finalizePacket();
            return internalRequestOnce(NULL, &tempPacket, false);
        }
    }
    else
    {
        if (!quiet)
            ArLog::log(ArLog::Normal,
                       "ArCentralForwarder::%s::requestOnce: Tried to call (for %s) while client was still NULL",
                       getRobotName(), name);
        return false;
    }
}
开发者ID:PipFall2015,项目名称:Ottos-Cloud,代码行数:39,代码来源:ArCentralForwarder.cpp

示例3: packetHandler

/// The packet handler for starting/stopping scans from the lcd
AREXPORT bool ArServerHandlerMapping::packetHandler(ArRobotPacket *packet)
{
  // we return these as processed to help out the ArLaserLogger class
  if (packet->getID() == 0x96)
    return true;

  if (packet->getID() != 0x97)
    return false;

  myRobot->unlock();
  char argument = packet->bufToByte();
  if (argument == 1)
  {
    // see if we're already mapping
    if (myLaserLogger != NULL)
    {
      ArLog::log(ArLog::Normal, 
		 "ArServerHandlerMapping::packetHandler: Start scan requested when already mapping");
    }
    else
    {
      // build a name
      time_t now;
      struct tm nowStruct;
      now = time(NULL);
      char buf[1024];

	  if (ArUtil::localtime(&now, &nowStruct))
      {
	sprintf(buf, "%02d%02d%02d_%02d%02d%02d", 
		(nowStruct.tm_year%100), nowStruct.tm_mon+1, nowStruct.tm_mday, 
		nowStruct.tm_hour, nowStruct.tm_min, nowStruct.tm_sec);
      }
      else
      {
	ArLog::log(ArLog::Normal, 
		   "ArServerHandlerMapping::packetHandler: Could not make good packet name (error getting time), so just naming it \"lcd\"");
	sprintf(buf, "lcd");
      }

      ArLog::log(ArLog::Normal, "Starting scan '%s' from LCD", buf);
      ArNetPacket fakePacket;
      fakePacket.strToBuf(buf);
      fakePacket.finalizePacket();
      serverMappingStart(NULL, &fakePacket);
    }
  }
  else if (argument == 0)
  {
    if (myLaserLogger == NULL)
    {
      ArLog::log(ArLog::Normal, 
		 "ArServerHandlerMapping::packetHandler: Stop scan requested when not mapping");
    }
    else
    {
      ArLog::log(ArLog::Normal, "Stopping scan from LCD");
      serverMappingEnd(NULL, NULL);
    }
  }
  else
  {
    ArLog::log(ArLog::Normal, "ArServerHandlerMapping::packetHandler: Unknown scan argument %d", argument);
  }
  myRobot->lock();
  return true;
}
开发者ID:PipFall2015,项目名称:Ottos-Cloud,代码行数:68,代码来源:ArServerHandlerMapping.cpp


注:本文中的ArNetPacket::finalizePacket方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。