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


C++ GoalHandle类代码示例

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


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

示例1: goalCB

  void goalCB(GoalHandle gh)
  {
    // Cancels the currently active goal.
    if (has_active_goal_)
    {
      // Marks the current goal as canceled.
      active_goal_.setCanceled();
      has_active_goal_ = false;
    }

    gh.setAccepted();
    active_goal_ = gh;
    has_active_goal_ = true;
    goal_received_ = ros::Time::now();

    // update our zero values for 0.25 seconds
    if(active_goal_.getGoal()->command.zero_fingertip_sensors)
    {
      std_srvs::Empty::Request req;
      std_srvs::Empty::Response resp;
      if(ros::service::exists("zero_fingertip_sensors",true))
      {
        ROS_INFO("updating zeros!");
        ros::service::call("zero_fingertip_sensors",req,resp);
      }
    }
    
    // Sends the command along to the controller.
    pub_controller_command_.publish(active_goal_.getGoal()->command);
    
    last_movement_time_ = ros::Time::now();
    action_start_time = ros::Time::now();
  }
开发者ID:PR2,项目名称:pr2_gripper_sensor,代码行数:33,代码来源:pr2_gripper_findContact_action.cpp

示例2: goalCB

  void goalCB(GoalHandle gh)
  {
    // Ensures that the joints in the goal match the joints we are commanding.
    ROS_DEBUG("Received goal: goalCB");
    ROS_INFO("Received goal: goalCB");
    if (!is_joint_set_ok(joint_names_, gh.getGoal()->trajectory.joint_names))
    {
      ROS_ERROR("Joints on incoming goal don't match our joints");
      gh.setRejected();
      return;
    }

    // Cancels the currently active goal.
    if (has_active_goal_)
    {
      ROS_DEBUG("Received new goal, canceling current goal");
      // Stops the controller.
      trajectory_msgs::JointTrajectory empty;
      empty.joint_names = joint_names_;
      pub_controller_command_.publish(empty);

      // Marks the current goal as canceled.
      active_goal_.setCanceled();
      has_active_goal_ = false;
    }

    gh.setAccepted();
    active_goal_ = gh;
    has_active_goal_ = true;

    // Sends the trajectory along to the controller
    ROS_INFO("Publishing trajectory; sending commands to the joint controller ");
    current_traj_ = active_goal_.getGoal()->trajectory;
    pub_controller_command_.publish(current_traj_);
  }
开发者ID:techeten,项目名称:hiroken-ros-pkg,代码行数:35,代码来源:hiro_joint_action_server.cpp

示例3: ROS_DEBUG

void BaseTrajectoryActionController::goalCB(GoalHandle gh)
{
  ROS_DEBUG("goalCB");

  std::vector<std::string> joint_names(joints_.size());
  for (size_t j = 0; j < joints_.size(); ++j)
    joint_names[j] = joints_[j]->name;

  // Ensures that the joints in the goal match the joints we are commanding.
  if (!setsEqual(joint_names, gh.getGoal()->trajectory.joint_names))
  {
    ROS_ERROR("Joints on incoming goal don't match our joints");
    gh.setRejected();
    return;
  }

  // Cancels the currently active goal.
  if (active_goal_)
  {
    // Marks the current goal as canceled.
    active_goal_->setCanceled();
  }

  starting(); // reset trajectory

  gh.setAccepted();

  // Sends the trajectory along to the controller
  active_goal_ = boost::shared_ptr<GoalHandle>(new GoalHandle(gh));
  commandTrajectory(share_member(gh.getGoal(),gh.getGoal()->trajectory), active_goal_);
}
开发者ID:YoheiKakiuchi,项目名称:jsk_robot,代码行数:31,代码来源:pr2_base_trajectory_action.cpp

示例4: goalCB

void CartesianTrajectoryAction::goalCB(GoalHandle gh) {
  // cancel active goal
  if (active_goal_.isValid() && (active_goal_.getGoalStatus().status == actionlib_msgs::GoalStatus::ACTIVE)) {
    active_goal_.setCanceled();
  }

  Goal g = gh.getGoal();

  CartesianTrajectory* trj_ptr =  new CartesianTrajectory;
  *trj_ptr = g->trajectory;
  CartesianTrajectoryConstPtr trj_cptr = CartesianTrajectoryConstPtr(trj_ptr);
  port_cartesian_trajectory_command_.write(trj_cptr);

  gh.setAccepted();
  active_goal_ = gh;
}
开发者ID:mikolak,项目名称:common_controllers,代码行数:16,代码来源:cartesian_trajectory_action.cpp

