Gazebo simulation and ros controller learning

Gazebo is a powerful simulator, especially suitable for robot motion and control simulation, but there are also many bugs

Official learning address: http://gazebosim.org/tutorials

Includes all the tutorials, from elementary intermediate to advanced level, you can also learn according to classification

Here mainly talk about the knowledge related to the ros controller.

Related address: http://gazebosim.org/tutorials/?tut=ros_control

I also got a general idea of ​​this picture: many of the contents are unavoidably obscure.

The main difference between the gazebo simulator and the real robot lies in the definition of the hardware interface, because I only use the gazebo simulator, so the real situation will not be involved. If necessary, please search for relevant information by yourself.

In the urdf robot model, you need to define transmission and joint, etc., and add the gazebo_ros_control plug-in, see

type里面:the type of transmission. Currently only "transmission_interface/SimpleTransmission

<hardwareInterface> The hardware interface here is EffortJointInterface, which can realize the position and speed controller based on power. In addition, there are JointStateInterface and VelocityJointInterface. The method of use is unknown.

Official example

 <transmission name="tran1">
    <type>transmission_interface/SimpleTransmission</type>
    <joint name="joint1">
      <hardwareInterface>EffortJointInterface</hardwareInterface>
    </joint>
    <actuator name="motor1">
      <hardwareInterface>EffortJointInterface</hardwareInterface>
      <mechanicalReduction>1</mechanicalReduction>
    </actuator>
  </transmission>

  <transmission name="tran2">
    <type>transmission_interface/SimpleTransmission</type>
    <joint name="joint2">
      <hardwareInterface>EffortJointInterface</hardwareInterface>
    </joint>
    <actuator name="motor2">
      <hardwareInterface>EffortJointInterface</hardwareInterface>
      <mechanicalReduction>1</mechanicalReduction>
    </actuator>
  </transmission>

In addition, a .yaml file is needed to load controller parameters, such as pid and speed acceleration limit position limit, etc.

rrbot:
  # Publish all joint states -----------------------------------
  joint_state_controller:
    type: joint_state_controller/JointStateController
    publish_rate: 50  

  # Position Controllers ---------------------------------------
  joint1_position_controller:
    type: effort_controllers/JointPositionController
    joint: joint1
    pid: {p: 100.0, i: 0.01, d: 10.0}
  joint2_position_controller:
    type: effort_controllers/JointPositionController
    joint: joint2
    pid: {p: 100.0, i: 0.01, d: 10.0}

Note that the joint name and type type correspond to transmission

Defined is the position controller

Below is the launch file

<launch>

  <!-- Load joint controller configurations from YAML file to parameter server -->
  <rosparam file="$(find rrbot_control)/config/rrbot_control.yaml" command="load"/>

  <!-- load the controllers -->
  <node name="controller_spawner" pkg="controller_manager" type="spawner" respawn="false"
    output="screen" ns="/rrbot" args="joint1_position_controller joint2_position_controller joint_state_controller"/>

  <!-- convert joint states to TF transforms for rviz, etc -->
  <node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher"
    respawn="false" output="screen">
    <remap from="/joint_states" to="/rrbot/joint_states" />
  </node>

</launch>

The robot_state_publisher here subscribes to the joint information to publish the robot state

You can use rosrun rqt_gui rqt_gui to check whether all topics are published normally.

The position of ros_controller can be controlled by instructions:

rostopic pub /pxdx/joint1_position_controller/command std_msgs/Float64 "data: 0.9"
rostopic pub /pxdx/joint2_position_controller/command std_msgs/Float64 "data: 0.9"

Or through cmd_vel instruction to control the movement

 rosrun teleop_twist_keyboard teleop_twist_keyboard.py /cmd_vel:=/pxdx/cmd_vel

There are two ways to publish the joint_state topic:

.Method 1: Load joint_state_controller in the .yaml file, add joint_state_controller in the launch file, but only the joint with transmission can be released

.Method 2: Through the gazebo plug-in can publish all the added joints

<gazebo>
    <plugin filename="libgazebo_ros_control.so" name="ros_control">
    </plugin>
    <plugin name="joint_state_publisher" filename="libgazebo_ros_joint_state_publisher.so">
      <jointName>
          bh_j11_joint, bh_j12_joint, bh_j13_joint, bh_j21_joint, bh_j22_joint, bh_j23_joint,
          bh_j32_joint, bh_j33_joint, elbow_joint, shoulder_lift_joint, shoulder_pan_joint,
          wrist_1_joint, wrist_2_joint, wrist_3_joint
      </jointName>
      <updateRate>50</updateRate>
      <alwaysOn>true</alwaysOn>
    </plugin>
  </gazebo>

At present, the two do not conflict.

Guess you like

Origin blog.csdn.net/li4692625/article/details/112798542