Controlling SparkV using Android phone's accelerometer

After integrating ROS and SparkV robot, its very easy to control the SparkV robot using Android phone's accelerometer. The prerequisite for this tutorial is basic understanding of ROS and my previous tutorial of integrating ROS and SparkV.

Package summary :

sparkV_android is a basic ROS package that subscribes to imu messages published by phone and according to the phone's orientation publishes motion command to sparkV robot.

Installation:

First install the ROS android sensor driver app from android market.

After that you have to connect your phone and computer to same network. For this you can check this tutorial. OR simply you can start a portable WiFi hotspot from your android device and connect your laptop to that network. After that open a new terminal and write

ifconfig

You will see your IP address in wlan tab as

inet addr:YOUR-IP

Now enter this IP address as http://YOUR-IP:11311/ in the app and start the app.

To verify the topics, try

roscore
rostopic list
Somewhere in the list of topics you will see /android/fix and /android/imu. You can analyze how the accelerometer data chances with change in your phone orientation by
rostopic echo /android/imu
After this download the [sparkV_android](https://github.com/playwithrobots/sparkV_android "SparkV_android github") and [sparkV_msg](https://github.com/playwithrobots/sparkV_msg "sparkV_msg Github") package and make them. **Published topics:** motor ([sparkV_msg/velocity](/ros-and-sparkv#velocity)):

Sends velocity commands to SparkV robot.

**Subscribed topics:** android/imu ([sensor_msgs/Imu](http://www.ros.org/doc/api/sensor_msgs/html/msg/Imu.html))

accelerometer data is published on this topic.

### Usage: After connecting the android device and sparkV robot run
roscore
rosrun rosserial_python serial_node.py /dev/ttyUSB0
rosrun sparkV_android android
NOTE: You might have to edit android.cpp depending on your accelerometer data from phone. See the video below how it works!.