本文整理汇总了C++中RecvMsgEvent类的典型用法代码示例。如果您正苦于以下问题:C++ RecvMsgEvent类的具体用法?C++ RecvMsgEvent怎么用?C++ RecvMsgEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了RecvMsgEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onRecvMsg
void RobotController::onRecvMsg(RecvMsgEvent &evt)
{
std::string sender = evt.getSender();
// 送信者がゴミ認識サービスの場合
char *all_msg = (char*)evt.getMsg();
std::string msg;
msg= evt.getMsg();
if(msg == "start" && m_state ==0)
{
m_state = 1; // initial settings
}
else if(msg == "kitchen" && m_state ==0)
{
m_state = 10; // move to the kitchen
}
else if(msg == "lobby" && m_state ==0)
{
m_state = 20; // move to the lobby
}
else if(msg == "bed room" && m_state ==0)
{
m_state = 30; // move to the bed room
}
else
{
broadcastMsgToSrv("Task finished\n");
}
}
示例2: onRecvMsg
void RobotController::onRecvMsg(RecvMsgEvent &evt)
{
std::string sender = evt.getSender();
std::string msg;
msg= evt.getMsg();
std::stringstream ss;
ss << msg;
std::string header;
ss >> header;
if (msg == "Task_start" && m_state == 0)
{
m_state = 10;
Kinect_data_flag = false;
Record_Postures.clear();
}
if (msg == "Task_end")
{
initialize();
}
if ( header == "KINECT_DATA_Sensor" && Kinect_data_flag == true)
{
Record_Kinect_Data(msg);
}
}
示例3: onRecvMsg
void MyController::onRecvMsg(RecvMsgEvent &evt)
{
// SimObj *stick = getObj("robot_test");
SimObj *stick = getObj("ArrowStick");
char *all_msg = (char*)evt.getMsg();
// std::string msg;
msg= evt.getMsg();
LOG_MSG((msg.c_str()));
char xPosStr[10]=" ";
char yPosStr[10]=" ";
int result=0;
result = sscanf(msg.c_str(), "%[^','],%[^',']", xPosStr, yPosStr );
xPos = atof(xPosStr);
yPos = atof(yPosStr);
// LOG_MSG((" Position Received by Controller : %f %f ", xPos, yPos));
//std::cout <<"xPos is" << xPos <<std::endl;
messageCount++;
std::cout << "The received mesage count is" << messageCount <<std::endl;
// stick->setPosition(pos.x() + xPos, pos.y(), pos.z() + yPos);
}
示例4: onRecvMsg
void RobotController::onRecvMsg(RecvMsgEvent &evt)
{
std::string sender = evt.getSender();
// 送信者がゴミ認識サービスの場合
char *all_msg = (char*)evt.getMsg();
std::string msg;
msg= evt.getMsg();
if(msg == "go" && m_state ==20)
{
m_state = 0;
}
else if(msg == "take" && m_state == 7)
{
printf("Kinect is started on object\n");
m_pointedObject = getPointedObjectName(m_avatar);
m_state = 8;
}
else if(msg == "put" && m_state == 16)
{
printf("Kinect is started on trash \n");
m_pointedtrash = getPointedTrashName(m_avatar);
m_state = 17;
}
else
{
printf("Message is not accepted\n");
}
}
示例5: onRecvMsg
void KinectService::onRecvMsg(RecvMsgEvent &evt) {
std::string sender = evt.getSender();
std::string msg = evt.getMsg();
int strPos1 = 0;
int strPos2;
int strPos3;
std::string headss;
std::string ss = msg;
strPos2 = ss.find("_", strPos1);
headss.assign(ss, strPos1, strPos2-strPos1);
if (headss == "Send") {
Folder = "Motion_Data/";
// Contol of body movement by KINECT
File_ID = "";
strPos3 = ss.find(".", strPos2+1);
File_ID.assign(ss, strPos2+1, strPos3);
File_ID += "dat";
Folder += File_ID;
std::cout << "The File path " << Folder << std::endl;
}
if (msg == "Start_motion" && sender == "moderator_0" )
{
in_stream_motion.open(Folder.c_str());
std::string previousLine = "";
while(getline(in_stream_motion,line)) // To get you all the lines.
{
list_motion.push_back(line);
}
in_stream_motion.close();
Data_Size = 0;
Start_motion = true;
}
if (msg == "Task_start" && sender == "moderator_0")
{
Data_Size = 0;
Start_t = clock();
list_motion.clear();
Send_Data = false;
}
if (msg == "Get_Data" && sender == "robot_000")
{
Send_Data = true;
}
if (msg == "Data_Off" && sender == "robot_000")
{
Send_Data = false;
}
}
示例6: onRecvMsg
void MyController::onRecvMsg(RecvMsgEvent &evt) {
//取得したメッセージを表示します
string msg = evt.getMsg();
//LOG_MSG(("msg : %s", msg.c_str()));
SimObj *my = getObj(myname());
if(strstr(msg.c_str()," "))
{
// phi theta に分ける
int n = 0;
n = msg.find(" ");
string phi_s = msg.substr(0,n);
string theta_s = msg.substr(n+1);
double phi = atof(theta_s.c_str());
double theta = atof(phi_s.c_str());
// 目玉関節を回転させる
my->setJointAngle("LEYE_JOINT1",DEG2RAD(phi));
my->setJointAngle("REYE_JOINT1",DEG2RAD(phi));
my->setJointAngle("LEYE_JOINT0",DEG2RAD(theta));
my->setJointAngle("REYE_JOINT0",DEG2RAD(theta));
}
}
示例7: onRecvMsg
void MyController::onRecvMsg(RecvMsgEvent &evt)
{
string msg = evt.getMsg();
if (msg == "point1"){
start = true;
}
}
示例8: onRecvMsg
void MyController::onRecvMsg(RecvMsgEvent &evt)
{
std::string msg = evt.getMsg();
if(msg == "Task_start"){
if(trials==0){
m_state = 100;
}
else{
m_state = 1100;
}
broadcastMsg("get message: Task_start");
}
else if(msg == "Task_end"){
m_my->setWheelVelocity(0.0, 0.0);
m_state = 0;
broadcastMsg("get message: Task_end");
trials++;
}
else if(msg == "Time_over"){
m_my->setWheelVelocity(0.0, 0.0);
m_state = 0;
}
/*else if(m_state == 207 && msg == "leave the elevator"){
broadcastMsg("get message: leave the elevator");
m_state = 208;
}*/
}
示例9: getObj
void AvatarControllerByKinectV2::onRecvMsg(RecvMsgEvent &evt)
{
try
{
std::string allMsg = evt.getMsg();
// std::cout << "msg:" << allMsg << std::endl;
// Decode message to sensor data of kinect v2.
std::map<std::string, std::vector<std::string> > sensorDataMap = KinectV2SensorData::decodeSensorData(allMsg);
if (sensorDataMap.find(MSG_KEY_DEV_TYPE) == sensorDataMap.end()){ return; }
if(sensorDataMap[MSG_KEY_DEV_TYPE][0] !=this->kinectV2DeviceManager.deviceType ){ return; }
if(sensorDataMap[MSG_KEY_DEV_UNIQUE_ID][0]!=this->kinectV2DeviceManager.deviceUniqueID){ return; }
KinectV2SensorData sensorData;
sensorData.setSensorData(sensorDataMap);
ManNiiPosture posture = KinectV2DeviceManager::convertSensorData2ManNiiPosture(sensorData);
// Set SIGVerse quaternions and positions
SimObj *obj = getObj(myname());
this->kinectV2DeviceManager.setRootPosition(obj, sensorData.rootPosition);
KinectV2DeviceManager::setJointQuaternions2ManNii(obj, posture, sensorData);
}
catch(SimObj::Exception &err)
{
LOG_MSG(("Exception: %s", err.msg()));
}
catch(...)
{
std::cout << "some error occurred." << std::endl;
}
}
示例10: onRecvMsg
//メッセージ受信時に呼び出される関数
void RobotController::onRecvMsg(RecvMsgEvent &evt)
{
static int iImage = 0;
//取得したメッセージを表示します
std::string msg = evt.getMsg();
LOG_MSG(("msg : %s", msg.c_str()));
}
示例11: onRecvMsg
void UserController::onRecvMsg(RecvMsgEvent &evt)
{
std::string sender = evt.getSender();
std::string msg = evt.getMsg();
//自分自身の取得
SimObj *my = getObj(myname());
if(msg == "Task_start" && sender == "moderator_0" && cycle < NUMBER_OF_REPETITION && Mission_complete == false) {
parseFile("command.txt");
message = ":"+ rooms[cycle] +";"+ objects[cycle]+".";
brodcast_msg = "Go to the "+ rooms[cycle] +", grasp the "+ objects[cycle]+" and come back here";
choice_movement(rooms[cycle]);
//broadcastMsgToSrv(brodcast_msg);
//sendMsg("moderator_0","init_time");
//broadcastMsg(message);
LOG_MSG((brodcast_msg.c_str()));
//LOG_MSG(("%s: %s",sender.c_str(), brodcast_msg.c_str()));
sendMsg("robot_000",brodcast_msg);
sendMsg("moderator_0",brodcast_msg);
sendMsg("SIGViewer",brodcast_msg);
// m_state = 0;
//broadcastMsg(brodcast_msg);
cycle = cycle+1;
}
if(msg == "Task_finished" && sender == "robot_000" && Mission_complete == false )
{
choice_movement("finish");
}
if(msg == "Task_end" && sender == "moderator_0" && Mission_complete == false ) {
sendMsg("moderator_0","init_time");
choice_movement("finish");
}
if(msg == "Mission_complete" && sender == "moderator_0" && Mission_complete == false ) {
Mission_complete = true;
choice_movement("finish");
}
}
示例12: onRecvMsg
void MyController::onRecvMsg(RecvMsgEvent &evt) {
std::string msg = evt.getMsg();
if (msg == "Task_start"){
sentMsg = false;
flag1 = false;
flag2 = false;
}
}
示例13: onRecvMsg
void WheelControllerByMyo::onRecvMsg(RecvMsgEvent &evt)
{
const std::string allMsg = evt.getMsg();
// std::cout << allMsg << std::endl;
std::map<std::string, std::vector<std::string> > sensorDataMap = MyoSensorData::decodeSensorData(allMsg);
if (sensorDataMap.find(MSG_KEY_DEV_TYPE) == sensorDataMap.end()){ return; }
if(sensorDataMap[MSG_KEY_DEV_TYPE][0] !=this->myoDeviceManager.deviceType ){ return; }
if(sensorDataMap[MSG_KEY_DEV_UNIQUE_ID][0]!=this->myoDeviceManager.deviceUniqueID){ return; }
MyoSensorData sensorData;
sensorData.setSensorData(sensorDataMap);
// std::cout << "roll=" << sensorData.roll << ",pitch=" << sensorData.pitch << ",yaw=" << sensorData.yaw << ",pose=" << sensorData.poseStr << std::endl;
// std::cout << "emg1=" << sensorData.emgData[0] << ",emg2=" << sensorData.emgData[1] << ", emg3=" << sensorData.emgData[2] << std::endl;
SimObj *obj = getObj(myname());
float vel = 0.0;
for(int i=0; i<MyoSensorData::EMG_SENSOR_NUM; i++)
{
vel += std::abs(sensorData.emgData[i]);
}
double rvel=0.0, lvel=0.0;
// Turn left.
if(sensorData.poseStr==MyoSensorData::mapPoseType2Str.at(MyoSensorData::WaveIn))
{
rvel = 3.0*vel;
lvel = 0.05*vel;
}
// Turn right.
if(sensorData.poseStr==MyoSensorData::mapPoseType2Str.at(MyoSensorData::WaveOut))
{
rvel = 0.05*vel;
lvel = 3.0*vel;
}
// Brake.
if(sensorData.poseStr==MyoSensorData::mapPoseType2Str.at(MyoSensorData::Fist))
{
rvel = -3.0*vel;
lvel = -3.0*vel;
}
// std::cout << "rvel=" << rvel << ",lvel=" << lvel << std::endl;
obj->setJointVelocity("JOINT_RWHEEL", rvel, 500.0);
obj->setJointVelocity("JOINT_LWHEEL", lvel, 500.0);
}
示例14: onRecvMsg
void MyController::onRecvMsg(RecvMsgEvent &evt)
{
string msg = evt.getMsg();
if(msg == "check1"){
check1 = true;
}else if(msg == "elevator"){
elevator = true;
}else if(msg == "check3"){
check3 = true;
}
}
示例15: onRecvMsg
void MyController::onRecvMsg(RecvMsgEvent &evt)
{
string msg = evt.getMsg();
if(msg == "walk"){
start = true;
}
if(msg == "Task_start"){
start = false;
my->setPosition(initPos);
count = 0;
}
}