[Documentation] [TitleIndex] [WordIndex

Overview

The android_base_controller is useful when using Android as the main robot computer, instead of just for controller a PC based ROS robot.

This package provides three nodes:

It is design to be easily extended to support different robotic bases, currently it supports:

This package works with Android devices which support USB host mode (or USB OTG). It has been tested on:

Usage

Launching the nodes

Add the required packages (this is done automatically by the IDE):

   1 // USB library used
   2 import com.hoho.android.usbserial.driver.UsbSerialDriver;
   3 import com.hoho.android.usbserial.driver.UsbSerialProber;
   4 // To create a Kobuki controller
   5 import com.github.c77.base_controller.BaseControllerNode;
   6 import com.github.c77.base_controller.BaseStatusPublisher;
   7 import com.github.c77.base_controller.BaseOdomPublisher;
   8 import com.github.c77.base_driver.kobuki.KobukiBaseDevice;

If extending RosActivity to create the application, in the init method you would need to add something like this:

   1 // Get UsbManager from Android.
   2 UsbManager manager = (UsbManager) getSystemService(Context.USB_SERVICE);
   3 // Find the first available driver.
   4 UsbSerialDriver driver = UsbSerialProber.findFirstDevice(manager);
   5 // Create the low level base device.
   6 baseDevice = new KobukiBaseDevice(driver);
   7 // Attach it to the controller node.
   8 baseControllerNode = new BaseControllerNode(baseDevice, "/cmd_vel");
   9 NodeConfiguration baseControllerNodeConf = NodeConfiguration.newPublic(host);
  10 nodeMainExecutor.execute(baseControllerNode, baseControllerNodeConf);
  11 // Publish the base odometry information.
  12 baseOdomPublisher = new BaseOdomPublisher(baseDevice);
  13 NodeConfiguration odomPublisherNodeConf = NodeConfiguration.newPublic(host);
  14 nodeMainExecutor.execute(baseOdomPublisher, odomPublisherNodeConf);

Gradle dependency

This package is a Catkin-Gradle package. To use it in your rosjava project you need to add the dependency to your build.gradle file:

compile 'com.github.creativa77.base_controller:base_controller:0.1.+'

Adding a new base

The controller is design to provide always the same API, no matter what base it is connected to.

The package is separated in two parts, the base_controller which is base-independant and the base_driver, where we find the required Interfaces and the implementation for the different bases that the package supports.

To add a new base, a new base_driver should be created, implementing the BaseDevice interface by overriding the following methods:

   1     /**
   2      * initialize the base. This method should is called by the node
   3      * before sending movement commands.
   4      */
   5     void initialize();
   6 
   7     /**
   8      * moves the base. The argument values are the ones
   9      * transmitted in a twist message.
  10      * @param linearVelX: linear speed
  11      * @param angVelZ: rotational speed
  12      */
  13     void move(double linearVelX, double angVelZ);
  14 
  15     /**
  16      * @return: The base status updated with the latest base information.
  17      */
  18     BaseStatus getBaseStatus();
  19 
  20     /**
  21      * @return: The odometry information published by the base.
  22      */
  23     OdometryStatus getOdometryStatus();

When programming a new base driver the developer may need to create helper classes. Those classes should be grouped in a directory with the name of the base. Currently, there are three folders containing the driver implementation for the Husky, the Kobuki and the Create.

Serial Communication

The required serial USB communication is entirely handled in the low level base specific drivers, which means that each driver could use different USB libraries, or don't use USB at all.

The Create, Kobuki and Husky drivers use the same USB serial library for Android. Though as stated above using this library is not required for new drivers.


2024-12-07 13:06