学校网站建设材料,神网站建设,百度seo怎么收费,重庆一般建一个网站需要多少钱目录 1 gazebo仿真环境搭建
1.1 直接添加内置组件创建仿真环境
1.2 urdf、gazebo、rviz的综合应用
2 ROS_control
2.1 运动控制实现流程(Gazebo)
2.1.1 已经创建完毕的机器人模型#xff0c;编写一个单独的 xacro 文件#xff0c;为机器人模型添加传动装置以及控制器
…目录 1 gazebo仿真环境搭建
1.1 直接添加内置组件创建仿真环境
1.2 urdf、gazebo、rviz的综合应用
2 ROS_control
2.1 运动控制实现流程(Gazebo)
2.1.1 已经创建完毕的机器人模型编写一个单独的 xacro 文件为机器人模型添加传动装置以及控制器
2.1.2 将此文件集成进xacro文件
2.1.3 修改launch文件
2.1.3 启动 Gazebo 并发布 /cmd_vel 消息控制机器人运动
2.3.4 里程计查看
3 雷达仿真信息以及显示
3.1 实现流程
3.2 为机器人模型添加雷达配置
3.3 集成进xacro文件
3.4 启动 Gazebo使用 Rviz 显示雷达信息
4 摄像头仿真
4.1 为机器人模型添加摄像头配置
4.2 为机器人模型添加相机配置
5 深度相机Kinect仿真
5.1 为机器人模型添加深度相机配置
5.2 kinect点云数据显示 1 gazebo仿真环境搭建 到目前为止我们已经可以将机器人模型显示在 Gazebo 之中了但是当前默认情况下在 Gazebo 中机器人模型是在 empty world 中并没有类似于房间、家具、道路、树木... 之类的仿真物如何在 Gazebo 中创建仿真环境呢 Gazebo 中创建仿真实现方式有两种: 方式1: 直接添加内置组件创建仿真环境 方式2: 手动绘制仿真环境(更为灵活) 也还可以直接下载使用官方或第三方提高的仿真环境插件。 1.1 直接添加内置组件创建仿真环境 启动roscore之后 rosrun gazebo_ros gazebo 是一个空的世界我们设置一些障碍物。 点击保存(save world as)即可。生成一个.world文件。 选择Editor -- Building Editor 可以添加门添加窗户等。 1.2 urdf、gazebo、rviz的综合应用 关于URDF(Xacro)、Rviz 和 Gazebo 三者的关系前面已有阐述: URDF 用于创建机器人模型、Rviz 可以显示机器人感知到的环境信息Gazebo 用于仿真可以模拟外界环境以及机器人的一些传感器如何在 Gazebo 中运行这些传感器并显示这些传感器的数据(机器人的视角)呢本节主要介绍的重点就是将三者结合:通过 Gazebo 模拟机器人的传感器然后在 Rviz 中显示这些传感器感知到的数据。主要内容包括: 运动控制以及里程计信息显示 雷达信息仿真以及显示 摄像头信息仿真以及显示 kinect 信息仿真以及显示 2 ROS_control gazebo 中已经可以正常显示机器人模型了那么如何像在 rviz 中一样控制机器人运动呢在此需要涉及到ros中的组件: ros_control。 场景:同一套 ROS 程序如何部署在不同的机器人系统上比如开发阶段为了提高效率是在仿真平台上测试的部署时又有不同的实体机器人平台不同平台的实现是有差异的如何保证 ROS 程序的可移植性ROS 内置的解决方式是 ros_control。 ros_control:是一组软件包它包含了控制器接口控制器管理器传输和硬件接口。ros_control 是一套机器人控制的中间件是一套规范不同的机器人平台只要按照这套规范实现那么就可以保证 与ROS 程序兼容通过这套规范实现了一种可插拔的架构设计大大提高了程序设计的效率与灵活性。 gazebo 已经实现了 ros_control 的相关接口如果需要在 gazebo 中控制机器人运动直接调用相关接口即可。 承上运动控制基本流程: 已经创建完毕的机器人模型编写一个单独的 xacro 文件为机器人模型添加传动装置以及控制器 将此文件集成进xacro文件 启动 Gazebo 并发布 /cmd_vel 消息控制机器人运动 2.1 运动控制实现流程(Gazebo)
2.1.1 已经创建完毕的机器人模型编写一个单独的 xacro 文件为机器人模型添加传动装置以及控制器 我们建立一个文件夹gazebo存放传动装置以及控制器相关文件move.xacro 把这个传动装置以及控制器相关文件集成进总的xacro文件中 官方文档复制下来即可无需自己写 robot namemy_car_move xmlns:xacrohttp://wiki.ros.org/xacro!-- 传动实现:用于连接控制器与关节 --xacro:macro namejoint_trans paramsjoint_name!-- Transmission is important to link the joints and the controller --transmission name${joint_name}_transtypetransmission_interface/SimpleTransmission/typejoint name${joint_name}hardwareInterfacehardware_interface/VelocityJointInterface/hardwareInterface/jointactuator name${joint_name}_motorhardwareInterfacehardware_interface/VelocityJointInterface/hardwareInterfacemechanicalReduction1/mechanicalReduction/actuator/transmission/xacro:macro!-- 每一个驱动轮都需要配置传动装置 --xacro:joint_trans joint_nameleft_wheel2base_link /xacro:joint_trans joint_nameright_wheel2base_link /!-- 控制器 --gazeboplugin namedifferential_drive_controller filenamelibgazebo_ros_diff_drive.sorosDebugLevelDebug/rosDebugLevelpublishWheelTFtrue/publishWheelTFrobotNamespace//robotNamespacepublishTf1/publishTfpublishWheelJointStatetrue/publishWheelJointStatealwaysOntrue/alwaysOnupdateRate100.0/updateRatelegacyModetrue/legacyModeleftJointleft_wheel2base_link/leftJoint !-- 左轮 --rightJointright_wheel2base_link/rightJoint !-- 右轮 --wheelSeparation${base_link_radius * 2}/wheelSeparation !-- 车轮间距 --wheelDiameter${wheel_radius * 2}/wheelDiameter !-- 车轮直径 --broadcastTF1/broadcastTFwheelTorque30/wheelTorquewheelAcceleration1.8/wheelAccelerationcommandTopiccmd_vel/commandTopic !-- 运动控制话题 --odometryFrameodom/odometryFrame odometryTopicodom/odometryTopic !-- 里程计话题 --robotBaseFramebase_footprint/robotBaseFrame !-- 根坐标系 --/plugin/gazebo/robot解释一下怎么适配自己的场景 第一部分是传动实现用于连接控制器与关节 这里要改成我们自己的关节。 我们的驱动轮关节名叫做base_link2_${wheel_name}传入参数是left和right因此move.xacro改为 xacro:joint_trans joint_namebase_link2_left /xacro:joint_trans joint_namebase_link2_right / 后面是差速控制器 整体来看是这样 robot namemy_car_move xmlns:xacrohttp://wiki.ros.org/xacroxacro:macro namejoint_trans paramsjoint_name!-- Transmission is important to link the joints and the controller --transmission name${joint_name}_transtypetransmission_interface/SimpleTransmission/typejoint name${joint_name}hardwareInterfacehardware_interface/VelocityJointInterface/hardwareInterface/jointactuator name${joint_name}_motorhardwareInterfacehardware_interface/VelocityJointInterface/hardwareInterfacemechanicalReduction1/mechanicalReduction/actuator/transmission/xacro:macroxacro:joint_trans joint_namebase_link2_left /xacro:joint_trans joint_namebase_link2_right /gazeboplugin namedifferential_drive_controller filenamelibgazebo_ros_diff_drive.sorosDebugLevelDebug/rosDebugLevelpublishWheelTFtrue/publishWheelTFrobotNamespace//robotNamespacepublishTf1/publishTfpublishWheelJointStatetrue/publishWheelJointStatealwaysOntrue/alwaysOnupdateRate100.0/updateRatelegacyModetrue/legacyModeleftJointbase_link2_left/leftJointrightJointbase_link2_right/rightJointwheelSeparation${base_radius * 2}/wheelSeparationwheelDiameter${wheel_radius * 2}/wheelDiameterbroadcastTF1/broadcastTFwheelTorque30/wheelTorquewheelAcceleration1.8/wheelAccelerationcommandTopiccmd_vel/commandTopicodometryFrameodom/odometryFrameodometryTopicodom/odometryTopicrobotBaseFramebase_footprint/robotBaseFrame/plugin/gazebo/robot2.1.2 将此文件集成进xacro文件 robot namemycarwithlidarandcamera xmlns:xacrohttp://wiki.ros.org/xacroxacro:include filenameinterial.xacro /xacro:include filenamedemo05carbase.xacro /xacro:include filenamecam.xacro /xacro:include filenamelidar.xacro /xacro:include filename/home/liuhongwei/Desktop/final/catkin_studyrobot/src/gazebo/move.xacro//robot就把刚刚加入就好。 2.1.3 修改launch文件 不需要修改 launchparam namerobot_description command$(find xacro)/xacro /home/liuhongwei/Desktop/final/catkin_studyrobot/src/urdf/xacro/car_gazebo.xacro /include file$(find gazebo_ros)/launch/empty_world.launcharg nameworld_name value/home/liuhongwei/Desktop/final/catkin_studyrobot/src/world/box_house.world //includenode pkggazebo_ros typespawn_model namemodel args-urdf -model mycar -param robot_description /
/launchroslaunch test gazebo_car.launch 2.1.3 启动 Gazebo 并发布 /cmd_vel 消息控制机器人运动 rostopic pub -r 10 /cmd_vel geometry_msgs/Twist {linear: {x: 0.2, y: 0, z: 0}, angular: {x: 0, y: 0, z: 0.5}} 机器人运动了 或者安装控制节点 sudo apt install ros-melodic-teleop-twist-keyboard rosrun teleop_twist_keyboard teleop_twist_keyboard.py 当然线速度、角速度比较快..... 我们可以通过传参降低速度 rosrun teleop_twist_keyboard teleop_twist_keyboard.py _speed:0.3 _turn:0.5 现在运动幅度就小多了。 2.3.4 里程计查看 我们要启动关节和机器人运动发布状态节点multisensor.launch launchnode pkgrviz typerviz namerviz args-d /home/liuhongwei/Desktop/final/catkin_studyrobot/src/config/qidong.rviz/node pkgrobot_state_publisher typerobot_state_publisher namerobot_state_publisher /node pkgjoint_state_publisher_gui typejoint_state_publisher_gui namejoint_state_publisher_gui /
/launch我们再打开之前的节点 launchparam namerobot_description command$(find xacro)/xacro /home/liuhongwei/Desktop/final/catkin_studyrobot/src/urdf/xacro/car_gazebo.xacro /include file$(find gazebo_ros)/launch/empty_world.launcharg nameworld_name value/home/liuhongwei/Desktop/final/catkin_studyrobot/src/world/box_house.world //includenode pkggazebo_ros typespawn_model namemodel args-urdf -model mycar -param robot_description /
/launch设置Fix Frame为odom。 我们打开键盘控制节点 都动啦 3 雷达仿真信息以及显示
3.1 实现流程 实现流程: 雷达仿真基本流程: 已经创建完毕的机器人模型编写一个单独的 xacro 文件为机器人模型添加雷达配置 将此文件集成进xacro文件 启动 Gazebo使用 Rviz 显示雷达信息。 3.2 为机器人模型添加雷达配置 我们需要把雷达贴到一个模块上 之前我们设置过lidar 如下 robot namemy_sensors xmlns:xacrohttp://wiki.ros.org/xacrogazebo referencelasersensor typeray namerplidarpose0 0 0 0 0 0/posevisualizetrue/visualizeupdate_rate5.5/update_raterayscanhorizontalsamples360/samplesresolution1/resolutionmin_angle-3/min_anglemax_angle3/max_angle/horizontal/scanrangemin0.10/minmax30.0/maxresolution0.01/resolution/rangenoisetypegaussian/typemean0.0/meanstddev0.01/stddev/noise/rayplugin namegazebo_rplidar filenamelibgazebo_ros_laser.sotopicName/scan/topicNameframeNamelaser/frameName/plugin/sensor/gazebo/robot完成 3.3 集成进xacro文件 robot namemycarwithlidarandcamera xmlns:xacrohttp://wiki.ros.org/xacroxacro:include filenameinterial.xacro /xacro:include filenamedemo05carbase.xacro /xacro:include filenamecam.xacro /xacro:include filenamelidar.xacro /xacro:include filename/home/liuhongwei/Desktop/final/catkin_studyrobot/src/gazebo/move.xacro/xacro:include filename/home/liuhongwei/Desktop/final/catkin_studyrobot/src/gazebo/laser.xacro//robot把雷达传感器集成进xacro。 3.4 启动 Gazebo使用 Rviz 显示雷达信息 启动双launch节点 /scan话题就是雷达话题。 gazebo中也有显示了。这是雷达的不可见扫描光束。 4 摄像头仿真
4.1 为机器人模型添加摄像头配置 robot namemy_sensors xmlns:xacrohttp://wiki.ros.org/xacrogazebo referencecamerasensor typecamera namecamera_nodeupdate_rate30.0/update_ratecamera nameheadhorizontal_fov1.3962634/horizontal_fovimagewidth1280/widthheight720/heightformatR8G8B8/format/imageclipnear0.02/nearfar300/far/clipnoisetypegaussian/typemean0.0/meanstddev0.007/stddev/noise/cameraplugin namegazebo_camera filenamelibgazebo_ros_camera.soalwaysOntrue/alwaysOnupdateRate0.0/updateRatecameraName/camera/cameraNameimageTopicNameimage_raw/imageTopicNamecameraInfoTopicNamecamera_info/cameraInfoTopicNameframeNamecamera/frameNamehackBaseline0.07/hackBaselinedistortionK10.0/distortionK1distortionK20.0/distortionK2distortionK30.0/distortionK3distortionT10.0/distortionT1distortionT20.0/distortionT2/plugin/sensor/gazebo
/robot4.2 为机器人模型添加相机配置 robot namemycarwithlidarandcamera xmlns:xacrohttp://wiki.ros.org/xacroxacro:include filenameinterial.xacro /xacro:include filenamedemo05carbase.xacro /xacro:include filenamecam.xacro /xacro:include filenamelidar.xacro /xacro:include filename/home/liuhongwei/Desktop/final/catkin_studyrobot/src/gazebo/move.xacro/xacro:include filename/home/liuhongwei/Desktop/final/catkin_studyrobot/src/gazebo/laser.xacro/xacro:include filename/home/liuhongwei/Desktop/final/catkin_studyrobot/src/gazebo/camera.xacro//robot 成功 5 深度相机Kinect仿真
5.1 为机器人模型添加深度相机配置 robot namemy_sensors xmlns:xacrohttp://wiki.ros.org/xacrogazebo referencesupport sensor typedepth namecameraalways_ontrue/always_onupdate_rate20.0/update_ratecamerahorizontal_fov${60.0*PI/180.0}/horizontal_fovimageformatR8G8B8/formatwidth640/widthheight480/height/imageclipnear0.05/nearfar8.0/far/clip/cameraplugin namekinect_camera_controller filenamelibgazebo_ros_openni_kinect.socameraNamecamera/cameraNamealwaysOntrue/alwaysOnupdateRate10/updateRateimageTopicNamergb/image_raw/imageTopicNamedepthImageTopicNamedepth/image_raw/depthImageTopicNamepointCloudTopicNamedepth/points/pointCloudTopicNamecameraInfoTopicNamergb/camera_info/cameraInfoTopicNamedepthImageCameraInfoTopicNamedepth/camera_info/depthImageCameraInfoTopicNameframeNamesupport/frameNamebaseline0.1/baselinedistortion_k10.0/distortion_k1distortion_k20.0/distortion_k2distortion_k30.0/distortion_k3distortion_t10.0/distortion_t1distortion_t20.0/distortion_t2pointCloudCutoff0.4/pointCloudCutoff/plugin/sensor/gazebo/robotrobot namemycarwithlidarandcamera xmlns:xacrohttp://wiki.ros.org/xacroxacro:include filenameinterial.xacro /xacro:include filenamedemo05carbase.xacro /xacro:include filenamecam.xacro /xacro:include filenamelidar.xacro /xacro:include filename/home/liuhongwei/Desktop/final/catkin_studyrobot/src/gazebo/move.xacro/xacro:include filename/home/liuhongwei/Desktop/final/catkin_studyrobot/src/gazebo/laser.xacro/xacro:include filename/home/liuhongwei/Desktop/final/catkin_studyrobot/src/gazebo/camera.xacro/xacro:include filename/home/liuhongwei/Desktop/final/catkin_studyrobot/src/gazebo/kinect.xacro//robot 启动! 5.2 kinect点云数据显示 在kinect中也可以以点云的方式显示感知周围环境在 rviz 中操作如下 添加PointCloud2点云但是显示错位了。 原因:在kinect中图像数据与点云数据使用了两套坐标系统且两套坐标系统位姿并不一致。 怎么解决呢 在插件中为kinect设置坐标系修改配置文件的frameName标签内容 发布新设置的坐标系到kinect连杆的坐标变换关系在启动rviz的launch中添加: launchnode pkgtf2_ros typestatic_transform_publisher namestatic_transform_publisher args0 0 0 -1.57 0 -1.57 /support /support_depth /node pkgrviz typerviz namerviz args-d /home/liuhongwei/Desktop/final/catkin_studyrobot/src/config/qidong.rviz/node pkgrobot_state_publisher typerobot_state_publisher namerobot_state_publisher /node pkgjoint_state_publisher_gui typejoint_state_publisher_gui namejoint_state_publisher_gui /
/launchOK