示例5: cancelCB

  void cancelCB(GoalHandle gh)
  {
    if (active_goal_ == gh)
    {
      /*
      // Stops the controller.
      if (last_controller_state_)
      {
        pr2_controllers_msgs::Pr2GripperCommand stop;
        stop.position = last_controller_state_->process_value;
        stop.max_effort = 0.0;
        pub_controller_command_.publish(stop);
      }
      */
      // stop the real-time motor control
      std_srvs::Empty::Request req;
      std_srvs::Empty::Response resp;
      if(ros::service::exists("stop_motor_output",true))
      {
        ROS_INFO("Stopping Motor Output");
        ros::service::call("stop_motor_output",req,resp);
      }

      // Marks the current goal as canceled.
      active_goal_.setCanceled();
      has_active_goal_ = false;
    }
  }
开发者ID:PR2,项目名称:pr2_gripper_sensor,代码行数:28,代码来源:pr2_gripper_sensor_action.cpp

示例6: cancelCB

  void cancelCB(GoalHandle gh)
  {
    std::string nodeName = ros::this_node::getName();
	ROS_INFO("%s",(nodeName + ": Canceling current grasp action").c_str());
    //gh.setAccepted();
    gh.setCanceled();
    ROS_INFO("%s",(nodeName + ": Current grasp action has been canceled").c_str());
  }
开发者ID:Liangconghui,项目名称:NTU_Amazon_Picking_Challenge,代码行数:8,代码来源:simulated_grasp_action_server.cpp

示例7: goalCB

  void goalCB(GoalHandle gh)
  {
    // Cancels the currently active goal.
    if (has_active_goal_)
    {
      // Marks the current goal as canceled.
      active_goal_.setCanceled();
      has_active_goal_ = false;
    }

    gh.setAccepted();
    active_goal_ = gh;
    has_active_goal_ = true;
    goal_received_ = ros::Time::now();
    min_error_seen_ = 1e10;

    // Sends the command along to the controller.
    pub_controller_command_.publish(active_goal_.getGoal()->command);
    last_movement_time_ = ros::Time::now();
  }
开发者ID:PR2,项目名称:pr2_gripper_sensor,代码行数:20,代码来源:pr2_gripper_sensor_action.cpp

示例8: goalCallback

void ServerGoalHandleDestructionTester::goalCallback(GoalHandle gh)
{
  ROS_ERROR_NAMED("actionlib", "In callback");
  //assign to our stored goal handle
  *gh_ = gh;

  TestGoal goal = *gh.getGoal();

  switch (goal.goal)
  {
    case 1:
      gh.setAccepted();
      gh.setSucceeded(TestResult(), "The ref server has succeeded");
      break;
    case 2:
      gh.setAccepted();
      gh.setAborted(TestResult(), "The ref server has aborted");
      break;
    case 3:
      gh.setRejected(TestResult(), "The ref server has rejected");
      break;
    default:
      break;
  }

  ros::shutdown();
}
开发者ID:mylxiaoyi,项目名称:ros_distro,代码行数:27,代码来源:server_goal_handle_destruction.cpp

示例9: goalCB

  void goalCB(GoalHandle& gh)
  {
    ROS_DEBUG("GoalHandle request received");

    // accept new goals
    gh.setAccepted();

    // get goal from handle
    const tf2_web_republisher::TFSubscriptionGoal::ConstPtr& goal = gh.getGoal();

    // generate goal_info struct
    boost::shared_ptr<ClientGoalInfo> goal_info = boost::make_shared<ClientGoalInfo>();
    goal_info->handle = gh;
    goal_info->client_ID_ = client_ID_count_++;
    goal_info->timer_ = nh_.createTimer(ros::Duration(1.0 / goal->rate),
                                        boost::bind(&TFRepublisher::processGoal, this, goal_info, _1));

    std::size_t request_size_ = goal->source_frames.size();
    goal_info->tf_subscriptions_.resize(request_size_);

    for (std::size_t i=0; i<request_size_; ++i )
    {
      TFPair& tf_pair = goal_info->tf_subscriptions_[i];

      std::string source_frame = cleanTfFrame(goal->source_frames[i]);
      std::string target_frame = cleanTfFrame(goal->target_frame);

      tf_pair.setSourceFrame(source_frame);
      tf_pair.setTargetFrame(target_frame);
      tf_pair.setAngularThres(goal->angular_thres);
      tf_pair.setTransThres(goal->trans_thres);
    }

    {
      boost::mutex::scoped_lock l(goals_mutex_);
      // add new goal to list of active goals/clients
      active_goals_.push_back(goal_info);
    }

  }
