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


C++ ActionEvent::time方法代码示例

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


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

示例1: onAction

double RobotController::onAction(ActionEvent &evt)
{

#if 1
	sendText(evt.time(), "Robot2", "hello!");
#else

	double distance = 10.0;
	sendText(evt.time(), NULL, "hello!", distance);
#endif
	return 3.0;
}
开发者ID:Aharobot,项目名称:SIGServer,代码行数:12,代码来源:SendText.cpp

示例2: onAction

double RobotController::onAction(ActionEvent &evt)
{
	LOG_MSG(("\ncurrent time : %f", evt.time()));

	static int cnt = 0;

	try {
		const char *name = myname();
		SimObj *obj = getObj(name);
		obj->dump();
		if (!obj->dynamics()) {

			double angle = 2*PI*cnt*0.01;

			double xx = 5*sin(angle);
			double yy = 0.5;
			double zz = 5*cos(angle);
		
			LOG_MSG(("pos (%f, %f, %f)", xx, yy, zz));
			obj->setPosition(xx, yy, zz);
			obj->setAxisAndAngle(0.0, 1.0, 0.0, angle);
		}
		obj->dump();

	} catch(SimObj::NoAttributeException &) {
		
	} catch(SimObj::AttributeReadOnlyException &) {
		
	} catch(SimObj::Exception &) {
		
	}
	cnt++;

	return 0.1;
}
开发者ID:Aharobot,项目名称:SIGServer,代码行数:35,代码来源:GoRound.cpp

示例3: onAction

double MyController::onAction(ActionEvent &evt) {  

  SimObj *obj = getObj(myname());  //obtaining handle to the agent  
  obj->setLinearVelocity(0,0,100); //apply the linear velocity 20[m/s] in Z axis  
  Vector3d currentVelocity;
  obj->getLinearVelocity(currentVelocity);
  
  if (myfile.is_open() && (evt.time() < 15) )
  {
  		myfile << currentVelocity.x() << " , "  <<  currentVelocity.z() << "\n" ;
  }
  if(evt.time() > 15)
  {
  	exit(0);
  }

  return 0.00001;    
      
}
开发者ID:raghavendrajain,项目名称:SenseiInvestigation,代码行数:19,代码来源:Controller.cpp

示例4: onAction

