(!) Please ask about problems and questions regarding this tutorial on answers.ros.org. Don't forget to include in your question the link to this page, the versions of your OS & ROS, and also add appropriate tags.

Creating a Simple Hardware Driver

Description: This tutorial shows how to create a simple hardware driver that connects via serial to a Parallax RFID Card Reader.

Tutorial Level: INTERMEDIATE

This tutorial is under construction

Introduction

Concept

This tutorial will show how to create a simple hardware driver for the Parallax RFID card reader that broadcasts RFID transponder tag IDs on a topic when they are detected. This information can then be used in a variety of ways by other nodes to identify people, objects or locations.

Setup

If you haven't done so already, create a directory for your repository and add it to your ROS_PACKAGE_PATH. To make the change permanent you can add the export statement to your .bashrc after it sources the setup.bash file.

$ cd ~/ros
$ mkdir mylab-ros-pkg
$ export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:~/ros/mylab-ros-pkg

Next create a separate stack to contain RFID related packaged.

$ cd ~/ros/mylab-ros-pkg
$ roscreate-stack mylab_rfid

Next edit ~/ros/mylab-ros-pkg/mylab_rfid/stack.xml file to have the appropriate information.

<stack>
  <description brief="mylab_rfid">RFID Driver and Tools</description>
  <author>Maintained by My Robotics Lab</author>
  <license>BSD</license>
  <review status="unreviewed" notes=""/>
  <url>http://ros.org/wiki/mylab_rfid</url>
  <depend stack="ros" />
</stack>

Since we want to use libserial to talk to the serial port we need to add that as a dependency. First we can check if it defined anywhere else.

$ rosdep where_defined libserial

Since dependencies are handled at the stack level we need to edit ~/ros/mylab-ros-pkg/mylab_rfid/rosdep.yaml so that it looks like this.

libserial:
  ubuntu: libserial-dev
  debian: libserial-dev

Next we create the package for the driver. Since we will be writing it in C++, we specify roscpp as a dependency.

$ roscreate-pkg parallax_rfid roscpp

Switch to the package directory and we can begin setting up the package.

$ cd ~/ros/mylab-ros-pkg/mylab_rfid/parallax_rfid

The manifest.xml file in ~/ros/mylab-ros-pkg/mylab_rfid/parallax_rfid should look something like this.

<package>
  <description brief="Parallax RFID Card Reader">
    Driver for Parallax 125kHz RFID Card Reader
  </description>
  <author>Me Myself</author>
  <license>BSD</license>
  <review status="unreviewed" notes=""/>
  <url>http://ros.org/wiki/parallax_rfid</url>
  <depend package="roscpp"/>
  <rosdep name="libserial"/>
</package>

Next, wait for the rest of the tutorial to be written

Wiki: vn/ROS/Hướng dẫn/Creating a Simple Hardware Driver (last edited 2017-03-30 07:34:58 by HoangGiang88)