Day 2: Enable the robot

The goal of this post is to make the robot drivable.

Platform

  • Ubuntu 14.04
  • ROS indigo

Source

Sources for this tutorial can be found on GitHub

Prepare the repo

git checkout master
git branch day2_enable_robot
git push --set-upstream origin day2_enable_robot

Now in a new branch we start working on enabling the robot.

Connect your robot to ROS

Alright, our robot is all nice and has this new car smell, but we can’t do anything with it yet as it has no connection with ROS. In order to add this connection we need to add gazebeo plugins to our model. There are different kinds of plugins:

  • World: Dynamic changes to the world, e.g. Physics, like illumination or gravity, inserting models
  • Model: Manipulation of models (robots), e.g. move the robots
  • Sensor: Feedback from virtual sensor, like camera, laser scanner
  • System: Plugins that are loaded by the GUI, like saving images

First of all we’ll use a plugin to provide access to the joints of the wheels. The transmission tags in our URDF will be used by this plugin the define how to link the joints to controllers. To activate the plugin, add the following to mybot.gazebo:

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

Look at this tutorial for more information on how this plugin works.

With this plugin, we will be able to control the joints, however we need to provide some extra configuration and explicitely start controllers for the joints. In order to do so, we’ll use the package mybot_control that we have defined before. Let’s first create the configuration file:

roscd mybot_control
mkdir config
cd config
gedit mybot_control.yaml

This file will define three controllers: one for each wheel, connections to the joint by the transmission tag, one for publishing the joint states. It also defined the PID gains to use for this controller:

mybot:
# Publish all joint states -----------------------------------
joint_state_controller:
type: joint_state_controller/JointStateController
publish_rate: # Effort Controllers ---------------------------------------
leftWheel_effort_controller:
type: effort_controllers/JointEffortController
joint: left_wheel_hinge
pid: {p: 100.0, i: 0.1, d: 10.0}
rightWheel_effort_controller:
type: effort_controllers/JointEffortController
joint: right_wheel_hinge
pid: {p: 100.0, i: 0.1, d: 10.0}

Now we need to create a launch file to start the controllers. For this let’s do:

roscd mybot_control
mkdir launch
cd launch
gedit mybot_control.launch

In this file we’ll put two things. First we’ll load the configuration and the controllers, and we’ll also start a node that will provide 3D transforms (tf) of our robot. This is not mandatory but that makes the simulation more complete:

<launch>

  <!-- Load joint controller configurations from YAML file to parameter server -->
<rosparam file="$(find mybot_control)/config/mybot_control.yaml" command="load"/> <!-- load the controllers -->
<node name="controller_spawner"
pkg="controller_manager"
type="spawner" respawn="false"
output="screen" ns="/mybot"
args="joint_state_controller
rightWheel_effort_controller
leftWheel_effort_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">
<param name="robot_description" command="$(find xacro)/xacro.py '$(find mybot_description)/urdf/mybot.xacro'" />
<remap from="/joint_states" to="/mybot/joint_states" />
</node> </launch>

We could launch our model on gazebo and then launch the controller, but to save some time (and terminals), we’ll start the controllers automatically by adding a line to the “mybot_world.launch” in the mybot_gazebo package :

<!-- ros_control mybot launch file -->
<include file="$(find mybot_control)/launch/mybot_control.launch" />

Now launch your simulations. In a separate terminal, if you do a “rostopic list” you should see the topics corresponding to your controllers. You can send commands manually to your robot:

  rostopic pub - /mybot/leftWheel_effort_controller/command std_msgs/Float64 "data: 1.5"
rostopic pub - /mybot/rightWheel_effort_controller/command std_msgs/Float64 "data: 1.0"

The robot should start moving. Congratulations, you can now control your joints through ROS ! You can also monitor the joint states by doing :

  rostopic echo /mybot/joint_states 

Issue 1

Failed to load plugin libgazebo_ros_control.so

the installation of this packages cleared out all errors for me (tested under indigo) :

  • ros-indigo-youbot-gazebo-robot
  • ros-indigo-youbot-gazebo-control
  • ros-indigo-youbot-description
  • ros-indigo-youbot-driver
  • ros-indigo-youbot-driver-ros-interface
  • ros-indigo-youbot-gazebo-worlds
  • ros-indigo-youbot-simulation
  • ros-indigo-gazebo-ros-control
  • ros-indigo-effort-controllers
  • ros-indigo-joint-state-controller
  • ros-indigo-joint-trajectory-controller

