summer.cpp
来自「一个语言识别引擎」· C++ 代码 · 共 33 行
CPP
33 行
// -*- mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*-
#include <yarp/os/all.h>
#include <iostream>
using namespace std;
using namespace yarp::os;
int main(int argc, char *argv) {
Network::init();
BufferedPort<Bottle> port;
port.open("/summer");
while (true) {
cout << "waiting for input" << endl;
Bottle *input = port.read();
if (input!=NULL) {
cout << "got " << input->toString().c_str() << endl;
double total = 0;
for (int i=0; i<input->size(); i++) {
total += input->get(i).asDouble();
}
Bottle& output = port.prepare();
output.clear();
output.addString("total");
output.addDouble(total);
cout << "writing " << output.toString().c_str() << endl;
port.write();
}
}
Network::fini();
return 0;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?