本文整理汇总了C++中al::ALValue::isBinary方法的典型用法代码示例。如果您正苦于以下问题:C++ ALValue::isBinary方法的具体用法?C++ ALValue::isBinary怎么用?C++ ALValue::isBinary使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类al::ALValue
的用法示例。
在下文中一共展示了ALValue::isBinary方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: readSensors
/**
* The method reads all sensors. It also detects if the chest button was pressed
* for at least three seconds. In that case, it shuts down the robot.
*/
void readSensors()
{
// get new sensor values and copy them to the shared memory block
try
{
// copy sensor values into the shared memory block
int writingSensors = 0;
if(writingSensors == data->newestSensors)
++writingSensors;
if(writingSensors == data->readingSensors)
if(++writingSensors == data->newestSensors)
++writingSensors;
assert(writingSensors != data->newestSensors);
assert(writingSensors != data->readingSensors);
float* sensors = data->sensors[writingSensors];
for(int i = 0; i < lbhNumOfSensorIds; ++i)
sensors[i] = *sensorPtrs[i];
AL::ALValue value = memory->getData("GameCtrl/RoboCupGameControlData");
if(value.isBinary() && value.getSize() == sizeof(RoboCup::RoboCupGameControlData))
memcpy(&data->gameControlData[writingSensors], value, sizeof(RoboCup::RoboCupGameControlData));
data->newestSensors = writingSensors;
// detect shutdown request via chest-button
if(*sensorPtrs[chestButtonSensor] == 0.f)
startPressedTime = dcmTime;
else if(state != shuttingDown && startPressedTime && dcmTime - startPressedTime > 3000)
{
if(*sensorPtrs[rBumperRightSensor] != 0.f || *sensorPtrs[rBumperLeftSensor] != 0.f ||
*sensorPtrs[lBumperRightSensor] != 0.f || *sensorPtrs[lBumperLeftSensor] != 0.f)
(void) !system("( /home/nao/bin/bhumand stop && sudo shutdown -r now ) &");
else
(void) !system("( /home/nao/bin/bhumand stop && sudo shutdown -h now ) &");
state = preShuttingDown;
}
}
catch(AL::ALError& e)
{
fprintf(stderr, "libbhuman: %s\n", e.toString().c_str());
}
// raise the semaphore
if(sem != SEM_FAILED)
{
int sval;
if(sem_getvalue(sem, &sval) == 0)
{
if(sval < 1)
{
sem_post(sem);
frameDrops = 0;
}
else
{
if(frameDrops == 0)
fprintf(stderr, "libbhuman: dropped sensor data.\n");
++frameDrops;
}
}
}
}