copy/paste command:

sudo apt-get install ros-indigo-youbot-gazebo-robot ros-indigo-youbot-gazebo-control ros-indigo-youbot-description ros-indigo-youbot-driver ros-indigo-youbot-driver-ros-interface ros-indigo-youbot-gazebo-worlds ros-indigo-youbot-simulation ros-indigo-gazebo-ros-control ros-indigo-effort-controllers ros-indigo-joint-state-controller ros-indigo-joint-trajectory-controller

Issue 2

No valid hardware interface element found in joint

In macro.xacro:

modify

    <transmission name="${lr}_trans">
<type>transmission_interface/SimpleTransmission</type>
<joint name="${lr}_wheel_hinge"/>
<actuator name="${lr}Motor">
<hardwareInterface>EffortJointInterface</hardwareInterface>
<mechanicalReduction></mechanicalReduction>
</actuator>
</transmission>

as

    <transmission name="${lr}_trans">
<type>transmission_interface/SimpleTransmission</type>
<joint name="${lr}_wheel_hinge">
<hardwareInterface>EffortJointInterface</hardwareInterface>
</joint>
<actuator name="${lr}Motor">
<hardwareInterface>EffortJointInterface</hardwareInterface>
<mechanicalReduction></mechanicalReduction>
</actuator>
</transmission>

Teleoperation of your robot

Ok you can control joints individually, but that’s not so convenient when you want to make your mobile robot move around. Let’s use another plugin called differential drive to make it easier. Add this in the gazebo file of your model :

<gazebo>
<plugin name="differential_drive_controller" filename="libgazebo_ros_diff_drive.so">
<alwaysOn>true</alwaysOn>
<updateRate></updateRate>
<leftJoint>left_wheel_hinge</leftJoint>
<rightJoint>right_wheel_hinge</rightJoint>
<wheelSeparation>${chassisWidth+wheelWidth}</wheelSeparation>
<wheelDiameter>${*wheelRadius}</wheelDiameter>
<torque></torque>
<commandTopic>mybot/cmd_vel</commandTopic>
<odometryTopic>mybot/odom_diffdrive</odometryTopic>
<odometryFrame>odom</odometryFrame>
<robotBaseFrame>footprint</robotBaseFrame>
</plugin>
</gazebo>

This plugin will subscribe to the cmd_vel topic specified with the « commandTopic » tag and convert the messages to the proper commands on the wheels. It also provides some odometry data.

Now, you can start gazebo with the usual launch file.

To teleoperate your robot with the keybord you can use a teleoperation node as provided in turtlesim or turtlebot packages. We just need to remap the topic name to connect it to our robot :

    rosrun turtlesim turtle_teleop_key /turtle1/cmd_vel:=/mybot/cmd_vel
rosrun turtlebot_teleop turtlebot_teleop_key /turtlebot_teleop/cmd_vel:=/mybot/cmd_vel

Enjoy the ride !

Issue

package "turtlebot_teleop" is not found

Fix by typing

sudo apt-get install ros-indigo-turtlebot-teleop

References

  1. [Tutorial] Simulating Sensors in Gazebo (part 2)
  2. Gazebo Plugin Library
  3. Gazebo Camera Tutorial