开发者ID:jstnhuang,项目名称:tf2_web_republisher,代码行数:40,代码来源:tf_web_republisher.cpp

示例10: goalCB

void CartesianImpedanceAction::goalCB(GoalHandle gh) {
  // cancel active goal
  if (active_goal_.isValid() && (active_goal_.getGoalStatus().status == actionlib_msgs::GoalStatus::ACTIVE)) {
    active_goal_.setCanceled();
  }

  Goal g = gh.getGoal();

  bool valid = true;

  for (size_t i = 0; i < g->trajectory.points.size(); i++) {
    valid = valid && checkImpedance(g->trajectory.points[i].impedance);
  }

  if (!valid) {
    cartesian_trajectory_msgs::CartesianImpedanceResult res;
    res.error_code = cartesian_trajectory_msgs::CartesianImpedanceResult::INVALID_GOAL;
    gh.setRejected(res);
  }

  CartesianImpedanceTrajectory* trj_ptr =  new CartesianImpedanceTrajectory;
  *trj_ptr = g->trajectory;
  CartesianImpedanceTrajectoryConstPtr trj_cptr = CartesianImpedanceTrajectoryConstPtr(trj_ptr);

  if (g->trajectory.header.stamp < rtt_rosclock::host_now()) {
    valid = false;
    cartesian_trajectory_msgs::CartesianImpedanceResult res;
    res.error_code = cartesian_trajectory_msgs::CartesianImpedanceResult::OLD_HEADER_TIMESTAMP;
    gh.setRejected(res);
  }

  if (valid) {
    port_cartesian_trajectory_command_.write(trj_cptr);

    gh.setAccepted();
    active_goal_ = gh;
  }
}
开发者ID:mikolak,项目名称:common_controllers,代码行数:38,代码来源:cartesian_impedance_action.cpp

示例11: cancelCB

	void cancelCB(GoalHandle gh){
		if (active_goal_ == gh)
		{
			// Stops the controller.
			if(creato){
				ROS_INFO_STREAM("Stop thread");
				pthread_cancel(trajectoryExecutor);
				creato=0;
			}
			pub_topic.publish(empty);

			// Marks the current goal as canceled.
			active_goal_.setCanceled();
			has_active_goal_ = false;
		}
	}
开发者ID:gnunoe,项目名称:Cf_ROS,代码行数:16,代码来源:actionController.cpp

示例12: goalCB

  void goalCB(GoalHandle gh)
  {
    std::string nodeName = ros::this_node::getName();

    ROS_INFO("%s",(nodeName + ": Received grasping goal").c_str());

	switch(gh.getGoal()->goal)
	{
		case GraspHandPostureExecutionGoal::PRE_GRASP:
			gh.setAccepted();
			//gh.getGoal()->grasp
			ROS_INFO("%s",(nodeName + ": Pre-grasp command accepted").c_str());
			gh.setSucceeded();
			break;

		case GraspHandPostureExecutionGoal::GRASP:
			gh.setAccepted();
			ROS_INFO("%s",(nodeName + ": Executing a gripper grasp").c_str());

			// wait
			ros::Duration(0.25f).sleep();
			gh.setSucceeded();
			break;

		case GraspHandPostureExecutionGoal::RELEASE:
			gh.setAccepted();
			ROS_INFO("%s",(nodeName + ": Executing a gripper release").c_str());

			// wait
			ros::Duration(0.25f).sleep();
			gh.setSucceeded();
			break;

		default:

			ROS_INFO("%s",(nodeName + ": Unidentified grasp request, rejecting goal").c_str());
			gh.setSucceeded();
			//gh.setRejected();
			break;
	}

  }
开发者ID:Liangconghui,项目名称:NTU_Amazon_Picking_Challenge,代码行数:42,代码来源:simulated_grasp_action_server.cpp

