当前位置: 首页 > news >正文

长沙网站建设推荐为了 门户网站建设

长沙网站建设推荐,为了 门户网站建设,谷歌google地图,淘宝导航里的链接网站怎么做actionlib是ROS中一个很重要的功能包集合#xff0c;尽管在ROS中已经提供了srevice机制来满足请求—响应式的使用场景#xff0c;但是假如某个请求执行时间很长#xff0c;在此期间用户想查看执行的进度或者取消这个请求的话#xff0c;service机制就不能满足了#xff0c…  actionlib是ROS中一个很重要的功能包集合尽管在ROS中已经提供了srevice机制来满足请求—响应式的使用场景但是假如某个请求执行时间很长在此期间用户想查看执行的进度或者取消这个请求的话service机制就不能满足了但是actionlib可满足用户这种需求。例如控制机器人运动到地图中某一目标位置这个过程可能复杂而漫长执行过程中还可能强制中断或反馈信息这时actionlib就能大展伸手了。 actionlib使用client-server工作模式ActionClient 和ActionServer通过ROS Action Protocol进行通信ROS Action Protocol以ROS消息方式进行传输。此外ActionClient 和ActionServer给用户提供了一些简单的接口用户使用这些接口可以完成goal请求client-side和goal执行server-side。 ActionClient 和ActionServer之间使用action protocol通信action protocol就是预定义的一组ROS message这些message被放到ROS topic上在 ActionClient 和ActionServer之间进行传实现二者的沟通。 ROS Messages goal - Used to send new goals to servers. 代表一个任务可以被ActionClient发送到ActionServer。比如在MoveBase中它的类型是PoseStamped包含了机器人运动目标位置的信息。 cancel - Used to send cancel requests to servers status - Used to notify clients on the current state of every goal in the system feedback - Used to send clients periodic auxiliary information for a goal. 服务端定期告知Client当前Goal执行过程中的情况。在Move Base案例中它表示机器人当前姿态。 result - Used to send clients one-time auxiliary information upon completion of a goal ROS系统在action文件文件名后缀为.action中定义了上述goal、result、feedback等消息。The .action file has the goal definition, followed by the result definition, followed by the feedback definition, with each section separated by 3 hyphens (---).  下面是一个示意的例子在./action/DoDishes.action文件中对洗碗这一任务进行定义goal为使用某一洗碗机洗碗result为总共洗好的碗数目feedback为洗碗进度。 # Define the goal uint32 dishwasher_id # Specify which dishwasher we want to use --- # Define the result uint32 total_dishes_cleaned --- # Define a feedback message float32 percent_complete 下面在catkin_ws/src目录下创建一个测试package catkin_create_pkg actionlib_test roscpp std_msgs actionlib actionlib_msgs message_generation rospy 在package的CMakeLists.txt文件中加入下面这几行 #find_package(catkin REQUIRED genmsg actionlib_msgs actionlib) add_action_files(DIRECTORY action FILES DoDishes.action) generate_messages(DEPENDENCIES actionlib_msgs) 注意如果使用catkin_create_pkg创建包时没有添加actionlib相关的依赖项要将上面CMakeLists中第一行的注释去掉另外还要在package.xml文件中加入下面几行。因为我们在创建包时就添加好了相关依赖所以这一步骤可以省略。 build_dependactionlib/build_depend build_dependactionlib_msgs/build_depend run_dependactionlib/run_depend run_dependactionlib_msgs/run_depend 使用catkin_make编译即可查看生成的消息文件这些消息之后将会用于ActionClient 和 ActionServer间的通信。 另外可以看到在devel/include/actionlib_test/中生成了相关的头文件 C SimpleActionClient  client示例代码client.cpp如下它会等待Server连接发送Goal获取状态。SimpleActionClient完整的API可以参考C SimpleActionClient #include actionlib_test/DoDishesAction.h #include actionlib/client/simple_action_client.htypedef actionlib::SimpleActionClientactionlib_test::DoDishesAction Client;int main(int argc, char** argv) {ros::init(argc, argv, do_dishes_client);Client client(do_dishes, true); // true - dont need ros::spin()client.waitForServer(); // Waits for the ActionServer to connect to this clientactionlib_test::DoDishesGoal goal;// Fill in goal hereclient.sendGoal(goal); // Sends a goal to the ActionServerclient.waitForResult(ros::Duration(5.0)); // Blocks until this goal finishesif (client.getState() actionlib::SimpleClientGoalState::SUCCEEDED)printf(Yay! The dishes are now clean\n);printf(Current State: %s\n, client.getState().toString().c_str());return 0; } C SimpleActionServer  服务端代码server.cpp如下SimpleActionServert完整的API可以参考 C SimpleActionServer #include actionlib_test/DoDishesAction.h #include actionlib/server/simple_action_server.htypedef actionlib::SimpleActionServeractionlib_test::DoDishesAction Server;void execute(const actionlib_test::DoDishesGoalConstPtr goal, Server* as) {// Do lots of awesome groundbreaking robot stuff hereas-setSucceeded(); }int main(int argc, char** argv) {ros::init(argc, argv, do_dishes_server);ros::NodeHandle n;Server server(n, do_dishes, boost::bind(execute, _1, server), false);server.start();ros::spin();return 0; } 在CMakeLists文件中加入下面这几行 add_executable(client src/client.cpp) add_executable(server src/server.cpp) target_link_libraries( client ${catkin_LIBRARIES}) target_link_libraries( server ${catkin_LIBRARIES}) 使用catkin_make进行编译完成后输入指令rosrun actionlib_test server 运行server通过rostopic list查看系统中的话题如下 使用rqt_graph命令可以查看节点和消息的关系可以看出server端会接收goal和cancel消息并发出status、result、feedback消息 接着输入指令rosrun actionlib_test client 运行client结果如下图所示 Python SimpleActionClient  除了C也可以使用Python实现同样的功能client.py如下API可以参考Python SimpleActionClient #! /usr/bin/env pythonimport roslib roslib.load_manifest(actionlib_test) import rospy import actionlibfrom actionlib_test.msg import DoDishesAction, DoDishesGoalif __name__ __main__:rospy.init_node(do_dishes_client)client actionlib.SimpleActionClient(do_dishes, DoDishesAction)client.wait_for_server()goal DoDishesGoal()# Fill in the goal hereclient.send_goal(goal)client.wait_for_result(rospy.Duration.from_sec(5.0)) Python SimpleActionServer  server.py程序如下API可参考Python SimpleActionServer #! /usr/bin/env pythonimport roslib roslib.load_manifest(actionlib_test) import rospy import actionlibfrom actionlib_test.msg import DoDishesActionclass DoDishesServer:def __init__(self):self.server actionlib.SimpleActionServer(do_dishes, DoDishesAction, self.execute, False)self.server.start()def execute(self, goal):# Do lots of awesome groundbreaking robot stuff hereself.server.set_succeeded()if __name__ __main__:rospy.init_node(do_dishes_server)server DoDishesServer()rospy.spin() 注意在运行程序前先用chmod x命令给Python文件添加可执行权限 运行client.py和server.py注意client.py运行就会返回
http://wiki.neutronadmin.com/news/431151/

