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


C++ ServiceClient::call方法代码示例

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


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

示例1: main

int main(int argc, char **argv)
{
	ros::init(argc, argv, "rps_robot_commander");
	ros::NodeHandle n;

	//~ ros::Subscriber	rps_map_subscriber = n.subscribe("rps_map_data", 1, set_RPS_MAP);
	ros::ServiceServer server_robot_command = n.advertiseService("rps_robot_command", start_robot_commander);

	commander_to_get_robots_info = n.serviceClient<tms_msg_db::tmsdb_get_robots_info>("tmsdb_get_robots_info");
#ifdef SEND_COMMAND
	client_smartpal5_control = n.serviceClient<tms_msg_rc::smartpal_control>("sp5_control");
#endif
	client_smartpal5_speak = n.serviceClient<tms_msg_rc::smartpal_speak>("sp5_speak");
	
	////////////////////////////
#ifdef USE_TMS_DB
	srv_r.request.robots_id = 2;
	if(commander_to_get_robots_info.call(srv_r))
		ROS_INFO("Success robots_x = %lf, y = %lf, theta = %lf", srv_r.response.robots_x,srv_r.response.robots_y,srv_r.response.robots_theta);
	else{
		ROS_ERROR("Failed to call service get_robots_info\n");
		return 0;
	}
	srv_smartpal_control.request.unit = UNIT_VEHICLE;
	srv_smartpal_control.request.cmd  = CMD_setPose;
	srv_smartpal_control.request.arg.resize(3);
	srv_smartpal_control.request.arg[0] = srv_r.response.robots_x;
	srv_smartpal_control.request.arg[1] = srv_r.response.robots_y;
	srv_smartpal_control.request.arg[2] = srv_r.response.robots_theta;
#else
	srv_smartpal_control.request.unit = UNIT_VEHICLE;
	srv_smartpal_control.request.cmd  = CMD_setPose;
	srv_smartpal_control.request.arg.resize(3);
	srv_smartpal_control.request.arg[0] = 1000;
	srv_smartpal_control.request.arg[1] = 1000;
	srv_smartpal_control.request.arg[2] = 0.0;
#endif
	
#ifdef SEND_COMMAND
	if(client_smartpal5_control.call(srv_smartpal_control)){
		ROS_INFO("result: %d", srv_smartpal_control.response.result);
	}	
	else{
		ROS_ERROR("Failed to call service sp5_control");
		return 0;
	}
#endif
	////////////////////////////
	
	ros::spin();

	return 0;
}
开发者ID:SiChiTong,项目名称:ros_tms,代码行数:53,代码来源:rps_robot_commander.cpp

示例2: emergencyStopHandler

void emergencyStopHandler(std_msgs::Bool msg)
{
	if (msg.data)
	{
		pending_bricks.clear();
		robot_client.call(cmdResetMotion,cmdRes);
		robot_state = emergency_stop;
	}
	else
	{
		robot_client.call(cmdOpenGripper,cmdRes);
		robot_state = idle;
	}
}
开发者ID:RSDgroup4,项目名称:BrixPicker,代码行数:14,代码来源:robot_motion_controller_node.cpp

示例3: joint_state_cb

void joint_state_cb(const sensor_msgs::JointStateConstPtr& js){

    if (js->position.size() > 4){ //Message from the base or the arm
        js_cur = *js;
        
        last_status = sbs;
		if(!checkIfSafe())
			sbs.status = sbs.PAUSED;
		else
			sbs.status = sbs.RUNNING;
			
		sb_req.status = sbs;
		sb_req.requester = "mico_safety_node";
		
		if(sbs.status != last_status.status){
			if(stopbase_client.call(sb_req,sb_resp)){
				ROS_DEBUG("Made stop_base call");
			}
			else{
				ROS_ERROR("Stop base service call failed!");
				ros::shutdown();
			}	
		}
    }

};
开发者ID:nj1407,项目名称:segbot_arm,代码行数:26,代码来源:mico_nav_safety_service.cpp

示例4: isADCBusy

/*
 * Check the busy flag
 *
 * Poll for the busy flag returns true if busy, false if not
 */
bool isADCBusy(ADC adc)
{
    //Define and fill in a service request
    hardware_interface::ReadI2CRegister read;
    read.request.addr = adc;
    read.request.reg = ADC_BUSY;
    read.request.size = 1;

    //Send request
    if(read_register_svr.call(read))
    {
        //Sussecful read
        if(read.response.data[0])
        {
            //Still busy
            return true;
        }
        else
        {
            //Not busy!
            return false;
        }
    }
    else
    {
        //Unsussesful read!!!
        //Do error handeling
    }

    return false;
}
开发者ID:JoeyS7,项目名称:AggreGatorRMC,代码行数:36,代码来源:adc_node.cpp

示例5: moveToJointState