double MyController::onAction(ActionEvent &evt)
{  
  switch(m_state){

    // 初期状態
  case 0: {

    // ゴミがある場所と名前を取得します
    if(!this->recognizeTrash(m_tpos,m_tname)){

      // ゴミが見つからないので終了
      broadcastMsgToSrv("I cannot find trash");
      m_state = 8;
    }
    // ゴミが見つかった
    else{

      // ゴミの方向に回転をはじめる
      m_time = rotateTowardObj(m_tpos, m_vel, evt.time());
      m_state = 1;
    }
    break;
  }
    // ゴミの方向に回転中
  case 1: {

    // 回転終了
    if(evt.time() >= m_time){

      // 回転を止める
      m_my->setWheelVelocity(0.0, 0.0);

      // 関節の回転を始める
      // orig
      m_my->setJointVelocity("RARM_JOINT1", -m_jvel, 0.0);

      // 50°回転
      m_time = DEG2RAD(50) / m_jvel + evt.time();

      // ゴミを取りに関節を曲げる状態に移行します
      m_state = 2;
    }
    break;
  }
    // 関節を回転中
  case 2: {

    // 関節回転終了    
    if(evt.time() >= m_time){

      m_my->setJointVelocity("RARM_JOINT1", 0.0, 0.0);

      // graspしたいパーツを取得します
      CParts *parts = m_my->getParts("RARM_LINK7");
      
      // graspします
      parts->graspObj(m_tname);
      
      // ゴミ箱の位置を取得します
      SimObj *trashbox = getObj("trashbox_1");
      Vector3d pos;
      trashbox->getPosition(pos);
      
      // ゴミ箱の方向に移動を開始します
      m_time = rotateTowardObj(pos, m_vel, evt.time());      
      m_state = 3;
    }
    
    break;
  }
    // ゴミ箱の方向に回転中
  case 3: {

    // ゴミ箱到着
    if(evt.time() >= m_time){

      // ここではゴミ箱の名前 位置は知っているものとします
      SimObj *trashbox = getObj("trashbox_1");
      Vector3d pos;
      trashbox->getPosition(pos);

      // ゴミ箱の近くに移動します
      m_time = goToObj(pos, m_vel*4, 40.0, evt.time());
      m_state = 4;
    }
    break;
  }

    // ゴミを持ってゴミ箱に向かっている状態
  case 4: {

    // ゴミ箱に到着
    if(evt.time() >= m_time){
      m_my->setWheelVelocity(0.0, 0.0);

      // grasp中のパーツを取得します
      CParts *parts = m_my->getParts("RARM_LINK7");
      
      // releaseします
      parts->releaseObj();
//.........这里部分代码省略.........
开发者ID:bttung,项目名称:CleanUpRobotController,代码行数:101,代码来源:CleanUpRobot_origin.cpp

示例5: onAction

double MyController::onAction(ActionEvent &evt) {  

  int actionNumber = 2;
  int functionalFeature = 1;
  int targetType = 3;

  myfile << setprecision(2) << std::fixed;

  // handle of target and tool
  SimObj *target = getObj("box_004");
  SimObj *toolName = getObj("TShapeTool_004");


  if (evt.time() < 5.0)
  {
    // cout << "Time" << endl;
    cout << evt.time() << endl;

    toolName->getPosition(currentToolPos); // get the current tool position
    toolName->getRotation(finalToolRotation);
    toolName->getVelocity(finalToolVel);
    isToolAtRest   = checkEntityMotionStatus(toolName);  // checks whether the tool is moving by calculating its velocity

    target->getPosition(currentTargetPos);
    target->getRotation(finalTargetRotation);
    target->getVelocity(finalTargetVel);
    isTargetAtRest = checkEntityMotionStatus(target);    // checks whether the object is moving by calculating its velocity
    
  }

  if (evt.time() > 5.0)
  {
     insideTimer = false;
     counterOfAction ++ ; 
  }

  if(!insideTimer && counterOfAction == 1 )
  {
           myfile << actionNumber  << " , " << functionalFeature << " , " ;
           myfile << initToolRotation.qw() <<  " , " << initToolRotation.qx() <<  " , " << initToolRotation.qy() <<  " , " << initToolRotation.qz() << " , " ;
           myfile << initTargetRotation.qw() <<  " , " << initTargetRotation.qx() <<  " , " << initTargetRotation.qy() <<  " , " << initTargetRotation.qz() << " , " ;
           myfile << finalTargetRotation.qw() <<  " , " << finalTargetRotation.qx() <<  " , " << finalToolRotation.qy() <<  " , " << finalToolRotation.qz() << " , " ;
           myfile << initToolPos.x() << " , " << initToolPos.z() << " , " ;
           myfile << initTargetPos.x() << " , " << initTargetPos.z() << " , " ;
           myfile << forceOnTool_x  << " , " << forceOnTool_z << " , " ;
           myfile << appliedToolVel.x()  << " , " << appliedToolVel.z() << " , " ;
           myfile << toolVelAtHit.x() << " , " << toolVelAtHit.z() << " , " ;
           myfile << targetVelAtHit.x() << " , " << targetVelAtHit.z() << " , " ;
           myfile << currentToolPos.x() << " , " << currentToolPos.z() << " , " ;
           myfile << currentTargetPos.x() << " , " << currentTargetPos.z() << " , " ;
           myfile << finalToolVel.x() << " , " << finalToolVel.z() << " , " ;
           myfile << finalTargetVel.x() << " , " << finalTargetVel.z() << " , " ;
           myfile   << isToolAtRest <<  " , " << isTargetAtRest << " , " ;
           myfile << currentToolPos.x() -  initToolPos.x() << " , " << currentToolPos.z() - initToolPos.z() << " , " ;
           myfile << currentTargetPos.x() -  initTargetPos.x() << " , " << currentTargetPos.z() - initTargetPos.z();
           myfile << "\n"; 
           cout << "The simulation for " << actionNumber << " , " << functionalFeature << " has been recorded" << endl;
           // exit(0);
           flag = false;  
  }

      
  return 0.01;    

 }
开发者ID:raghavendrajain,项目名称:IROS2015,代码行数:65,代码来源:ControllerSample_21.cpp

示例6: onAction

double RobotController::onAction(ActionEvent &evt)
{
    switch(m_state){

  // 初期姿勢を設定 seting initial pose
  case 0: {
    //broadcastMsgToSrv("Let's start the clean up task\n");
    sendMsg("VoiceReco_Service","Let's start the clean up task\n");
    double angL1 =m_my->getJointAngle("LARM_JOINT1")*180.0/(PI);
    double angL4 =m_my->getJointAngle("LARM_JOINT4")*180.0/(PI);
    double angR1 =m_my->getJointAngle("RARM_JOINT1")*180.0/(PI);
    double angR4 =m_my->getJointAngle("RARM_JOINT4")*180.0/(PI);
    double thetaL1 = -20-angL1;
    double thetaL4 = -160-angL4;
    double thetaR1 = -20-angR1;
    double thetaR4 = -160-angR4;
    if(thetaL1<0) m_my->setJointVelocity("LARM_JOINT1", -m_jvel, 0.0);
    else m_my->setJointVelocity("LARM_JOINT1", m_jvel, 0.0);
    if(thetaL4<0) m_my->setJointVelocity("LARM_JOINT4", -m_jvel, 0.0);
    else m_my->setJointVelocity("LARM_JOINT4", m_jvel, 0.0);
    if(thetaR1<0) m_my->setJointVelocity("RARM_JOINT1", -m_jvel, 0.0);
    else m_my->setJointVelocity("RARM_JOINT1", m_jvel, 0.0);
    if(thetaR4<0) m_my->setJointVelocity("RARM_JOINT4", -m_jvel, 0.0);
    else m_my->setJointVelocity("RARM_JOINT4", m_jvel, 0.0);
    m_time_LA1 = DEG2RAD(abs(thetaL1))/ m_jvel + evt.time();
    m_time_LA4 = DEG2RAD(abs(thetaL4))/ m_jvel + evt.time();
    m_time_RA1 = DEG2RAD(abs(thetaR1))/ m_jvel + evt.time();
    m_time_RA4 = DEG2RAD(abs(thetaR4))/ m_jvel + evt.time();
    m_state = 1;
    break;
  }
  // 初期姿勢に移動 moving initial pose
  case 1: {
    if(evt.time() >= m_time_LA1) m_my->setJointVelocity("LARM_JOINT1", 0.0, 0.0);
    if(evt.time() >= m_time_LA4) m_my->setJointVelocity("LARM_JOINT4", 0.0, 0.0);
    if(evt.time() >= m_time_RA1) m_my->setJointVelocity("RARM_JOINT1", 0.0, 0.0);
    if(evt.time() >= m_time_RA4) m_my->setJointVelocity("RARM_JOINT4", 0.0, 0.0);
    if(evt.time() >= m_time_LA1 && evt.time() >= m_time_LA4
    && evt.time() >= m_time_RA1 && evt.time() >= m_time_RA4){
	// 位置Aの方向に回転を開始します setting position a for rotating
	//broadcastMsgToSrv("Moving to the table");
	m_time = rotateTowardObj(pos_a, m_vel, evt.time());
	m_state = 2;
    }
    break;
  }
  // 位置Aの方向に回転 rotating to position a
  case 2: {
    // 回転終了
    if(evt.time() >= m_time){
      m_my->setWheelVelocity(0.0, 0.0);
      // 位置Aに移動します setting position a for moving
      m_time = goToObj(pos_a, m_vel*4, 0.0, evt.time());
      m_state = 3;
    }
    break;
  }
  // 位置Aに移動 moving to position a
  case 3: {
    // 位置Aに到着
    if(evt.time() >= m_time){
      m_my->setWheelVelocity(0.0, 0.0);
      // 位置Bの方向に回転を開始します setting position b for rotating
      m_time = rotateTowardObj(pos_b, m_vel, evt.time());
      m_state = 4;
    }
    break;
  }
  // 位置Bの方向に回転 rotating to position b
  case 4: {
    // 回転終了
    if(evt.time() >= m_time){
      m_my->setWheelVelocity(0.0, 0.0);
      // 位置Bに移動します setting position b for moving
      m_time = goToObj(pos_b, m_vel*4, 0.0, evt.time());
      m_state = 5;
    }
    break;
  }
  // 位置Bに移動 moving to position b
  case 5: {
    // 位置Bに到着
    if(evt.time() >= m_time){
      m_my->setWheelVelocity(0.0, 0.0);
      // テーブルの方向に回転を開始します setting table position for rotating
      SimObj *table = getObj("table_0");
      Vector3d pos;
      table->getPosition(pos);
      m_time = rotateTowardObj(pos, m_vel, evt.time());
      m_state = 6;
    }
    break;
  }
  // テーブルの方向に回転 rotating to table
  case 6: {
    // 回転終了
    if(evt.time() >= m_time){
      m_my->setWheelVelocity(0.0, 0.0);
      // ゴミがある場所と名前を取得します
      // ゴミが見つからなかった
//.........这里部分代码省略.........
开发者ID:Aharobot,项目名称:samples,代码行数:101,代码来源:cleanUpRobot.cpp

示例7: onAction

double MyController::onAction(ActionEvent &evt)
{
	if(!checkService("RecogTrash")){
		m_srv == NULL;
	}
	
	if(m_srv == NULL){
		// ゴミ認識サービスが利用可能か調べる
		if(checkService("RecogTrash")){
			// ゴミ認識サービスに接続
			m_srv = connectToService("RecogTrash");
		}
	}


	//if(evt.time() < m_time) printf("state: %d \n", m_state);
	switch(m_state) {
		// 初期状態
		case 0: {
			if(m_srv == NULL){
				// ゴミ認識サービスが利用可能か調べる
				if(checkService("RecogTrash")){
					// ゴミ認識サービスに接続
					m_srv = connectToService("RecogTrash");
				}
			} else if(m_srv != NULL && m_executed == false){  
				//rotate toward upper
				m_my->setJointVelocity("LARM_JOINT4", -m_jvel, 0.0);
				m_my->setJointVelocity("RARM_JOINT4", -m_jvel, 0.0);
				// 50°回転
				m_time = DEG2RAD(ROTATE_ANG) / m_jvel + evt.time();
				m_state = 5;
				m_executed = false;			
			}
			break;
		}


		case 5: {
			if(evt.time() > m_time && m_executed == false) {
				//m_my->setJointVelocity("LARM_JOINT1", 0.0, 0.0);
				m_my->setJointVelocity("LARM_JOINT4", 0.0, 0.0);
				m_my->setJointVelocity("RARM_JOINT4", 0.0, 0.0);
				sendSceneInfo("Start");				
				//m_srv->sendMsgToSrv("Start");
				printf("Started! \n");
				m_executed = true;
			}
			break;
		}

		// 物体の方向が帰ってきた
		case 20: {
			// 送られた座標に回転する
			m_time = rotateTowardObj(nextPos, m_rotateVel, evt.time());
			//printf("debug %lf %lf \n", evt.time(), m_time);
			m_state = 21;
			m_executed = false;
			break;
		}
		
		case 21: {
			// ロボットが回転中
			//printf("debug %lf %lf \n", evt.time(), m_time);
			if(evt.time() > m_time && m_executed == false) {
				// 物体のある場所に到着したので、車輪と止め、関節を回転し始め、物体を拾う
				m_my->setWheelVelocity(0.0, 0.0);
				// 物体のある方向に回転した
				//printf("目的地の近くに移動します %lf %lf %lf \n", nextPos.x(), nextPos.y(), nextPos.z());	
				// 送られた座標に移動する
				m_time = goToObj(nextPos, m_vel*4, m_range, evt.time());
				//m_time = goToObj(nextPos, m_vel*4, 40, evt.time());
				m_state = 22;
				m_executed = false;
			}
			break;
		}

		case 22: {
			// 送られた座標に移動した
			if(evt.time() > m_time && m_executed == false) {
				m_my->setWheelVelocity(0.0, 0.0);
				printf("止める \n");
				Vector3d myPos;
				m_my->getPosition(myPos);
				double x = myPos.x();
				double z = myPos.z();
				double theta = 0;			// y方向の回転は無しと考える		
				char replyMsg[256];

				bool found = recognizeNearestTrash(m_tpos, m_tname);
				// ロボットのステートを更新
			
				if (found == true) {
					m_state = 500;				
					m_executed = false;		
					//printf("m_executed = false, state = 500 \n");		
				} else {
					//printf("Didnot found anything \n");		
					m_state = 10;
//.........这里部分代码省略.........
开发者ID:bttung,项目名称:CleanUpRobotController,代码行数:101,代码来源:CleanUpRobot1126_bak.cpp

示例8: onAction

double MyController::onAction(ActionEvent &evt)
{
	switch(m_state){
		// wait
		case 0:{
			break;
		}
		// 1st section
		case 100: {
			m_time = rotateTowardObj(Vector3d(-50,60,500),m_vel_rot,evt.time());
			m_state = 101;
			break;
		}
		case 101: {
			if(evt.time() >= m_time){
				m_my->setWheelVelocity(0.0, 0.0);
				m_time = goToObj(Vector3d(-50,60,500), m_vel, 1.0, evt.time());
				m_state = 102;
			}
			break;
		}
		case 102: {
			if(evt.time() >= m_time){
				m_my->setWheelVelocity(0.0, 0.0);
				m_time = goToObj(Vector3d(-50,60,575), m_vel, 1.0, evt.time());
				m_state = 103;
			}
			break;
		}
		case 103: {
			if(evt.time() >= m_time){
				m_my->setWheelVelocity(0.0, 0.0);
				m_time = rotateTowardObj(Vector3d(-450,60,575),m_vel_rot,evt.time());
				m_state = 104;
				break;
			}
		}
		case 104: {
			if(evt.time() >= m_time){
				m_my->setWheelVelocity(0.0, 0.0);
				m_time = goToObj(Vector3d(-450,60,575), m_vel, 1.0, evt.time());
				m_state = 105;
			}
			break;
		}
		case 105: {
			if(evt.time() >= m_time){
				m_my->setWheelVelocity(0.0, 0.0);
				// wait for a walking person
				usleep(3200000);
				m_state = 106;
			}
			break;
		}
		case 106: {
			m_time = rotateTowardObj(Vector3d(-525,60,575),m_vel_rot,evt.time());
			m_state = 107;
			break;
		}
		case 107: {
			if(evt.time() >= m_time){
				m_my->setWheelVelocity(0.0, 0.0);
				m_time = goToObj(Vector3d(-525,60,575), m_vel, 1.0, evt.time());
				m_state = 200;
			}
			break;
		}
		// 2nd section
		case 200: {
			if(evt.time() >= m_time){
				m_my->setWheelVelocity(0.0, 0.0);
				m_time = rotateTowardObj(Vector3d(-800,60,575),m_vel_rot,evt.time());
				m_state = 201;
			}
			break;
		}
		case 201: {
			if(evt.time() >= m_time){
				m_my->setWheelVelocity(0.0, 0.0);
				m_time = goToObj(Vector3d(-800,60,575), m_vel, 1.0, evt.time());
				m_state = 202;
			}
			break;
		}
		case 202: {
			if(evt.time() >= m_time){
				m_my->setWheelVelocity(0.0, 0.0);
				m_time = rotateTowardObj(Vector3d(-800,60,275),m_vel_rot,evt.time());
				m_state = 203;
			}
			break;
		}
		case 203: {
			if(evt.time() >= m_time){
				m_my->setWheelVelocity(0.0, 0.0);
				m_time = goToObj(Vector3d(-800,60,275), m_vel, 1.0, evt.time());
				m_state = 204;
			}
			break;
		}
//.........这里部分代码省略.........
开发者ID:Aharobot,项目名称:samples,代码行数:101,代码来源:FollowMeTestRobot.cpp

示例9: onAction

double MyController::onAction(ActionEvent &evt)
{  
  if(first == false){
    std::string msg = "start";  
    broadcastMsg(msg);
    first = true; 
  }

    int count=0;
    double r=0.0; //2点間の直線距離
    double angle;

    if(end==false){
        if(start==true){

            Vector3d pos;
            Vector3d npos;

            if(first==false){
                FILE* fp;           
                x=0;
                y=0;
                z=0;
                w=0; //チェックポイント
      
                dx=0;
                dy=0;
                dz=0;

                if((fp = fopen("node.txt", "r")) == NULL) {
	             printf("File do not exist.\n");
	             exit(0);
                }
                while(fscanf(fp, "%lf,%lf,%lf,%lf", &x, &y, &z,&w) != EOF) {
                    temp.x[i]=x;
                    temp.y[i]=y;
                    temp.z[i]=z;
                    temp.w[i]=w;
                    i++;
                }
                fclose(fp);
                first = true;
                i=0;
            }

            if(stop==false){
                my->getPosition(pos);

                npos.x(temp.x[i]); 
                npos.y(temp.y[i]); 
                npos.z(temp.z[i]); 

                angle = rotateTowardObj(npos);   

                if(angle < 0.0){
                    angle = -1.0 * angle;
                }
 		/*ここに相当する部分を書く*/
                //my->setAxisAndAngle(0, 1.0, 0, -angle);
   	        // 回転すべき円周距離
                double distance = m_distance*PI*fabs(targetAngle)/(2*PI);
                if(targetAngle > 0.0){
                    m_my->setWheelVelocity(velocity, -velocity);
                }
                else{
                    m_my->setWheelVelocity(-velocity, velocity);
                }
                // 車輪の半径から移動速度を得る
                double vel = m_radius*velocity;
    
                // 回転時間(u秒)
                double time = (distance / vel) + evt.time();
    
                if(evt.time>=time){
		    m_my->setWheelVelocity(0, 0);
                }

                dx=(temp.x[i]-pos.x());
                dy=(temp.y[i]-pos.y());
                dz=(temp.z[i]-pos.z());

                r=sqrt(pow(dx,2)+pow(dz,2));
                //ここまでが現在地から次の座標までの距離と角度の計算

                double vel = m_radius*velocity;

                // 移動開始
                m_my->setWheelVelocity(velocity, velocity);

                // 到着時間取得
                double time2 = r / vel;

                count = 0;
                count2= 0;
                i++;
            }


            if(temp.w[i-1] == 1.0){
                std::string msg = "point1";  
//.........这里部分代码省略.........
开发者ID:RoboCupatHomeSim,项目名称:RoboCupatHomeSim,代码行数:101,代码来源:FollowMeTestRobot_v1.cpp

示例10: onAction

double MyController::onAction(ActionEvent &evt)
{

	if(first == false){
		std::string msg = "start";  
		broadcastMsg(msg);
	}

	if(first==false){
		FILE* fp;
		x=0;
		y=0;
		z=0;
		w=0; //チェックポイント

		if((fp = fopen("node2.txt", "r")) == NULL) {
			printf("File do not exist.\n");
			exit(0);
		}
		while(fscanf(fp, "%lf,%lf,%lf,%lf", &x, &y, &z,&w) != EOF) {
			temp.x[i]=x;
			temp.y[i]=y;
			temp.z[i]=z;
			temp.w[i]=w;
			i++;
		}
		fclose(fp);
		first = true;
		i=0;
	}

	switch(m_state){

	// 初期状態
	case 0: {
		npos.x(temp.x[i]); 
		npos.y(temp.y[i]); 
		npos.z(temp.z[i]);

		m_time= rotateTowardObj(npos,m_vel,evt.time());
		m_state = 1;

		break;
	}
	// 回転中
	case 1: {

		// 回転終了
		if(evt.time() >= m_time){

			// 回転を止める
			m_my->setWheelVelocity(0.0, 0.0);
			m_time = goToObj(npos, m_vel*20, 1.0, evt.time());
			m_state = 2;

		}
		break;
	}
	case 2: {
 
		if(evt.time() >= m_time){
			m_my->setWheelVelocity(0.0, 0.0);

			if(temp.w[i] == 1.0){
				usleep(3200000);
				i++;
			}else if(temp.w[i] == 2.0){
				std::string msg = "elevator";  
				//"man_000"にメッセージを送信します
				//broadcastMsgToSrv("Elevator");  
				sendMsg("man_000", msg);
				m_state = 0;
				i++;
			}else if(temp.w[i] == 3.0){
				std::string msg = "ok";  
				//"man_000"にメッセージを送信します
				//broadcastMsgToSrv("Elevator");  
				sendMsg("man_000", msg);
				sleep(10);
				m_state = 0;
				i++;
			}else if(temp.w[i] == 4.0){
				m_state =99;
			}
			else{
				//std::string msg = "elevator";
				//"man_000"にメッセージを送信します
				//broadcastMsgToSrv("Elevator");  
				//sendMsg("man_000", msg);
				m_state = 0;
				i++;
			}
		}
		break;
	}
	case 99: {
		if(flg==false){
			m_my->setWheelVelocity(0.0, 0.0);
			//std::string msg = "Collision";  
			//broadcastMsg(msg);
//.........这里部分代码省略.........
开发者ID:RoboCupatHomeSim,项目名称:RoboCupatHomeSim,代码行数:101,代码来源:FollowMeTestRobot.cpp

示例11: onAction

double MyController::onAction(ActionEvent &evt)
{
/*	if(!checkService("RecogTrash")){
		m_srv == NULL;
		m_state = 0;
		return UPDATE_INTERVAL;
	}
	
	if(m_srv == NULL){
		// ゴミ認識サービスが利用可能か調べる
		if(checkService("RecogTrash")){
			// ゴミ認識サービスに接続
			m_srv = connectToService("RecogTrash");
			return UPDATE_INTERVAL;
		}
	}*/


	//if(evt.time() < m_time) printf("state: %d \n", m_state);
	switch(m_state) {
		// 初期状態
		case 0: {
			if(m_srv == NULL){
				// ゴミ認識サービスが利用可能か調べる
				if(checkService("RecogTrash")){
					// ゴミ認識サービスに接続
					m_srv = connectToService("RecogTrash");
				}
			} else if(m_srv != NULL && m_executed == false){  
				//rotate toward upper
				m_my->setJointVelocity("LARM_JOINT4", -m_jvel, 0.0);
				m_my->setJointVelocity("RARM_JOINT4", -m_jvel, 0.0);
				// 50°回転
				m_time = DEG2RAD(ROTATE_ANG) / m_jvel + evt.time();
				m_state = 5;
				m_executed = false;			
			}
			break;
		}

		case 5: {
			if(evt.time() > m_time && m_executed == false) {
				m_my->setJointVelocity("LARM_JOINT4", 0.0, 0.0);
				m_my->setJointVelocity("RARM_JOINT4", 0.0, 0.0);
				sendSceneInfo("Start");				
				printf("Started! \n");
				m_executed = true;
			}
			break;
		}


		case 800: {
			if(evt.time() > m_time && m_executed == false) {
				sendSceneInfo();
				m_executed = true;
			}
			break;
		}

		case 805: {
			if(evt.time() > m_time && m_executed == false) {
				// 送られた座標に移動する
				double range = 0;
				m_time = rotateTowardObj(nextPos, m_rotateVel, evt.time());
				m_state = 807;
				m_executed = false;
			}
			break;
	  }

		case 807: {
			if(evt.time() > m_time && m_executed == false) {
				m_my->setWheelVelocity(0.0, 0.0);				
				printf("移動先 x: %lf, z: %lf \n", nextPos.x(), nextPos.z());				
				m_time = goToObj(nextPos, m_vel*4, m_range, evt.time());
				
				if (m_lookObjFlg == 1.0) {
					printf("looking to Obj \n");				
					m_state = 810;
				} else {
					printf("go to next node \n");				
					m_state = 815;
				}

				m_executed = false;
			}
			break;
		}

		case 810: {
			// 送られた座標に移動中
			if(evt.time() > m_time && m_executed == false) {
				m_my->setWheelVelocity(0.0, 0.0);
				m_time = rotateTowardObj(m_lookingPos, m_rotateVel, evt.time());
				m_executed = false;
				m_state = 815;
			}
			break;
		}
//.........这里部分代码省略.........
开发者ID:bttung,项目名称:CleanUpRobotController,代码行数:101,代码来源:CleanUpRobot_1128.cpp

示例12: onAction

double DemoRobotController::onAction(ActionEvent &evt)
{
	switch(m_state) {
		case 0: {
			break;
		}
		case 1: {
			this->stopRobotMove();
			break;
		}
		case 10: {  // go straight a bit
			m_graspObjectName = m_trashName2;  // at first, focusing to m_trashName2:can_0
			m_robotObject->setWheelVelocity(m_angularVelocity, m_angularVelocity);
			m_time = 10.0/m_movingSpeed + evt.time();  // time to be elapsed
			m_state = 20;
			break;
		}
		case 20: {  // direct to the trash
			if(evt.time() >= m_time && m_state==20) {
				stopRobotMove();    // at first, stop robot maneuver

				Vector3d l_tpos;
				this->recognizeObjectPosition(l_tpos, m_trashName2);  // get position of trash
				double l_moveTime = rotateTowardObj(l_tpos);  // rotate toward the position and calculate the time to be elapsed.

				m_time = l_moveTime+evt.time();
				m_state = 30;
			}
			break;
		}
		case 30: {  // proceed toward trash
			if(evt.time() >= m_time && m_state==30) {
				this->stopRobotMove();

				Vector3d l_tpos;
				this->recognizeObjectPosition(l_tpos, m_trashName2);
				double l_moveTime = goToObj(l_tpos, 75.0);  // go toward the position and calculate the time to be elapsed.

				m_time = l_moveTime+evt.time();
				m_state = 40;
      }
      break;
    }
		case 40: {  // get back a bit after colliding with the table
			if(evt.time() >= m_time && m_state==40) {
				this->stopRobotMove();    // at first, stop robot maneuver

				m_robotObject->setWheelVelocity(-m_angularVelocity, -m_angularVelocity);
				m_time = 20./m_movingSpeed + evt.time();
				m_state = 50;
			}
			break;
		}
		case 50: {  // detour: rotate toward relay point 1
			if(evt.time() >= m_time && m_state==50) {
				this->stopRobotMove();

				double l_moveTime = rotateTowardObj(m_relayPoint1);

				m_time = l_moveTime+evt.time();
				m_state = 60;
			}
			break;
		}
		case 60: {  // detour: go toward relay point 1
			if(evt.time() >= m_time && m_state==60) {
				this->stopRobotMove();

				double l_moveTime = goToObj(m_relayPoint1, 0.0);

				m_time = l_moveTime+evt.time();
				m_state = 70;
			}
			break;
		}
		case 70: {  // rotate toward the position in front of trash
			if(evt.time() >= m_time && m_state==70) {
				this->stopRobotMove();

				double l_moveTime = rotateTowardObj(m_frontTrash1);

				m_time = l_moveTime+evt.time();
				m_state = 80;
			}
			break;
		}
		case 80: {  // go toward the position in front of trash
			if(evt.time() >= m_time && m_state==80) {
				this->stopRobotMove();

				double l_moveTime = goToObj(m_frontTrash1, 0.0);

				m_time = l_moveTime+evt.time();
				m_state = 90;
			}
			break;
		}
		case 90: {  // rotate toward the trash
			if(evt.time() >= m_time && m_state==90) {
				this->stopRobotMove();
//.........这里部分代码省略.........
开发者ID:RoboCupatHomeSim,项目名称:RoboCupatHomeSim,代码行数:101,代码来源:CleanUpDemo2014Robo.cpp

示例13: onAction

double RobotController::onAction(ActionEvent &evt)
{
	//std::cout << "m_state " <<  m_state << std::endl;
	//std::cout << "the size of Vector " <<  Record_Postures.size() << std::endl;
	switch(m_state)
	{
		case 10: 
		{
			Robot_speed  = Change_Robot_speed;
			choose_task_arm(5, LEFT_ARM);
			choose_task_arm(5, RIGHT_ARM);
			//   printf("got it in case!1 flag1 \n");
			if (goTo(m_relayPoint1, 0) == true && moveArm(LEFT_ARM) == true && moveArm(RIGHT_ARM) == true)
			{
				m_state = 20;
				//  printf("got it in case!1 \n");
			}
			break;
		}
		case 20:   
		{ 
			Robot_speed  = Change_Robot_speed;
			if (goTo(m_relayPoint2, 0) == true) m_state = 30;
			break;
		}
		case 30: 
		{
			Robot_speed  = Change_Robot_speed;
			if (goTo(m_relayFrontTable, 0) == true) m_state = 40;
			break;
		}
		case 40:   // Test if the cycle is finished or not
		{
			if (cycle > 0)
			{
				m_state = 41;
				broadcastMsg("Show_me");
				get_Kinect_Data();
				m_time = evt.time() + 5;
				break;
			}
			else 
			{
				m_state = 49;
				break;
			}
		}
		case 41: 
		{
			if(evt.time() > m_time) m_state = 42;
			break;
		}
		case 42:
		{
			Kinect_Data_Off(); // finished analysing data
			m_pointedObject = "petbottle";
			m_pointedtrash = "recycle";
			std::cout << "Task started Robot ........ "  << std::endl;
			//PrintPosture();
			m_state = 50;
		}
		case 49:
		{
			break;
		}
		case 50:     //Optional case  !!!
		{
			Robot_speed  = Change_Robot_speed;
			if (m_pointedObject=="petbottle")
			{
				if (goTo(m_BottleFront, 0) == true) m_state = 60;
			}
			else if (m_pointedObject=="mugcup")
			{
				if (goTo(m_MuccupFront, 0) == true) m_state = 60;
			}
			else if (m_pointedObject=="can")
			{
				if (goTo(m_CanFront, 0) == true)  m_state = 60;
			}
			break;
		}
		case 60:    //preparation of the arm for grasp
		{
			Robot_speed  = Change_Robot_speed;
			recognizeObjectPosition(m_Object_togo, m_pointedObject);
			if (goTo(m_Object_togo, 70) == true)
			{
				m_state = 70;
			}
			break;
		}
		case 70:    //preparation of the arm for grasp
		{
			choose_task_arm(1, LEFT_ARM);
			if (moveArm(LEFT_ARM) == true) m_state = 80;
			break;
		}
		case 80:    //move to the object
		{
//.........这里部分代码省略.........
开发者ID:RoboCupatHomeSim,项目名称:RoboCupatHomeSim,代码行数:101,代码来源:Robot.cpp

示例14: onAction

double DemoRobotController::onAction(ActionEvent &evt)
{
	switch(m_state) {
		case 0: {
			break;
		}
		case 1: {
			this->stopRobotMove();
			break;
		}
		case 50: {  // detour: rotate toward relay point 1
			if(evt.time() >= m_time) {
				this->stopRobotMove();

				double l_moveTime = rotateTowardObj(m_relayPoint1);

				m_time = l_moveTime+evt.time();
				m_state = 60;
			}
			break;
		}
		case 60: {  // detour: go toward relay point 1
			if(evt.time() >= m_time) {
				this->stopRobotMove();

				double l_moveTime = goToObj(m_relayPoint1, 0.0);

				m_time = l_moveTime+evt.time();
				m_state = 70;
			}
			break;
		}
		case 70: {  // rotate toward the position in front of trash
			if(evt.time() >= m_time) {
				this->stopRobotMove();

				double l_moveTime = rotateTowardObj(m_frontDesk1);

				m_time = l_moveTime+evt.time();
				m_state = 80;
			}
			break;
		}
		case 80: {  // go toward the position in front of trash
			if(evt.time() >= m_time) {
				this->stopRobotMove();

				double l_moveTime = goToObj(m_frontDesk1, 0.0);

				m_time = l_moveTime+evt.time();
				m_state = 90;
			}
			break;
		}
		case 90: {  // rotate toward the trash
			if(evt.time() >= m_time) {
				this->stopRobotMove();

				Vector3d l_tpos;

				if(m_task == 1)
					this->recognizeObjectPosition(l_tpos, m_trashName1);
				else
					this->recognizeObjectPosition(l_tpos, m_trashName2);

				double l_moveTime = rotateTowardObj(l_tpos);

				m_time = l_moveTime+evt.time();
				m_state = 100;
			}
			break;
		}
		case 100: {  // prepare the robot arm to grasping the trash
			if(evt.time() >= m_time) {
				this->stopRobotMove();
				this->neutralizeArms(evt.time());

				m_state = 105;
			}
			break;
		}
		case 105: {  // fix robot direction for grasping
			if(evt.time() >= m_time1) m_robotObject->setJointVelocity("RARM_JOINT1", 0.0, 0.0);
			if(evt.time() >= m_time4) m_robotObject->setJointVelocity("RARM_JOINT4", 0.0, 0.0);
			if(evt.time() >= m_time1 && evt.time() >= m_time4) {
				Vector3d l_tpos;
				if(m_task == 1)
					this->recognizeObjectPosition(l_tpos, m_trashName1);
				else
					this->recognizeObjectPosition(l_tpos, m_trashName2);
				double l_moveTime = rotateTowardObj(l_tpos);

				m_time = l_moveTime+evt.time();

				m_state = 110;
			}
			break;
		}
		case 110: {  // approach to the trash
			if(evt.time() >= m_time) {
//.........这里部分代码省略.........
开发者ID:RoboCupatHomeSim,项目名称:RoboCupatHomeSim,代码行数:101,代码来源:CleanUpDemo2014Robo.cpp


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