相关文章:

  • 做包装盒效果图的网站域名是什么样子的
  • 为企业提供网站建设服务怎么做app下载网站
  • 门户网站首页设计删除自豪地采用wordpress
  • 做网站有哪些需求it外包人员最后什么下场
  • 旅游类网站设计重庆市工程招标信息网
  • 凡科做网站给后台的吗wordpress 改登录界面
  • 软件开发可以做网站么软件开发步骤包括哪些
  • 个人网页制作源代码格式seo整站优化方法
  • 一个域名绑定多个网站正规的代加工平台
  • 建网站手续手机蓝牙app开发教程
  • 网站程可以自己做吗网站版本功能列表
  • 网站建设与管理实验安卓移动网站开发详解
  • 安全网站建设网站制作专门做ui图标的网站
  • 湖州网站建设企业能联系做仿瓷的网站
  • 对做网站有什么建议淘客网站开发公司
  • 江苏泰州海陵区建设局网站新开最好的传奇网站
  • 网站建设douyanet新闻类网站排版网站建设
  • 济南网站建设哪个好国内最好的旅游网站
  • 惠州惠城网站建设网站目录有什么意义
  • 域名注册成功后怎么使用网站wordpress短网址插件
  • asp网站 换模板网上服务旗舰店
  • 企业建站公司哪里找网站建设花都區
  • 网站工信部超链接怎么做建网站深
  • 做网站的公司在哪企业网站建设注意
  • 哪家网站游戏做的比较好的wordpress 加视频教程
  • 怎样创建网站快捷方式到桌面开一个网站建设公司需要什么软件
  • 建筑工程网校有哪些苏州seo门户网
  • 行业网站联盟东莞建设网站流程
  • 建网站 考虑wordpress 绝对路径
  • 盐城做网站需要多少钱常州市网站建设设计