Making my own Autonomous Robot in ROS / Gazebo, Day 2: Enable the robot的更多相关文章

  1. Making my own Autonomous Robot in ROS / Gazebo, Day 1: Building the static model

    Day 1: Setting up ROS: Indigo OS: Ubuntu 14.04 OS: Gazebo 7.0.0 Initialize the workspace To create t ...

  2. Gazebo Ros入门

    教程代码 First step with gazebo and ros • setup a ROS workspace • create projects for your simulated rob ...

  3. Gazebo機器人仿真學習探索筆記(七)连接ROS

    中文稍后补充,先上官方原版教程.ROS Kinetic 搭配 Gazebo 7 附件----官方教程 Tutorial: ROS integration overview As of Gazebo 1 ...

  4. ROS常用三維機器人仿真工具Gazebo教程匯總

    參考網址: 1. http://gazebosim.org/tutorials 2. http://gazebosim.org/tutorials/browse Gazebo Tutorials Ga ...

  5. Robot Operating System (ROS)学习笔记2---使用smartcar进行仿真

    搭建环境:XMWare  Ubuntu14.04  ROS(indigo) 转载自古月居  转载连接:http://www.guyuehome.com/248 一.模型完善 文件夹urdf下,创建ga ...

  6. ROS学习笔记十二:使用gazebo在ROS中仿真

    想要在ROS系统中对我们的机器人进行仿真,需要使用gazebo. gazebo是一种适用于复杂室内多机器人和室外环境的仿真环境.它能够在三维环境中对多个机器人.传感器及物体进行仿真,产生实际传感器反馈 ...

  7. Gazebo與ROS版本說明

    使用哪种ROS / Gazebo版本的组合 介绍 本文档提供了有关将不同版本的ROS与不同版本的Gazebo结合使用的选项的概述.建议在安装Gazebo ROS包装之前阅读它.重要!简单的分析,快速和 ...

  8. 在ROS Kinetic和Gazebo 8中使用智能汽车仿真演示

    在ROS Kinetic和Gazebo 8中使用智能汽车仿真演示 智能车无人驾驶技术是目前人工智能和机器人技术的研究热点,有许多开源平台可以使我们零基础零成本入门无人驾驶技术.本文分享一下目前ROS官 ...

  9. getting started with building a ROS simulation platform for Deep Reinforcement Learning

    Apparently, this ongoing work is to make a preparation for futural research on Deep Reinforcement Le ...

随机推荐

  1. Hadoop平台常用配置及优化建议

    当发现作业运行效率不理想时,需要对作业执行进行性能监测,以及对作业本身.集群平台进行优化.优化后的集群可能最大化利用硬件资源,从而提高作业的执行效率.本文记录了在hadoop集群平台搭建以及作业运行过 ...

  2. GPS部标监控平台的功能设计(一)-功能列表

    在2011年交通部的796标准推出后,随着各地交管部门的硬性要求,大多数的GPS监控系统或者车辆管理系统或者物流管理系统,无论是旧的,还是新开发的,都必须要以796标准为基础蓝本,首先要满足796的要 ...

  3. JSP中动态INCLUDE与静态INCLUDE的区别

    动态INCLUDE 用法: <jsp:include page="included.jsp" flush="true" /> 说明: 它总是会检查所 ...

  4. 「JavaScript」四种跨域方式详解

    超详细并且带 Demo 的 JavaScript 跨域指南来了! 本文基于你了解 JavaScript 的同源策略,并且了解使用跨域跨域的理由. 1. JSONP 首先要介绍的跨域方法必然是 JSON ...

  5. MXNet学习~试用卷积~跑CIFAR-10

    第一次用卷积,看的别人的模型跑的CIFAR-10,不过吐槽一下...我觉着我的965m加速之后比我的cpu算起来没快多少..正确率64%的样子,没达到模型里说的75%,不知道问题出在哪里 import ...

  6. spring-cloud-event-sourcing-example-master 运行效果及说明

    1.微服务架构下电商示例,部署成功!监控等技术细节未深入研究.      简单介绍:             配置服务(config-service ),端口8888,健康检查 xx:8888/hea ...

  7. iOS 推送小记

    ios做推送功能时,最烦得就是各种证书的问题,以前自己做的时候经常要反复搞那些证书搞好几遍才能成功,现在发现归根到底都是appid这个东西搞错了,做个笔记记下来,以免忘了. 首先是程序里面注册推送的变 ...

  8. N久没写过东西了..写个最近在研究的程序

    import numpy as np import matplotlib.pyplot as plt #a = np.matrix([[1,1.15],[1,1.9],[1,3.06],[1,4.66 ...

  9. C# 自动Ping服务

    using Newtonsoft.Json; using Newtonsoft.Json.Linq; using System; using System.Collections.Generic; u ...

  10. Good Bye 2015 D. New Year and Ancient Prophecy

    D. New Year and Ancient Prophecy time limit per test 2.5 seconds memory limit per test 512 megabytes ...