深圳坪山站,重庆市园林建设有限公司网站,wordpress 主页不显示图片,a网站建设目录 写在前面的话调用 libgazebo_ros_ackermann_drive.so 插件属性介绍补充 steering_wheel_joint 配置键盘控制命令 结果演示 写在前面的话
这里增加一个四轮阿克曼#xff08;前轮转向、后轮驱动#xff09;车子仿真控制的版本#xff0c;使用的事gazebo的插件
参考资料… 目录 写在前面的话调用 libgazebo_ros_ackermann_drive.so 插件属性介绍补充 steering_wheel_joint 配置键盘控制命令 结果演示 写在前面的话
这里增加一个四轮阿克曼前轮转向、后轮驱动车子仿真控制的版本使用的事gazebo的插件
参考资料gazebo plugins文档
调用 libgazebo_ros_ackermann_drive.so 插件
这段代码要添加到车子描述的xacro文件
属性介绍
plugin 声明调用的插件name可以随便ros 声明环境和话题映射update_rate 更新频率底盘车轮控制 front_left_joint 这些跟自身的车子进行匹配就行控制车轮转动的left_steering_joint 这是控制车轮转向的steering_wheel_joint 这个不是一个真正的轮子类似是车子的方向盘需要另外添加后面有代码补充 max_steer 车轮最大转向角度大约是37度弧度制0.6458max_steering_angle 方向盘steering_wheel_joint的最大转向角度大概一圈半弧度制7.85publish_wheel_tf 官方代码是true但github上很多代码是falserobot_base_frame 机器人的基准轴odometry_frame 里程计odom的链接 gazeboplugin namegazebo_ros_ackermann_drive filenamelibgazebo_ros_ackermann_drive.sorosnamespace/car_nav2/namespaceremappingcmd_vel:cmd_demo/remappingremappingodom:odom_demo/remappingremappingdistance:distance_demo/remapping/rosupdate_rate100.0/update_rate!-- wheels --front_left_jointleft_front_wheel_joint/front_left_jointfront_right_jointright_front_wheel_joint/front_right_jointrear_left_jointleft_back_wheel_joint/rear_left_jointrear_right_jointright_back_wheel_joint/rear_right_jointleft_steering_jointleft_front_orient_joint/left_steering_jointright_steering_jointright_front_orient_joint/right_steering_jointsteering_wheel_jointvirtual_steering_wheel_joint/steering_wheel_joint!-- Max absolute steer angle for tyre in radians--!-- Any cmd_vel angular z greater than this would be capped --max_steer0.6458/max_steer!-- Max absolute steering angle of steering wheel --max_steering_angle7.85/max_steering_angle!-- Max absolute linear speed in m/s --max_speed5/max_speed!-- PID tuning --left_steering_pid_gain1500 0 1/left_steering_pid_gainleft_steering_i_range0 0/left_steering_i_rangeright_steering_pid_gain1500 0 1/right_steering_pid_gainright_steering_i_range0 0/right_steering_i_rangelinear_velocity_pid_gain1000 0 1/linear_velocity_pid_gainlinear_velocity_i_range0 0/linear_velocity_i_range!-- output --publish_odomtrue/publish_odompublish_odom_tftrue/publish_odom_tfpublish_wheel_tffalse/publish_wheel_tfpublish_distancetrue/publish_distanceodometry_frameodom_demo/odometry_framerobot_base_framebase_link/robot_base_frame/plugin/gazebo补充 steering_wheel_joint 配置
需要把这段代码添加到车子描述的xacro文件中
virtual_steer_link 可以看到都是虚的惯性啥的都是0也就是不存在的virtual_steering_wheel_joint 这个设置是前轮的转向的中间位置z轴高度随意我这里两个左右两个车轮分别是0.22654 0.5868 -0.068 和 0.22654 -0.5868 -0.068跟 base_link 绑定上即可 !-- Virtual Steering wheel --link namevirtual_steer_linkvisualorigin xyz0.0 0.0 0.0 rpy0.0 0.0 0.0 /geometrybox size0.01 0.15 0.075 //geometrymaterial namecolor rgba1.0 1.0 0.0 1 //material/visualinertial !-- Gazebo wont show this link without this inertial mass --origin xyz0.0 0.0 0.0 rpy0.0 0.0 0.0 /mass value0.001 /inertia ixx0.0 ixy0.0 ixz0.0 iyy0.0 iyz0.0 izz0.0 //inertial/linkjoint namevirtual_steering_wheel_joint typerevoluteorigin xyz0.22654 0 0 rpy0.0 0.0 0.0 /parent linkbase_link /child linkvirtual_steer_link /axis xyz0 0 -1 /limit lower-3 upper3 effort200 velocity10 //joint
键盘控制命令
注意这里需要进行cmd_vel的进行映射因为我们在调用 gazebo 插件的时候进行了 remapping 映射可以查看上面的描述同时要加上命名空间namespace
ros2 run teleop_twist_keyboard teleop_twist_keyboard cmd_vel:/car_nav2/cmd_demo结果演示
前轮转向后轮驱动