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

常熟网站建设公司阳春房产网

常熟网站建设公司,阳春房产网,营销型网站的例子,租电信网站服务器吗仿真环境中操作TurtleBot 一、实操1.1 查看姿态信息1.2 控制turtlebot移动的三种方式1.2.1 命令行发布指令1.2.2 键盘操控1.2.3 Python脚本控制1.2.4 使用rqt工具界面#xff0c;发布运动指令 二、里程计(odometry)TurtleBot3 仿真 进行实操之前#xff0c;先准备环境 $ sud… 仿真环境中操作TurtleBot 一、实操1.1 查看姿态信息1.2 控制turtlebot移动的三种方式1.2.1 命令行发布指令1.2.2 键盘操控1.2.3 Python脚本控制1.2.4 使用rqt工具界面发布运动指令 二、里程计(odometry)TurtleBot3 仿真 进行实操之前先准备环境 $ sudo apt install ros-kinetic-turtlebot ros-kinetic-turtlebot-apps ros-kinetic-turtlebot-interactions ros-kinetic-turtlebot-simulator ros-kinetic-kobuki-ftdi ros-kinetic-turtlebot-gazebo一、实操 1.1 查看姿态信息 环境准备好后执行以下命令启动 $ roslaunch turtlebot_gazebo turtlebot_world.launch可以看见以下效果视角不舒服的话就按CtrlShift鼠标左键调整调整至你喜欢的视角并通过滚轮缩放大小。 按如下顺序点击TurtleBot将被一个白色框线框住并可以查看姿态信息 也可以用以下命令打印出mobile_base的姿态信息注意到由于车应该是放置在水平面上的position.z的值本应该是0这里却是一串-0.00113074128666的小数原因是什么呢是ROS的缺陷吗//TODO此问题待解答然后看到orientation的x,y,z,w这被称作四元数(quaternion)用来表示三维空间里的旋转关于四元数如何表示三维空间里的旋转见《二维空间与三维空间的姿态表示法》 $ rosservice call gazebo/get_model_state {model_name: mobile_base} header: seq: 1stamp: secs: 1945nsecs: 170000000frame_id: pose: position: x: 1.97484093771y: 0.0147819206239z: -0.00113074128666orientation: x: -0.00134519341326y: -0.00376571136568z: -0.348703846748w: 0.937224432639 twist: linear: x: -0.000155242355429y: -0.000224370086231z: -4.28258194336e-06angular: x: -0.0023805996017y: 0.00191483013878z: 0.000121453647707 success: True status_message: GetModelState: got properties 1.2 控制turtlebot移动的三种方式 1.2.1 命令行发布指令 可以看到这个名字叫做mobile_base的link(连接刚体)根据之前操作小乌龟的文章我们要先找到有哪些node在跑然后再找到对应的有哪些topic在publish和被subscribe去控制mobile_base开始我们干脆看图说话。 rosrun rqt_graph rqt_graph目的很明确要找的node就应该是/gazebo了我原本以为这里会有一个结点应该叫mobile_base但想了想它应该被整个包含在/gazebonode环境里面了所以/gazebo这个node还是有非常多子结构不然一个孤零零的/gazebo怎么完成这么多物体的操作呢 $ rosnode list /gazebo #忽略 /gazebo_gui #忽略 /laserscan_nodelet_manager /mobile_base_nodelet_manager #可能是 /robot_state_publisher /rosout #忽略继续信息有点多但是我们还是只需要看Subscriptions这个服从命令听指挥是优良作风看名字的话在上面rqt_graph图中所见到的的topic正是/mobile_base/commands/velocity哦这里连message的数据类型都给出来了是geometry_msgs/Twist $ rosnode info /gazebo -------------------------------------------------------------------------------- Node [/gazebo] Publications: * /camera/depth/camera_info [sensor_msgs/CameraInfo]* /camera/depth/image_raw [sensor_msgs/Image] ... ...Subscriptions: * /clock [rosgraph_msgs/Clock]* /gazebo/set_link_state [unknown type]* /gazebo/set_model_state [unknown type]* /mobile_base/commands/motor_power [unknown type]* /mobile_base/commands/reset_odometry [unknown type]* /mobile_base/commands/velocity [geometry_msgs/Twist] ... ...那么就有的放矢了发布命令 $ rostopic pub -r 10 /mobile_base/commands/velocity /geometry_msgs/Twist {linear: {x: 0.2}}1.2.2 键盘操控 执行下面的命令可以用键盘操作 $ roslaunch turtlebot_teleop keyboard_teleop.launch但这个package是turtlebot_teleop有什么说法和依据吗为什么执行的是它答案是没有代码开发时的设计如此来看最新的rqt_graph所以这建立在你非常了解你所要运行的仿真环境基础上才能做到用键盘操作不然琢磨半天也不会知道如何使用键盘去操作这个turtlebot。 1.2.3 Python脚本控制 西天取经孙悟空总算是要拿到他的如意金箍棒了有了程序才叫编程有了金箍棒孙悟空才能大闹天宫可孙悟空终会有取到经书的一刻那时不只是涅盘成佛也是大圣的寂灭。 创建一份ControlTurtleBot.py内容为: #!/usr/bin/env python # Execute as a python script # Set linear and angular values of TurtleBots speed and turning. import rospy # Needed to create a ROS node from geometry_msgs.msg import Twist # Message that moves baseclass ControlTurtleBot():def __init__(self):# ControlTurtleBot is the name of the node sent to the #masterrospy.init_node(ControlTurtleBot, anonymousFalse)# Message to screenrospy.loginfo(Press CTRLc to stop TurtleBot)# Keys CNTL c will stop script #这里的self.shutdown是一个函数地址rospy.on_shutdown(self.shutdown)# Publisher will send Twist message on topic cmd_vel_mux/input/naviself.cmd_vel rospy.Publisher(cmd_vel_mux/input/navi,Twist, queue_size10)# TurtleBot will receive the message 10 times per second.rate rospy.Rate(10);# 10 Hz is fine as long as the processing does not exceed# 1/10 second.# Twist is geometry_msgs for linear and angular velocitymove_cmd Twist()move_cmd.linear.x 0.3# Modify this value to change speed# Turn at 0 radians/smove_cmd.angular.z 0# Modify this value to cause rotation rad/s# Loop and TurtleBot will move until you type CNTLcwhile not rospy.is_shutdown():# publish Twist values to TurtleBot node /cmd_vel_muxself.cmd_vel.publish(move_cmd)# wait for 0.1 seconds (10 HZ) and publish againrate.sleep()def shutdown(self):# You can stop turtlebot by publishing an empty Twist# messagerospy.loginfo(Stopping TurtleBot)self.cmd_vel.publish(Twist())# Give TurtleBot time to stoprospy.sleep(1)if __name__ __main__:try:ControlTurtleBot()except:rospy.loginfo(End of the trip for TurtleBot)然后赋予执行权限并用python解释执行然后小车就会沿着它自身坐标系的x轴方向一直前进。 $ chmod x ControlTurtleBot.py $ python ControlTurtleBot.py1.2.4 使用rqt工具界面发布运动指令 rqt ROS Qt GUI Toolkit $ rqt然后在插件选项栏里将Message Publisher与Topic Monitor调出来 并选择对应的Topic和Message Type设置数据值然后勾选发布 另外rqt这个工具可以让你跟踪发布的message一旦TurtleBot的行动不是你预期的那样你可以进行debug排查原因。 二、里程计(odometry) 这个odometry是用来估计mobile robot当前所处位置和起点之间的距离和姿态变化当mobile robot走了一段较长的距离时这个数据会变得不准原因可能是车轮的直径参数有误或者路不平导致车轮的转换器输出了不准确的数据书上给了一篇IEEE Transactions on Robotics and Automation(IEEE TRO)收录的论文对这个问题有较为详尽的讨论 Measurement and Correction of Systematic Odometry Errors in Mobile Robots.pdf这篇文章还讨论了轴距(wheelbase)的影响。 这是一作老头子的个人主页 Johann Borenstein。 首先查看/odom这个topic使用的message结果显示是nav_msgs/Odometry再看nav_msgs/Odometry的数据格式 $ rostopic type /odom nav_msgs/Odometry $ rosmsg show nav_msgs/Odometry std_msgs/Header headeruint32 seqtime stampstring frame_id string child_frame_id geometry_msgs/PoseWithCovariance posegeometry_msgs/Pose posegeometry_msgs/Point positionfloat64 xfloat64 yfloat64 zgeometry_msgs/Quaternion orientationfloat64 xfloat64 yfloat64 zfloat64 wfloat64[36] covariance geometry_msgs/TwistWithCovariance twistgeometry_msgs/Twist twistgeometry_msgs/Vector3 linearfloat64 xfloat64 yfloat64 zgeometry_msgs/Vector3 angularfloat64 xfloat64 yfloat64 zfloat64[36] covariance 用以下命令可以使turtlebot归位 # 1.查找归位topic对应的message $ rostopic type /mobile_base/commands/reset_odometry std_msgs/Empty # 2.命令mobile_base归位 $ rostopic pub /mobile_base/commands/reset_odometry std_msgs/Empty$ rostopic echo /mobile_base/sensors/imu_data使用以下命令分别把gazebo和rviz启动起来 $ roslaunch turtlebot_gazebo turtlebot_world.launch $ roslaunch turtlebot_rviz_launchers view_robot.launch按如下方式勾选 就会出现一根红色箭头将指明turtlebot的前进方向 然后发布运动命令 $ rostopic pub -r 10 /cmd_vel_mux/input/teleop \geometry_msgs/Twist {linear: {x: 0.1, y: 0, z: 0}, angular: {x: 0, y: 0, z: -0.5}} # 效果与上面的一样 $ rostopic pub -r 10 /mobile_base/commands/velocity \geometry_msgs/Twist {linear: {x: 0.1, y: 0, z: 0}, angular: {x: 0, y: 0, z: -0.5}}TurtleBot3 仿真 安装环境 $ sudo apt-get install ros-kinetic-joy ros-kinetic-teleop-twist-joy ros-kinetic-teleop-twist-keyboard ros-kinetic-laser-proc ros-kinetic-rgbd-launch ros-kinetic-depthimage-to-laserscan ros-kinetic-rosserial-arduino ros-kinetic-rosserial-python ros-kinetic-rosserial-server ros-kinetic-rosserial-client ros-kinetic-rosserial-msgs ros-kinetic-amcl ros-kinetic-map-server ros-kinetic-move-base ros-kinetic-urdf ros-kinetic-xacro ros-kinetic-compressed-image-transport ros-kinetic-rqt-image-view ros-kinetic-gmapping ros-kinetic-navigation然后将给turtlebot3远程计算机开发的ROS catkin 软件包代码拉到本地并进行编译 $ cd ~/catkin_ws/src/ $ git clone https://github.com/ROBOTIS-GIT/turtlebot3_simulations.git $ git clone https://github.com/ROBOTIS-GIT/turtlebot3_msgs.git $ git clone https://github.com/ROBOTIS-GIT/turtlebot3.git $ cd ~/catkin_ws $ catkin_make用以下命令去指定model这样再启动rviz环境下看到的就是burger这个机器人TurtleBot 3 Burger [US] $ export TURTLEBOT3_MODELburger $ roslaunch turtlebot3_fake turtlebot3_fake.launch然后在新的Terminal就可以用键盘控制这个机器人了 $ export TURTLEBOT3_MODELburger $ roslaunch turtlebot3_teleop turtlebot3_teleop_key.launch关闭刚刚打开rviz的终端然后是gazebo环境的仿真你应该会看到如下画面 $ export TURTLEBOT3_MODELburger $ roslaunch turtlebot3_gazebo turtlebot3_world.launch然后再打开一个Terminal执行下面的命令你就能操控turtlebot3在这个仿真环境里行驶了 $ export TURTLEBOT3_MODELburger $ roslaunch turtlebot3_teleop turtlebot3_teleop_key.launch并且turtlebot3还可以自动行驶关掉执行turtlebot3_teleop的终端在新的Terminal里执行下面的命令 $ export TURTLEBOT3_MODELburger $ roslaunch turtlebot3_gazebo turtlebot3_simulation.launch来看下为什么turtlebot3不撞墙新建一个Terminal并执行 $ export TURTLEBOT3_MODELburger $ roslaunch turtlebot3_gazebo turtlebot3_gazebo_rviz.launch发现有激光雷达的扫描数据红点连起来就是激光雷达的描边 书本的第三章后半部分就在写硬件部分的实操了第三章就到这里
http://www.w-s-a.com/news/205609/

