コード例 #1
0
/**
   Like most memory stuff this won't work across DLL's in windows,
   it should work fine in linux or with static library files in windows.
**/
AREXPORT std::string ArRobotConfigPacketReader::buildString(void) const
{
  std::string ret;

  char line[32000];
  sprintf(line, "General information:\n");
  ret += line;
  sprintf(line, "Robot is type '%s' subtype '%s'\n",
	     getType(), getSubType());
  ret += line;
  sprintf(line, "serial number '%s' name '%s'\n", 
	     getSerialNumber(), getName());
  ret += line;
  sprintf(line, "Intrinsic properties and unsettable maxes:\n");
  ret += line;
  sprintf(line, "RotVelTop %d RotAccelTop %d\n", 
	     getRotVelTop(), getRotAccelTop());
  ret += line;
  sprintf(line, "TransVelTop %d TransAccelTop %d\n", 
	     getTransVelTop(), getTransAccelTop());
  ret += line;
  sprintf(line, "PWMMax %d ResetBaud %s\n", getPwmMax(),
	     ArUtil::convertBool(getResetBaud()));
  ret += line;
  sprintf(line, "Current values:\n");
  ret += line;
  sprintf(line, "RotVelMax %d RotAccel %d RotDecel %d\n", 
	     getRotVelMax(), getRotAccel(), getRotDecel());
  ret += line;
  sprintf(line, "TransVelMax %d TransAccel %d TransDecel %d\n", 
	     getTransVelMax(), getTransAccel(), getTransDecel());
  ret += line;  
  sprintf(line, "Accessories:\n");
  ret += line;  
  sprintf(line, 
	     "Gripper %s FrontSonar %s RearSonar %s Charger %d Gyro %s\n", 
	     ArUtil::convertBool(getHasGripper()), 
	     ArUtil::convertBool(getFrontSonar()), 
	     ArUtil::convertBool(getRearSonar()), 
	     getHasCharger(),
	     ArUtil::convertBool(getHasGyro()));
  ret += line;  
  sprintf(line, "FrontBumps %d RearBumps %d\n", 
	     getFrontBumps(), getRearBumps());
  ret += line;  
  sprintf(line, "Settings:\n");
  ret += line;  
  sprintf(line, "SipCycle %d SonarCycle %d HostBaud %d Aux1Baud %d\n", getSipCycleTime(), getSonarCycle(), getHostBaud(), getAux1Baud());
  ret += line;  
  sprintf(line, "StallVal %d StallCount %d RevCount %d Watchdog %d\n",
	     getStallVal(), getStallCount(), getRevCount(), getWatchdog());
  ret += line;  
  sprintf(line, "JoyVel %d JoyRVel %d NormalMotorPackets %s\n", getJoyVel(), getJoyRotVel(), ArUtil::convertBool(getNormalMPacs()));
  ret += line;  
  sprintf(line, "PID Settings:\n");
  ret += line;  
  sprintf(line, "Rot kp %d kv %d ki %d\n", getRotKP(), getRotKV(),
	     getRotKI());
  ret += line;  
  sprintf(line, "Trans kp %d kv %d ki %d\n", getTransKP(), 
	     getTransKV(), getTransKI());
  ret += line;  
  sprintf(line, "DriftFactor %d\n", getDriftFactor());
  ret += line;  
  sprintf(line, "Aux2Baud setting %d, Aux3Baud setting %d\n", getAux2Baud(), getAux3Baud());
  ret += line;  
  sprintf(line, "TicksMM: %d\n", getTicksMM());
  ret += line;  
  sprintf(line, "Shutdown Voltage: %d\n", getShutdownVoltage());
  ret += line;  

  return ret;
}
コード例 #2
0
/**
   Like most memory stuff this won't work across DLL's in windows,
   it should work fine in linux or with static library files in windows.
**/
AREXPORT std::string ArRobotConfigPacketReader::buildString(void) const
{
  std::string ret;

  char line[32000];
  sprintf(line, "General information:\n");
  ret += line;
  sprintf(line, "Robot is type '%s' subtype '%s'\n",
	     getType(), getSubType());
  ret += line;
  sprintf(line, "serial number '%s' name '%s'\n", 
	     getSerialNumber(), getName());
  ret += line;
  sprintf(line, "firmware version '%s'\n",
	  getFirmwareVersion());
  ret += line;
  sprintf(line, "Intrinsic properties and unsettable maxes:\n");
  ret += line;
  sprintf(line, "TransVelTop %d TransAccelTop %d\n", 
	     getTransVelTop(), getTransAccelTop());
  ret += line;
  sprintf(line, "RotVelTop %d RotAccelTop %d\n", 
	     getRotVelTop(), getRotAccelTop());
  ret += line;
  if (myRobot->hasLatVel())
  {
    sprintf(line, "LatVelTop %d LatAccelTop %d\n", 
	    getLatVelTop(), getLatAccelTop());
    ret += line;
  }
  sprintf(line, "PWMMax %d ResetBaud %s\n", getPwmMax(),
	     ArUtil::convertBool(getResetBaud()));
  ret += line;
  sprintf(line, "Current values:\n");
  ret += line;
  sprintf(line, "TransVelMax %d TransAccel %d TransDecel %d\n", 
	     getTransVelMax(), getTransAccel(), getTransDecel());
  ret += line;  
  sprintf(line, "RotVelMax %d RotAccel %d RotDecel %d\n", 
	     getRotVelMax(), getRotAccel(), getRotDecel());
  ret += line;
  if (myRobot->hasLatVel())
  {
    sprintf(line, "LatVelMax %d LatAccel %d LatDecel %d\n", 
	    getLatVelMax(), getLatAccel(), getLatDecel());
    ret += line;  
  }
  sprintf(line, "Accessories:\n");
  ret += line;  
  sprintf(line, 
	  "Gripper %s FrontSonar %s RearSonar %s Charger %d GyroType %d\n", 
	  ArUtil::convertBool(getHasGripper()), 
	  ArUtil::convertBool(getFrontSonar()), 
	  ArUtil::convertBool(getRearSonar()), 
	  getHasCharger(),
	  getGyroType());
  ret += line;  
  sprintf(line, "FrontBumps %d RearBumps %d\n", 
	     getFrontBumps(), getRearBumps());
  ret += line;  
  sprintf(line, "Settings:\n");
  ret += line;  
  sprintf(line, "SipCycle %d SonarCycle %d HostBaud %d Aux1Baud %d\n", getSipCycleTime(), getSonarCycle(), getHostBaud(), getAux1Baud());
  ret += line;  
  sprintf(line, "StallVal %d StallCount %d RevCount %d Watchdog %d\n",
	     getStallVal(), getStallCount(), getRevCount(), getWatchdog());
  ret += line;  
  sprintf(line, "GyroRateLimit %d\n",
	  getGyroRateLimit());
  ret += line;  
  sprintf(line, "JoyVel %d JoyRVel %d NormalMotorPackets %s\n", getJoyVel(), getJoyRotVel(), ArUtil::convertBool(getNormalMPacs()));
  ret += line;  
  sprintf(line, "PID Settings:\n");
  ret += line;  
  sprintf(line, "Trans kp %d kv %d ki %d\n", getTransKP(), 
	     getTransKV(), getTransKI());
  ret += line;  
  sprintf(line, "Rot kp %d kv %d ki %d\n", getRotKP(), getRotKV(),
	     getRotKI());
  ret += line;  
  sprintf(line, "Other:\n");
  ret += line;  
  sprintf(line, "DriftFactor %d KinematicsDelay %d\n", getDriftFactor(),
	  getKinematicsDelay());
  ret += line;  
  sprintf(line, "Aux2Baud setting %d Aux3Baud setting %d\n", getAux2Baud(), getAux3Baud());
  ret += line;  
  sprintf(line, "PDBPort setting %d\n", getPDBPort());
  ret += line;  
  sprintf(line, "TicksMM %d GyroCW %d GyroCCW %d\n", getTicksMM(),
	  getGyroCW(), getGyroCCW());
  ret += line;  
  sprintf(line, "ShutdownVoltage %d PowerbotChargeTreshold %d\n", 
	  getShutdownVoltage(), getPowerbotChargeThreshold());
  ret += line;  

  char buf[128];
  int i, j;
  unsigned int value = getPowerBits();
  int bit;
  buf[0] = '\0';
  for (j = 0, bit = 1; j < 16; ++j, bit *= 2)
  {
    if (j == 8)
      sprintf(buf, "%s ", buf);
    if (value & bit)
      sprintf(buf, "%s%d", buf, 1);
    else
      sprintf(buf, "%s%d", buf, 0);
  }

  sprintf(line, "HighTempShutdown %d PowerBits %s\n",
	  getHighTemperatureShutdown(), buf);
  ret += line;  

  return ret;
}