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!.
{"cc_re__cc_re__cc_by_sa_4_0": ["t.getElementsByTagName('body')[0]).appendChild(dsq);\n  })();\n</script>\n<noscript>Please enable JavaScript to view the <a href=\"https://disqus.com/?ref_noscript\" rel=\"nofollow\">comments powered by Disqus.</a></noscript>\n\n    \n  </div>\n</div>\n<div class=\"row top-buffer\">\n  <footer class=\"col-md-8 col-md-offset-1 text-center\">\n    Designed and built by <a href=\"http://abhishek.ind.in\">Abhishek</a>, code licensed under <a href=\"http://opensource.org/licenses/MIT\">MIT License</a> and tutorials under <a href=\"http://creativecommons.org/licenses/by-sa/4.0/\">CC-SA-4.0</a>. Hosted on <a href=\"https://github.com/playwithrobots/playwithrobots.github.io\">Github</a>.\n  </footer>\n</div>\n</div>\n  </body>\n</html>\n"]}