91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 3KB
    文件類型: .cpp
    金幣: 1
    下載: 0 次
    發布日期: 2021-05-15
  • 語言: C/C++
  • 標簽: 機器人ros??導航??

資源簡介

ros move_base提供了actionlib的服務,用戶可以通過該服務來設置一系列導航位置點,該例子提供了c++的一個實現,通過使用相應的回調函數,用戶還可以隨時取消不需要的導航點。

資源截圖

代碼片段和文件信息

#include?
#include?
#include?se_msgs/MovebaseAction.h>
#include?“tf/tf.h“
#include?
#include?
typedef?actionlib::SimpleActionClientse_msgs::MovebaseAction>?MovebaseClient;
class?MyNode
{
public:

MovebaseClient*?ac_;
void?init()?{
//MovebaseClient?ac(“move_base“?true);
ac_?=?new?MovebaseClient(“move_base“?true);
//wait?for?the?action?server?to?come?up
while?(!ac_->waitForServer(ros::Duration(5.0)))?{
ROS_INFO(“Waiting?for?the?move_base?action?server?to?come?up“);
}
}

bool?doStuff(const?double&?x_set?const?double&?y_set?const?double&?z_set?const?double&?x?const?double&?y?const?double&?z?const?double&?w)
{
move_base_msgs::MovebaseGoal?goal;
if?(x_set?!=?last_x_set?||?y_set?!=?last_y_set)
{
//we‘ll?send?a?goal?to?the?robot?to?move?1?meter?forward
goal.target_pose.header.frame_id?=?“map“;
goal.target_pose.header.stamp?=?ros::Time::now();

goal.target_pose.pose.position.x?=?x_set;
goal.target_pose.pose.position.y?=?y_set;
goal.target_pose.pose.position.z?=?0;

//??????????tf::Quaternion?q;
//??????????q.setRotation(tf::Vector3(0?0?1)?th_set);
goal.target_pose.pose.orientation.x?=?x;
goal.target_pose.pose.orientation.y?=?y;
goal.target_pose.pose.orientation.z?=?z;
goal.target_pose.pose.orientation.w?=?w;

ROS_INFO(“Sending?goal“);
//?ac.sendGoal(goal);
ac_->sendGoal(goal
boost::bind(&MyNode::doneCb?this?_1?_2)
MovebaseClient::SimpleActiveCallback()
MovebaseClient::SimpleFeedbackCallback());
success_?=?false;
}
last_x_set?=?x_set;?last_y_set?=?y_set;
return?success_;
}


評論

共有 條評論