相关文章:

  • 设计师投资做项目网站外贸网站建设工作室
  • 无聊的网站wordpress的alt属性插件
  • 个股期权系统网站开发小清新wordpress模板
  • 全中文网站开发建筑公司企业愿景文案
  • 广州网站建设正规公司建设银行信用卡中心网站
  • 哪个网站是专门做封面素材怎么制作app平台
  • 网站开发 平均工资商标注册在哪个部门申请
  • 做外贸需要自己的网站吗营销型网站建设市场分析
  • 绍兴网站制作推广wordpress 无法自动升级
  • 阿里云建站数据库用什么app制作开发费用多少
  • 中国住房和城乡建设部网站资质查询中小开网站
  • 交易所网站开发水果营销软文
  • 石家庄有什么好玩的地方2017织梦网站怎么做seo
  • wordpress项目插件seo的含义
  • 网站平台建设的作用电影宣传类网页界面设计
  • 户外网站模板国外优秀的平面设计网站
  • 家政网站怎么做网站机房建设方案
  • 学校网站建设运行情况2022年近期舆情热点话题
  • 做淘宝需要知道什么网站吗有没有做软件的网站
  • 安丘网站建设制作做网站和微信小程序
  • 京东网站的建设与发展前景黑龙江建设网官网登陆
  • soho的网站怎么做微网站平台建设方案
  • 网站开发下载阿里云oss做视频网站
  • 东莞营销网站制作做一个网站建设
  • 啥网站都能看的浏览器下载网站后台管理系统展望
  • 新建站点步骤汉中 wordpress联盟
  • 坪山网站设计的公司网站 seo 设置
  • 济南网站设计公司排名如何免费注册网站域名
  • 网站开发分工甜妹妹福利wordpress
  • 网站中英文要怎么做网站建设的策划文案