ROS :发送一个目标位置,机器人自动规划路线,移动到该位置。
2016-10-22 14:02
741 查看
使用 Action :move_base_msgs::MoveBaseAction(move_base在world中的目标)
新建send_goal.cpp
CMakeList.txt
新建launch文件goal_launch.launch
launch 中的节点
使用willow-full-0.025.pgm 0.025,注意要换成自己的文件目录,我的是在navigation_stage/stage_config/maps/文件中。
其他节点类似。
运行launch。
结果:
新建send_goal.cpp
/* * send_goal.cpp * * Created on: Aug 10, 2016 * Author: unicorn */ #include <ros/ros.h> #include <move_base_msgs/MoveBaseAction.h> #include <actionlib/client/simple_action_client.h> /*move_base_msgs::MoveBaseAction move_base在world中的目标 */ typedef actionlib::SimpleActionClient<move_base_msgs::MoveBaseAction> MoveBaseClient; int main(int argc, char** argv) { ros::init(argc, argv, "send_goals_node"); /* // create the action client // true causes the client to spin its own thread //don't need ros::spin() 创建action客户端,参数1:action名,参数2:true,不需要手动调用ros::spin(),会在它的线程中自动调用。 */ MoveBaseClient ac("move_base", true); // Wait 60 seconds for the action server to become available ROS_INFO("Waiting for the move_base action server"); ac.waitForServer(ros::Duration(60)); ROS_INFO("Connected to move base server"); // Send a goal to move_base //目标的属性设置 move_base_msgs::MoveBaseGoal goal; goal.target_pose.header.frame_id = "map"; goal.target_pose.header.stamp = ros::Time::now(); goal.target_pose.pose.position.x = 21.174; goal.target_pose.pose.position.y = 10.876; goal.target_pose.pose.orientation.w = 1; ROS_INFO(""); ROS_INFO("Sending goal"); ac.sendGoal(goal); // Wait for the action to return ac.waitForResult(); if (ac.getState() == actionlib::SimpleClientGoalState::SUCCEEDED) ROS_INFO("You have reached the goal!"); else ROS_INFO("The base failed for some reason"); return 0; }
CMakeList.txt
add_executable(send_goal src/send_goal.cpp) target_link_libraries(send_goal ${catkin_LIBRARIES} )
新建launch文件goal_launch.launch
<launch> <master auto="start"/> <param name="/use_sim_time" value="true"/> <include file="$(find navigation_stage)/move_base_config/move_base.xml"/> <node pkg="stage_ros" type="stageros" name="stageros" args="$(find navigation_stage)/stage_config/worlds/willow-pr2-2.5cm.world" respawn="false" > <param name="base_watchdog_timeout" value="0.2"/> </node> <include file="$(find navigation_stage)/move_base_config/amcl_node.xml"/> <node name="rviz" pkg="rviz" type="rviz" args="-d $(find navigation_stage)/single_robot.rviz" /> <node name="send_goal" pkg="navigation_example" type="send_goal" output="screen"/> </launch>
launch 中的节点
<node name="map_server" pkg="map_server" type="map_server" args="$(find navigation_stage)/stage_config/maps/" respawn="false" />
使用willow-full-0.025.pgm 0.025,注意要换成自己的文件目录,我的是在navigation_stage/stage_config/maps/文件中。
其他节点类似。
运行launch。
结果:
相关文章推荐
- 1、当鼠标移动到目标上的时候,自动显示一个提示框。
- 一个简单的自动发送邮件系统(二)
- 如何向目标窗口发送一个Unicode 字符?
- CLR 无法从 COM 上下文 0x1a2740 转换为 COM 上下文 0x1a28b0,这种状态已持续 60 秒。拥有目标上下文/单元的线程很有可能执行的是非泵式等待或者在不发送 Windows 消息的情况下处理一个运行时间非常长的操作
- 一个机器人ROS相关资源的网站
- wo 想做一个根据鼠标效果,平行的边选择,加线,根据鼠标移动分布位置,
- 一个可以自动改变控件位置和大小的对话框类
- 自动移动域中计算机到目标OU的脚本
- 异常信息:CLR无法从COM 上下文0x645e18 转换为COM上下文0x645f88,这种状态已持续60秒。拥有目标上下文/单元的线程很有可能执行的是非泵式等待或者在不发送 Windows 消息的情况下处理一个运行时间非常长的操作.这种情况通常会影响到
- vs每次拉下一个控件都必选设置为绝对位置才可以移动,怎样解决啊
- 一个自动将cookie发送到自己网站的XSS脚本!
- 一个简单的自动发送邮件系统(三)
- 一个简单的自动发送邮件系统(一)
- 一个简单的自动发送邮件系统(三)
- 是时候给自己规划一个详细目标了
- 自主移动机器人动作设计--目标跟踪及移动轨迹设计(开发日志一)
- 一个简单的自动发送邮件系统(一)
- 一个简单的自动发送邮件系统(三)
- 向一个指定窗口发送左键按下的消息,同时将左键按下的位置也发过去(譬如要编写连连看程序的外挂)
- 鼠标移动到一个位置弹出相应的一张图片