Creating a ROS workspace for dependencies

Before starting to install the usb_cam package, let's create a ROS workspace for storing the dependencies of all the projects mentioned in the section. We can create another workspace for keeping the project code.

Create a ROS workspace called ros_project_dependencies_ws in the home folder. Clone the usb_cam package into the src folder:

    $ git clone https://github.com/bosch-ros-pkg/usb_cam.git

Build the workspace using catkin_make.

After building the package, install the v4l-util Ubuntu package. It is a collection of command-line V4L utilities used by the usb_cam package:

    $ sudo apt-get install v4l-utils

Configuring a webcam on Ubuntu 16.04

After installing these two, we can connect the webcam to the PC to check whether it is properly detected by our PC.

Open a Terminal and execute the dmesg command to check the kernel logs. If your camera is detected in Linux, it may give you logs like this:

    $ dmesg

Figure 1: Kernels logs of the webcam device

You can use any webcam that has driver support in Linux. In this project, an iBall Face2Face (http://www.iball.co.in/Product/Face2Face-C8-0--Rev-3-0-/90) webcam is used for tracking. You can also go for the popular Logitech C310 webcam mentioned as a hardware prerequisite. You can opt for that for better performance and tracking.

If our webcam has support in Ubuntu, we can open the video device using a tool called Cheese. Cheese is simply a webcam viewer.

Enter the command cheese in the Terminal. If it is not installed, you can install it using the following command:

    $ sudo apt-get install cheese

If the driver and device are proper, you will get a video stream from the webcam, like this:

Figure 2: Webcam video streaming using Cheese

Congratulations! Your webcam is working well in Ubuntu, but are we done with everything? No. The next thing is to test the ROS usb_cam package. We have to make sure that it's working well in ROS!

The complete source code of this project can be cloned from the following Git repository. The following command will clone the project repo: $ git clone https://github.com/qboticslabs/ros_robotics_projects

Interfacing the webcam with ROS

Let's test the webcam using the usb_cam package. The following command is used to launch the usb_cam nodes to display images from a webcam and publish ROS image topics at the same time:

    $ roslaunch usb_cam usb_cam-test.launch

If everything works fine, you will get the image stream and logs in the Terminal, as shown here:

Figure 3: Working of the usb_cam package in ROS

The image is displayed using the image_view package in ROS, which is subscribed to the topic called /usb_cam/image_raw.

Here are the topics that usb_cam node is publishing:

Figure 4: The topics being published by the usb_cam node

We've finished interfacing a webcam with ROS. So what's next? We have to interface an AX-12 Dynamixel servo with ROS. Before proceeding to interfacing, we have to do something to configure this servo.

Next, we are going to see how to configure a Dynamixel AX-12A servo.

Configuring a Dynamixel servo using RoboPlus

The Dynamixel servo can be configured using a program called RoboPlus, provided by ROBOTIS INC (http://en.robotis.com/index/), the manufacturer of Dynamixel servos.

To configure Dynamixel, you have to switch your operating system to Windows. The RoboPlus tool works on Windows. In this project, we are going to configure the servo in Windows 7.

Here is the link to download RoboPlus:

http://www.robotis.com/download/software/RoboPlusWeb%28v1.1.3.0%29.exe

If the link is not working, you can just search in Google for RoboPlus 1.1.3. After installing the software, you will get the following window. Navigate to the Expert tab in the software to get the application for configuring Dynamixel:

Figure 5: Dynamixel manager in RoboPlus

Before starting Dynamixel Wizard and configuring, we have to connect the Dynamixel and properly power it up. The following are images of the AX-12A servo we are using for this project and a diagram of its pin connection:

Figure 6: The AX-12A Dynamixel and its connection diagram

Unlike other RC servos, AX-12 is an intelligent actuator having a microcontroller that can monitor every parameter of a servo and customize all of them. It has a geared drive, and the output of the servo is connected to a servo horn. We can connect any link to this servo horn. There are two connection ports behind each servo. Each port has pins such as VCC, GND, and Data. The ports of the Dynamixel are daisy-chained, so we can connect one servo to another servo. Here is the connection diagram of the Dynamixel with a computer:

Figure 7: The AX-12A Dynamixel and its connection diagram

The main hardware component interfacing Dynamixel with the PC is called a USB-to-Dynamixel adapter. This is a USB-to-serial adapter that can convert USB to RS232, RS 484, and TTL. In AX-12 motors, data communication is done using TTL. From the previous figure, we can see that there are three pins in each port. The data pin is used to send to and receive from AX-12, and power pins are used to power the servo. The input voltage range of the AX-12A Dynamixel is from 9V to 12V. The second port in each Dynamixel can be used for daisy chaining. We can connect up to 254 servos using such chaining.

Official links of the AX-12A servo and USB-to-Dynamixel adapter: AX-12A: http://www.trossenrobotics.com/dynamixel-ax-12-robot-actuator.aspx USB-to-Dynamixel: http://www.trossenrobotics.com/robotis-bioloid-usb2dynamixel.aspx

To work with Dynamixel, we should know some more things. Let's have a look at some of the important specifications of the AX-12A servo. The specifications are taken from the servo manual.

Figure 8: AX-12A specifications

The Dynamixel servo can communicate with the PC at a maximum speed of 1 Mbps. It can also provide feedback about various parameters, such as its position, temperature, and current load. Unlike RC servos, this can rotate up to 300 degrees, and communication is mainly done using digital packets.

Powering and connecting the Dynamixel to a PC

Now, we are going to connect the Dynamixel to a PC. The following is a standard way of doing that:

Figure 9: Connecting the Dynamixel to a PC

The three-pin cable is first connected to any of the ports of the AX-12, and the other side has to connect to a six-port power hub. From the six-port power hub, connect another cable to the USB-to-Dynamixel. We have to set the switch of the USB-to-Dynamixel to TTL mode. The power can be either be connected through a 12V adapter or through a battery. The 12V adapter has a 2.1 x 5.5 female barrel jack, so you should check the specifications of the male adapter plug while purchasing.

Setting up the USB-to-Dynamixel driver on the PC

We have already discussed that the USB-to-Dynamixel adapter is a USB-to-serial converter with an FTDI chip (http://www.ftdichip.com/) on it. We have to install a proper FTDI driver on the PC in order to detect the device. The driver is required for Windows but not for Linux, because FTDI drivers are already present in the Linux kernel. If you install the RoboPlus software, the driver may already be installed along with it. If it is not, you can manually install from the RoboPlus installation folder.

Plug the USB-to-Dynamixel into the Windows PC, and check Device Manager. (Right-click on My Computer and go to Properties | Device Manager). If the device is properly detected, you'll see something like this:

Figure 10: COM port of the USB-to-Dynamixel

If you are getting a COM port for the USB-to-Dynamixel, you can start Dynamixel manager from RoboPlus. You can connect to the serial port number from the list and click on the Search button to scan for Dynamixel, as shown in the next screenshot.

Select the COM port from the list, and connect to the port marked 1. After connecting to the COM port, set the default baud rate to 1 Mbps, and click on the Start searching button:

Figure 11: COM Port of the USB-to-Dynamixel

If you are getting a list of servos in the left-hand side panel, it means that your PC has detected a Dynamixel servo. If the servo is not being detected, you can perform the following steps to debug:

  1. Make sure that the supply and connections are proper using a multimeter. Make sure that the servo LED on the back is blinking when power is on; if it is not coming on, it can indicate a problem with the servo or power supply.
  2. Upgrade the firmware of the servo using Dynamixel manager from the option
    marked 5.The wizard is shown in the next set of screenshots. While using the wizard, you may need to power off the supply and turn it back on in order to detect the servo.
  1. After detecting the servo, you have to select the servo model and install the new firmware. This may help you detect the servo in Dynamixel manager if the existing servo firmware is outdated.
Figure 12: The Dynamixel recovery wizard

If the servos are being listed in Dynamixel Manager, click on one, and you can see its complete configuration. We have to modify some values inside the configurations for our current face-tracker project. Here are the parameters:

  • ID: Set the ID to 1
  • Baud rate: 1
  • Moving Speed: 100
  • Goal Position: 512

 

The modified servo settings are shown in the following figure:

Figure 13: Modified Dynamixel firmware settings

After making these settings, you can check whether the servo is working well or not by changing its Goal position.

Nice! You are done configuring Dynamixel; congratulations! What next? We'll want to interface Dynamixel with ROS.

The complete source code of this project can be cloned from the following Git repository. The following command will clone the project repo: $ git clone https://github.com/qboticslabs/ros_robotics_projects
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.103.10