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里面需要运动的关节都需要添加
反正你的轮子转向的时候又不需要模拟出轮胎的转向,但是如果你需要模拟出小车转向的时候,
轮胎的转动,这个时候就需要在轮胎关节部分---joint部分添加
在书里面好像是关节只要定义运动方式就可以了,也没有说要添加Transmissions
切换行号显示
12 transmission_interface/SimpleTransmission 34 61 57 9hardware_interface/PositionJointInterface 8
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.
// / / //
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.
切换行号显示
12 3 4 5 6 7
roslaunch urdf_sim_tutorial 10-head.launch model:=urdf/11-limittransmission.urdf.xacro