ros_control

按照官网调试时候遇到了各种bug,主要是却依赖,安装gazebo_ros_pkgs+toolbox+realtime_tool等几个包之后就好了,在github下载时,记得选择正确的版本!!


We add a <transmission> block similar to the following for every joint that we wish to have Gazebo actuate. Note that the<hardwareInterface> must be included in both the <joint> and <actuator> tags (see ros_control issue here). Open yourrrbot.xacro file and at the bottom of the file you should see:

1、在rrbot.xacro文件下添加标签<transmission>.在每个想要添加启动器的关节处,需要添加标签<transmission>,这个标签中的《joint》和《actuator》中都要添加《hardwareInterface》标签

  <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>

You'll also see the gazebo_ros_control plugin in rrbot.gazebo that reads in all the <transmission> tags:

2、在文件rrbot.gazebo中也要添加gazebo_ros_control的插件说明

<gazebo>
  <plugin name="gazebo_ros_control" filename="libgazebo_ros_control.so">
    <robotNamespace>/rrbot</robotNamespace>
  </plugin>
</gazebo>

The PID gains and controller settings must be saved in a yaml file that gets loaded to the param server via the roslaunch file. In the config folder of your MYROBOT\_control package, adapt the following RRBot example to your robot asMYROBOT_control/config/rrbot_control.yaml:

3、新建一个功能包叫myrobot_control,下方建立config文件夹,新建一个rrbot_control.yaml的配置文件,用于给参数服务器载入ros_controller的PID参数

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}

Create a roslaunch file

Create a roslaunch file for starting the ros_control controllers. Within the launch folder create aMYROBOT_control/launch/MYROBOT_control.launch file and adapt the following RRBot example to your robot:

4、在myrobot_control建立launch文件夹,并书写launch文件如下:

<launch>

  <!-- Load joint controller configurations from YAML file to parameter server -->
<!--这里应该是给ros的参数服务load你的参数文件,把对应名称的参数都load到ros参数服务器里-->
  <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>

猜你喜欢

转载自blog.csdn.net/qq_33179208/article/details/70822553
ROS