void moveToJointState(const float* js){
	
	/*moveit::planning_interface::MoveGroup group("arm");
    moveit::planning_interface::PlanningSceneInterface planning_scene_interface;   
    group.setPlanningTime(5.0); //10 second maximum for collision computation*/
	
	
	
	moveit_utils::MicoMoveitJointPose::Request req;
	moveit_utils::MicoMoveitJointPose::Response res;
	
	for(int i = 0; i < 6; i++){
        switch(i) {
            case 0  :    req.target.joint1 = js[i]; break;
            case 1  :    req.target.joint2 =  js[i]; break;
            case 2  :    req.target.joint3 =  js[i]; break;
            case 3  :    req.target.joint4 =  js[i]; break;
            case 4  :    req.target.joint5 =  js[i]; break;
            case 5  :    req.target.joint6 =  js[i]; break;
        }
	//ROS_INFO("Requested angle: %f", q_vals.at(i));
    }
	
	if(client_joint_command.call(req, res)){
 		ROS_INFO("Call successful. Response:");
 		ROS_INFO_STREAM(res);
 	} else {
 		ROS_ERROR("Call failed. Terminating.");
 		//ros::shutdown();
 	}
}
开发者ID:nj1407,项目名称:segbot_arm,代码行数:31,代码来源:ispy_arm_server.cpp

示例6: jointsCall

  void jointsCall()
  {
    //ここをどうするか?
    for(int i = 0; i < okao_id.size(); ++i)
      {

	humans_msgs::HumanImgSrv hs;
	//hs.request.rule = rule;
       	
	hs.request.src.max_okao_id = okao_id[i];
	
	//okao_client::OkaoStack okao_img;
	//okao_img.request.person.okao_id = okao_id;
	
	if( srv.call( hs ) )
	  {	
	    //cout << "okao_id:" << okao_id[i] << ", x,y =" 
	    //	 << hs.response.dst.p.x << ","<< hs.response.dst.p.y <<  endl ;
	    markerPublisher( hs.response.dst, hs.response.img );
	  }
	else
	  {
	    cout << "not found!"<<endl;
	  }
      }


  }
开发者ID:cvpapero,项目名称:mysql_connector,代码行数:28,代码来源:database_client_joints.cpp

示例7: processData

/* processData is the main decision function that
 * will publish commands to the motor controller
 * node and possibly ask for arduino data.
 */
void processData() {

   //geometry_msgs::Twist command;
   beagle_pkg::status status;
   if(ard_client.call(ard_data)) {

      ROS_INFO("lidar data was %f, arduino reading was %f\n", scan_data.range_min, ard_data.response.distance);

      if(ard_data.response.distance > 5 && scan_data.range_min > 5) {
         status.command = 0;
      }
      else if(ard_data.response.distance <= 0 && scan_data.range_min <= 0) {
         status.command = 0;
      }
      else if(ard_data.response.distance > scan_data.range_min) {
         status.command = 1;
      }
      else {
         status.command = 2;
      }
      
      /* TODO: look at global data (scan_data, gps_data, ard_data)
       * and make decision of what to send to the motor node.
       */
      vel_pub.publish(status);
   }
   else {
    ROS_ERROR("Failed to call ard service");
   }
}
开发者ID:jleija42,项目名称:CPRC-IGVC,代码行数:34,代码来源:master_node.cpp

示例8: TurnScan

//=============================================================
//名前:TurnScan
//説明:首振りの方向折り返し
//=============================================================
void ThermalScanning::TurnScan(void)
{
	//std_msgs::Float64 tilt_controller_command_msg; 

	if(cw == -1)	// 左回りの場合
	{
		start_angle = MIN_YAW_ANGLE_CAM;
		end_angle   = MAX_YAW_ANGLE_CAM;
		pm = 1;
	}else if(cw == 1){	// 右回りの場合
		start_angle = MAX_YAW_ANGLE_CAM;
		end_angle   = MIN_YAW_ANGLE_CAM;
		pm = -1;
	}

	// ダイナミクセルのスピードの設定
	if(Scan_state == 0 || Scan_state == 5 || Scan_state == 6)	// 通常探索
	{ 
		srv.request.speed = MOTOR_SPEED;
	}
	else if(Scan_state == 1)	// 強化探索
	{
		srv.request.speed = MOTOR_SPEED2;
	}	
	dyna_client.call(srv);
		
	// ダイナミクセルの角度を初期位置に移動する
	// TODO ダイナミクセルの角度をDyna_angleに変更する処理を入れる
	Dyna_angle = start_angle;

	tilt_controller_command_msg.data = Dyna_angle;
}
开发者ID:kyoto-u-shinobi,项目名称:kamui,代码行数:36,代码来源:thermo_scan2.cpp

示例9: main

int main(int argc, char **argv){
    ros::init(argc, argv, "run_pose_estimation_for_scene_screenshot");

    ros::NodeHandle nodeHandle = ros::NodeHandle("~");
    global = nodeHandle.serviceClient<MsgT>("/inSceneDetector/detect");

    if (!once){


        //get screen shot pose
        ROS_INFO("Subscribing to detection service for screen shot pose...");
        ros::service::waitForService("/inSceneDetector/detect");
        MsgT msgglobal01;
        msgglobal01.request.scenario = "detect_screen_shot";

            if(global.call(msgglobal01)) {
			//printResults(msgglobal01);
                    pcl::console::print_value("Screenshot detected!\n");
            } else pcl::console::print_error("Screenshot not detected!\n");

	once = true;
    }
    ros::spinOnce();

return 0;
}
开发者ID:kilimi,项目名称:acat_pose_vizualization,代码行数:26,代码来源:run_pose_estimation_for_scene_screenshot.cpp