示例13: cancelCB

  void cancelCB(GoalHandle gh)
  {
    
    if (active_goal_ == gh)
    {
      // stop the real-time motor control
      std_srvs::Empty::Request req;
      std_srvs::Empty::Response resp;
      if(ros::service::exists("stop_motor_output",true))
      {
        ROS_INFO("Stopping Motor Output");
        ros::service::call("stop_motor_output",req,resp);
      }

      // Marks the current goal as canceled.
      active_goal_.setCanceled();
      has_active_goal_ = false;
    }
  }
开发者ID:PR2,项目名称:pr2_gripper_sensor,代码行数:19,代码来源:pr2_gripper_findContact_action.cpp

示例14: goalCB

  void goalCB(GoalHandle gh)
  {
    // Ensures that the joints in the goal match the joints we are commanding.
    ROS_DEBUG("Received goal: goalCB");
    if (!setsEqual(joint_names_, gh.getGoal()->trajectory.joint_names))
    {
      ROS_ERROR("Joints on incoming goal don't match our joints");
      gh.setRejected();
      return;
    }

    // Cancels the currently active goal.
    if (has_active_goal_)
    {
      ROS_DEBUG("Received new goal, canceling current goal");
      // Stops the controller.
      trajectory_msgs::JointTrajectory empty;
      empty.joint_names = joint_names_;
      pub_controller_command_.publish(empty);

      // Marks the current goal as canceled.
      active_goal_.setCanceled();
      has_active_goal_ = false;
    }

    // Sends the trajectory along to the controller
    if (withinGoalConstraints(last_controller_state_, goal_constraints_, gh.getGoal()->trajectory))
    {
      ROS_INFO_STREAM("Already within goal constraints");
      gh.setAccepted();
      gh.setSucceeded();
    }
    else
    {
      gh.setAccepted();
      active_goal_ = gh;
      has_active_goal_ = true;

      ROS_INFO("Publishing trajectory");

      current_traj_ = active_goal_.getGoal()->trajectory;
      pub_controller_command_.publish(current_traj_);
    }
  }
开发者ID:CloPeMa,项目名称:motoman,代码行数:44,代码来源:joint_trajectory_action.cpp

示例15: goalCB

  void GripperAction::goalCB(GoalHandle gh)
  {
	  // Cancels the currently active goal.

      if (has_active_goal_)
      {
    	  // Marks the current goal as canceled.
    	  active_goal_.setCanceled();
    	  has_active_goal_ = false;
          std::cout << "canceled current active goal" << std::endl;
      }

      gh.setAccepted();
      active_goal_ = gh;
      has_active_goal_ = true;
      goal_received_ = ros::Time::now();
      min_error_seen_ = 1e10;

      ROS_INFO_STREAM("Gripper target position: " << active_goal_.getGoal()->command.position << "effort: " << active_goal_.getGoal()->command.max_effort);

      ROS_INFO("setFingersValues");
    
      std::vector<double> fingerPositionsRadian = jaco_->getFingersJointAngle();

      std::cout << "current fingerpositions: " << fingerPositionsRadian[0] << " " << fingerPositionsRadian[1] << " " << fingerPositionsRadian[2] << std::endl;

        target_position = active_goal_.getGoal()->command.position;
        target_effort = active_goal_.getGoal()->command.max_effort;

        //determine if the gripper is supposed to be opened or closed
        double current_position = jaco_->getFingersJointAngle()[0];
        if(current_position > target_position){
            opening = true;
            std::cout << "Opening gripper" << std::endl;
        }else{
            opening = false;
            std::cout << "Closing gripper" << std::endl;
        }

        

        fingerPositionsRadian[0] = target_position;
        fingerPositionsRadian[1] = target_position;
        fingerPositionsRadian[2] = target_position;

        

        std::cout << "Gripper target position: " << active_goal_.getGoal()->command.position << "effort: " << active_goal_.getGoal()->command.max_effort << std::endl;


      double fingerPositionsDegree[3] = {radToDeg(fingerPositionsRadian[0]),radToDeg(fingerPositionsRadian[1]),radToDeg(fingerPositionsRadian[2])};

      if(!jaco_->setFingersValues(fingerPositionsDegree))
      {
    	  active_goal_.setCanceled();
    	  ROS_ERROR("Cancelling goal: moveJoint didn't work.");
          std::cout << "Cancelling goal because setFingers didn't work" << std::endl;
      }

      last_movement_time_ = ros::Time::now();
  }
开发者ID:ksatyaki,项目名称:JacoROS,代码行数:61,代码来源:gripper_controller.cpp


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