(ros2/ros)__urdf文件: <Transmissions>

Transmissions()

For every non-fixed joint, we need to specify a transmission, which tells Gazebo what to do with the joint. Let's start with the head joint. Add the following to your URDF:

不看不知道,每个在gazebo里面需要运动的关节都需要添加标签,例如如果你有一个小车只是需要移动位置,可以只在地盘的base_footprint添加一个就可以了,

反正你的轮子转向的时候又不需要模拟出轮胎的转向,但是如果你需要模拟出小车转向的时候,

轮胎的转动,这个时候就需要在轮胎关节部分---joint部分添加,这样gazebo里面的-------那个书里面好像不是这么写的啊,书里面就没有Transmissions,

        在书里面好像是关节只要定义运动方式就可以了,也没有说要添加Transmissions

切换行号显示

  1   
  2     transmission_interface/SimpleTransmission
  3     
  4       1
  5     
  6     
  7       hardware_interface/PositionJointInterface
  8     
  9   
  • For introductory purposes, just treat most of this chunk of code as boilerplate.
  • The first thing to note is the joint element. The name should match the joint declared earlier.
  • The hardwareInterface will be important as we explore the plugins.

You can run this URDF with our previous launch configuration.  roslaunch urdf_sim_tutorial 09-joints.launch model:=urdf/10-firsttransmission.urdf.xacro  

Now, the head is displayed properly in RViz because the head joint is listed in the joint_states messages.

header:
  seq: 220
  stamp:
    secs: 4
    nsecs: 707000000
  frame_id: ''
name: ['head_swivel']
position: [-2.9051283156888985e-08]
velocity: [7.575990694887896e-06]
effort: [0.0]

We could continue adding transmissions for all the non-fixed joints (and we will) so that all the joints are properly published. But, there's more to life than just looking at robots. We want to control them. So, let's get another controller in here.

//                                                /                   /                                                 //

Joint Control()

Here's the next controller config we're adding.

type: "position_controllers/JointPositionController"
joint: head_swivel

This specifies to use the a JointPositionController from the position_controllers package to control the head_swivel transmission. Note that hardware interface in the URDF for this joint matches the controller type.

Now we can launch this with the added config as before  roslaunch urdf_sim_tutorial 10-head.launch 

Now Gazebo is subscribed to a new topic, and you can then control the position of the head by publishing a value in ROS. rostopic pub /r2d2_head_controller/command std_msgs/Float64 "data: -0.707"

When this command is published, the position will immediately change to the specified value. This is because we did not specify any limits for the joint in our urdf. However, if we change the joint, it will move gradually.

切换行号显示

  1   
  2     
  3     
  4     
  5     
  6     
  7   

 roslaunch urdf_sim_tutorial 10-head.launch model:=urdf/11-limittransmission.urdf.xacro

你可能感兴趣的:(ros2,机器人,gazebo)