示例10: getBricks

std::vector<Brick> getBricks()
{
    std::vector<Brick> retVec;
    rc_vision::getBricks obj;

    if(!_serviceGetBricks.call(obj))
    {
        printConsole("Failed to call the 'serviceGetBricks'");
    }
    else
    {
        for(unsigned int i=0; i<obj.response.size.size(); i++)
        {
            Brick brick;
            brick.color = obj.response.color[i];
            brick.posX = obj.response.posX[i];
            brick.posY = obj.response.posY[i];
            brick.size = obj.response.size[i];
            brick.theta = obj.response.theta[i];
            retVec.push_back(brick);
        }
    }

    return retVec;
}
开发者ID:rsbGroup1,项目名称:rc_rsd,代码行数:25,代码来源:mainNode.cpp

示例11: anyBrickCallback

void anyBrickCallback(std_msgs::Bool msg)
{
    // Fetch robot position
    kuka_rsi::getConfiguration getQObj;

    // Call service
    if(!_serviceGetConf.call(getQObj))
       printConsole("Failed to call the 'serviceKukaGetConfiguration'");

    // Get information
    bool same = true;
    for(int i=0; i<6; i++)
    {
        if(fabs(getQObj.response.q[i]*DEGREETORAD - _qIdle[i]) > 0.1)
        {
            same = false;
            break;
        }
    }

    _anyBricksMutex.lock();
    _anyBricks = msg.data;
    _anyBricksMutex.unlock();

    _qMutex.lock();
    _positionQIdle = same;
    _qMutex.unlock();
}
开发者ID:rsbGroup1,项目名称:rc_rsd,代码行数:28,代码来源:mainNode.cpp

示例12: changeDirConveyerBelt

void changeDirConveyerBelt(bool dir) // true = reverse
{
    rc_plc::ChangeDirection obj;
    obj.request.direction = dir;
    if(!_serviceChangeDir.call(obj))
        printConsole("Failed to call the 'serviceChangeDirConveyer'");
}
开发者ID:rsbGroup1,项目名称:rc_rsd,代码行数:7,代码来源:mainNode.cpp

示例13: startConveyerBelt

void startConveyerBelt(bool dir = false)
{
    rc_plc::StartConv obj;
    obj.request.direction = dir;
    if(!_serviceStart.call(obj))
        printConsole("Failed to call the 'serviceStartConveyer'");
}
开发者ID:rsbGroup1,项目名称:rc_rsd,代码行数:7,代码来源:mainNode.cpp

示例14: sub1_callback

/**
 * @brief Callback functions for datalink routing, channel 1 
 *        
 */
void sub1_callback(const uav_control::DFrame msg)
{
  // message from GCS, to be relayed to quadcopter
  if(msg.target_id != SYSID){
    uav_control::datalink_send ss;
    ss.request.source_id = msg.source_id;
    ss.request.target_id = msg.target_id;
    ss.request.route = msg.route;
    ss.request.len = msg.len;
    int i;
    for(i=0; i<msg.len; i++)
      ss.request.payload[i] = msg.payload[i];

    if(client_sub1.call(ss)){
      switch(ss.response.err){
        case 0: //ROS_INFO("successful");
                break;
        case 1: ROS_ERROR("relay error: invalid channel");
                break;
        case 2: ROS_ERROR("relay error: channel not initialized");
                break;
        case 3: ROS_ERROR("relay error: sending failed");
                break;
        default: ROS_ERROR("relay error: unknown failure");
                break;
      }
    }
  }

}
开发者ID:YifanJiangPolyU,项目名称:UAV-communication-relay,代码行数:34,代码来源:datalink_route.cpp

示例15: plotSummary

bool plotSummary(ros::ServiceClient& sum_client)
{
    PlanningSummary planning_sum;
    if (!sum_client.call(planning_sum))
    {
        return false;
    }

    unsigned int cols = planning_sum.response.score_labels.size();
    for (unsigned int i = 0; i < planning_sum.response.score_labels.size(); i++)
    {
        cout << planning_sum.response.score_labels[i] << "\t";
    }
    cout << endl;

    for (unsigned int i = 0; i < planning_sum.response.score_values.size(); i++)
    {
        if (i % cols == 0)
        {
            cout << i / cols << ": ";
        }
        cout << planning_sum.response.score_values[i];
        cout << "\t";
        if (i % cols == cols - 1)
        {
            cout << endl;
        }
    }

    return true;
}
开发者ID:jordisoler,项目名称:usc-clmc-ros-pkg,代码行数:31,代码来源:template_grasp_feedback_ui.cpp


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