{"id":5629,"date":"2018-11-13T12:26:09","date_gmt":"2018-11-13T11:26:09","guid":{"rendered":"https:\/\/blog.generationrobots.com\/?p=5629"},"modified":"2023-03-29T14:27:37","modified_gmt":"2023-03-29T12:27:37","slug":"tutorial-turtlebot-teleoperation-android-phone","status":"publish","type":"post","link":"https:\/\/www.generationrobots.com\/blog\/en\/tutorial-turtlebot-teleoperation-android-phone\/","title":{"rendered":"Tutorial: Intuitive Turtlebot Teleoperation using an Android phone"},"content":{"rendered":"\n<html>\n <body>\n  <h2 class=\"wp-block-heading\" id=\"h-introduction-turtlebot-tutorial-step-by-step\">\n   Introduction &#8211; Turtlebot tutorial step by step\n  <\/h2>\n  \n  \n  <p>\n   In this tutorial we will use the inertial measurement unit of a standard Android phone to control a ROS compatible robot. We have chosen a classical ROS robot, the\n   <a class=\"catalogue\" href=\"\/en\/402707-turtlebot3-burger-mobile-robot.html\" rel=\"noopener noreferrer\" target=\"_blank\" title=\"Turtlebot 3 Burger\">\n    Turtlebot3 Burger\n   <\/a>\n   , to be our test platform.\n  <\/p>\n  \n  \n  <figure class=\"wp-block-image aligncenter\">\n   <a class=\"catalogue\" href=\"https:\/\/blog.generationrobots.com\/wp-content\/uploads\/2018\/10\/IMG_20181009_172541.jpg\">\n    <img fetchpriority=\"high\" decoding=\"async\" width=\"300\" height=\"225\" alt=\"Tutorial Turtlebot Android\" class=\"wp-image-5607\" src=\"https:\/\/blog.generationrobots.com\/wp-content\/uploads\/2018\/10\/IMG_20181009_172541-300x225.jpg\" srcset=\"https:\/\/www.generationrobots.com\/blog\/wp-content\/uploads\/2018\/10\/IMG_20181009_172541-300x225.jpg 300w, https:\/\/www.generationrobots.com\/blog\/wp-content\/uploads\/2018\/10\/IMG_20181009_172541-768x576.jpg 768w, https:\/\/www.generationrobots.com\/blog\/wp-content\/uploads\/2018\/10\/IMG_20181009_172541-1024x768.jpg 1024w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/>\n   <\/a>\n  <\/figure>\n  \n  \n  <p>\n   Requirements:\n  <\/p>\n  \n  \n  <ul class=\"wp-block-list\">\n   \n   <li>\n    Android phone\n   <\/li>\n   \n   \n   <li>\n    Any ROS compatible robot &#8211; In our tutorial we use the\n    <a class=\"catalogue\" href=\"\/en\/402707-turtlebot3-burger-mobile-robot.html\" rel=\"noopener noreferrer\" target=\"_blank\" title=\"Turtlebot 3 Burger\">\n     Turtlebot 3 &#8211; Burger\n    <\/a>\n   <\/li>\n   \n   \n   <li>\n    Some basic knowledge on Linux and ROS\n   <\/li>\n   \n   \n   <li>\n    WiFi connection\n   <\/li>\n   \n  <\/ul>\n  \n  \n  <h3 class=\"wp-block-heading\" id=\"h-prepare-the-android-app\">\n   Prepare the Android App\n  <\/h3>\n  \n  \n  <p>\n   As we are not reinventing the wheel, we are goint to use a specific app, that is already available in the Android store. I recommend to install the app first, because it is essential to this tutorial.\n  <\/p>\n  \n  \n  <h3 class=\"wp-block-heading\" id=\"h-connect-to-your-robot\">\n   Connect to your robot\n  <\/h3>\n  \n  \n  <p>\n   Open a few terminals on your robot. Either connect a screen and a keyboard to your robot or simply ssh into your robot. All consequent commands are executed on the robot (Raspberry Pi).\n  <\/p>\n  \n  \n  <p>\n   If you are working remotely, I recommend to add your ssh key to the authorized hosts on the robot, in order to connect to the robot using your key and no password. If you have not create a ssh key yet, just call ssh-keygen in a terminal to create a key in your home directory\/.ssh. Replace the path to YOUR_KEY, USER and HOST with your actual setup.\n  <\/p>\n  \n  \n  <p>\n   <em>\n    cat ~\/.ssh\/YOUR_KEY.pub | (ssh USER@HOST \u00ab\u00a0cat &gt;&gt; ~\/.ssh\/authorized_keys\u00a0\u00bb)\n   <\/em>\n  <\/p>\n  \n  \n  <h3 class=\"wp-block-heading\" id=\"h-prepare-the-environment-optional\">\n   Prepare the environment (optional)\n  <\/h3>\n  \n  \n  <p>\n   We recommend some additional setup that makes your life much more easier. We created some useful alias for ros environments. It\u2019s just a little script, but very useful. Clone the tool and it to your local .bashrc\n  <\/p>\n  \n  \n  <p>\n   <em>\n    cd\n   <\/em>\n   <br\/>\n   <em>\n    git clone https:\/\/github.com\/generationrobots-lab\/rosbash\n   <\/em>\n   <br\/>\n   <em>\n    nano ~\/.bashrc\n   <\/em>\n   <br\/>\n   <em>\n    Add following lines to the end of your file:\n   <\/em>\n   <br\/>\n   <em>\n    source $HOME\/rosbash\/rosbash.bash\n   <\/em>\n   <br\/>\n   <em>\n    source \/opt\/ros\/kinetic\/setup.bash\n   <\/em>\n   <br\/>\n   <em>\n    source $HOME\/ros_ws\/devel\/setup.bash\n   <\/em>\n   <br\/>\n   <em>\n    export ROS_MASTER_URI=http:\/\/$HOSTNAME:11311\n   <\/em>\n   <br\/>\n   <em>\n    export ROS_HOSTNAME=$HOSTNAME.local\n   <\/em>\n   <br\/>\n   <em>\n    export TURTLEBOT3_MODEL=burger\n   <\/em>\n  <\/p>\n  \n  \n  <p>\n   Save and close the file with Ctrl+O, Ctrl+X.\n  <\/p>\n  \n  \n  <p>\n   Note: Depending on your\n   <a class=\"catalogue\" href=\"\/en\/396-mobile-robot-turtlebot\" rel=\"noopener noreferrer\" target=\"_blank\" title=\"Buy Turtlebot robot\">\n    turtlebot model\n   <\/a>\n   , you might need to replace the name \u201cburger\u201d with \u201cwaffle\u201d.\n  <\/p>\n  \n  \n  <p>\n   Note: Do not worry about the ros_ws directory. We gonna create it in the next step.\n  <\/p>\n  \n  \n  <h3 class=\"wp-block-heading\" id=\"h-prepare-the-robot\">\n   Prepare the robot\n  <\/h3>\n  \n  \n  <p>\n   If your robot is not setup yet, I recommend that you look at this\n   <a class=\"catalogue\" href=\"http:\/\/emanual.robotis.com\/docs\/en\/platform\/turtlebot3\/overview\/\" rel=\"noopener noreferrer\" target=\"_blank\" title=\"Turtlebot Tutorial\">\n    tutorial\n   <\/a>\n   first, which describes the basic setup of Ubuntu 16.04 and ROS Kinetic for the Turtlebot 3.\n  <\/p>\n  \n  \n  <p>\n   Let\u2019s assume Ubuntu and ROS are installed, we continue to setup a ROS workspace. Let\u2019s create a workspace called \u201cros_ws\u201d.\n  <\/p>\n  \n  \n  <p>\n   <em>\n    source \/opt\/ros\/kinetic\/setup.bash\n   <\/em>\n   <br\/>\n   <em>\n    mkdir &#8211; p ~\/ros_ws\/src\n   <\/em>\n   <br\/>\n   <em>\n    cd ~\/ros_ws\/src\n   <\/em>\n   <br\/>\n   <em>\n    catkin_init_workspace\n   <\/em>\n   <br\/>\n   <em>\n    cd ..\n   <\/em>\n   <br\/>\n   <em>\n    catkin_make\n   <\/em>\n  <\/p>\n  \n  \n  <p>\n   In case you have installed rosbash from the previous step, you should now source it in all existing terminals by:\n  <\/p>\n  \n  \n  <p>\n   <em>\n    source ~\/.bashrc\n   <\/em>\n  <\/p>\n  \n  \n  <p>\n   In order to tell you bash that you want to use the \u201cros_ws\u201d you can just type \u201cdevel\u201d in the root of the workspace and you command prompt should change.\n  <\/p>\n  \n  \n  <p>\n   Now let\u2019s clone the turtlebot3 and our IMU bridge repository:\n  <\/p>\n  \n  \n  <p>\n   <em>\n    cd ~\/ros_ws\/src\n   <\/em>\n   <br\/>\n   <em>\n    git clone https:\/\/github.com\/ROBOTIS-GIT\/turtlebot3.git\n   <\/em>\n   <br\/>\n   <em>\n    git clone https:\/\/github.com\/generationrobots-lab\/teleop_imu.git\n   <\/em>\n  <\/p>\n  \n  \n  <p>\n   You can now simply invoke a\n   <em>\n    catkin_make\n   <\/em>\n   by writing the abbreviation cm, otherwise you need to invoke\n   <em>\n    catkin_make\n   <\/em>\n   in\n   <em>\n    ~\/ros_ws\n   <\/em>\n   . In case you have any missing dependencies you can simply install them by\n   <em>\n    install_deps\n   <\/em>\n   .\n  <\/p>\n  \n  \n  <h3 class=\"wp-block-heading\" id=\"h-test-all-components-and-assemble-everything\">\n   Test all components and assemble everything\n  <\/h3>\n  \n  \n  <p>\n   Now it is time to see, if all components are working.\n  <\/p>\n  \n  \n  <p>\n   Start the rosmaster :\n  <\/p>\n  \n  \n  <p>\n   <em>\n    roscore\n   <\/em>\n  <\/p>\n  \n  \n  <p>\n   By default you should also have a teleop_twist_keyboard controller installed with the ros packages, other install it by:\n  <\/p>\n  \n  \n  <p>\n   <em>\n    sudo apt-get update &amp;&amp; sudo apt-get install ros-kinetic-teleop-twist-keyboard\n   <\/em>\n   <br\/>\n   <em>\n    rosrun teleop_twist_keyboard teleop_twist_keyboard.py\n   <\/em>\n  <\/p>\n  \n  \n  <p>\n   In another terminal run:\n  <\/p>\n  \n  \n  <p>\n   <i>\n    rostopic echo \/cmd_vel\n   <\/i>\n  <\/p>\n  \n  \n  <p>\n   If you press now on one of the buttons (while the terminal with the teleop twist keyboard has the focus) I, J, K, L or space, you should see an output message on the echo terminal.\n  <\/p>\n  \n  \n  <p>\n   Now lets start the robot base driver in another terminal:\n  <\/p>\n  \n  \n  <p>\n   <em>\n    roslaunch turtlebot3_bringup turtlebot3_core.launch\n   <\/em>\n  <\/p>\n  \n  \n  <p>\n   If you try the teleop keyboard now the robot should be moving. Stop the teleop_keyboard once this is working (Ctrl-C).\n  <\/p>\n  \n  \n  <p>\n   Now check the IP of your robot, using ifconfig. You should get an output, similar to the one shown below. In my case the robot is connected by WiFi (wlan0) and its address is 192.168.0.115. This is the address of the rosmaster.\n  <\/p>\n  \n  \n  <figure class=\"wp-block-image aligncenter\">\n   <a class=\"catalogue\" href=\"https:\/\/blog.generationrobots.com\/wp-content\/uploads\/2018\/10\/Screenshot-from-2018-10-09-16-27-18.png\">\n    <img decoding=\"async\" width=\"300\" height=\"70\" alt=\"Tutorial Turtlebot Android\" class=\"wp-image-5606\" src=\"https:\/\/blog.generationrobots.com\/wp-content\/uploads\/2018\/10\/Screenshot-from-2018-10-09-16-27-18-300x70.png\" srcset=\"https:\/\/www.generationrobots.com\/blog\/wp-content\/uploads\/2018\/10\/Screenshot-from-2018-10-09-16-27-18-300x70.png 300w, https:\/\/www.generationrobots.com\/blog\/wp-content\/uploads\/2018\/10\/Screenshot-from-2018-10-09-16-27-18.png 565w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/>\n   <\/a>\n  <\/figure>\n  \n  \n  <p>\n   Now start the app on your phone. It will ask you to enter the address of the master in the first line.\n  <\/p>\n  \n  \n  <figure class=\"wp-block-image aligncenter\">\n   <a class=\"catalogue\" href=\"https:\/\/blog.generationrobots.com\/wp-content\/uploads\/2018\/10\/Screenshot_2018-10-09-16-49-30-388_org.ros_.android.sensors_driver.png\">\n    <img decoding=\"async\" width=\"300\" height=\"169\" alt=\"Tutorial Turtlebot Android\" class=\"wp-image-5608\" src=\"https:\/\/blog.generationrobots.com\/wp-content\/uploads\/2018\/10\/Screenshot_2018-10-09-16-49-30-388_org.ros_.android.sensors_driver-300x169.png\" srcset=\"https:\/\/www.generationrobots.com\/blog\/wp-content\/uploads\/2018\/10\/Screenshot_2018-10-09-16-49-30-388_org.ros_.android.sensors_driver-300x169.png 300w, https:\/\/www.generationrobots.com\/blog\/wp-content\/uploads\/2018\/10\/Screenshot_2018-10-09-16-49-30-388_org.ros_.android.sensors_driver-768x432.png 768w, https:\/\/www.generationrobots.com\/blog\/wp-content\/uploads\/2018\/10\/Screenshot_2018-10-09-16-49-30-388_org.ros_.android.sensors_driver-1024x576.png 1024w, https:\/\/www.generationrobots.com\/blog\/wp-content\/uploads\/2018\/10\/Screenshot_2018-10-09-16-49-30-388_org.ros_.android.sensors_driver.png 1920w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/>\n   <\/a>\n  <\/figure>\n  \n  \n  <p>\n   Enter:\n   <i>\n    http:\/\/192.168.0.115:11311\n   <\/i>\n   and replace\n   <em>\n    192.168.0.115\n   <\/em>\n   with the corresponding IP of your robot and confirm with OK.\n  <\/p>\n  \n  \n  <p>\n   Note: The roscore and the turtlebot3 core should still be running on your robot.\n   <br\/>\n   Now the android phone should connect to your robot and send message under the topic name:\n  <\/p>\n  \n  \n  <p>\n   <i>\n    \/android\/imu\n   <\/i>\n  <\/p>\n  \n  \n  <p>\n   In order to see, if you get the messages do a\n  <\/p>\n  \n  \n  <p>\n   <i>\n    rostopic echo \/android\/imu\n   <\/i>\n  <\/p>\n  \n  \n  <p>\n   You should see a lot of values that are published.\n  <\/p>\n  \n  \n  <p>\n   If that works fine, you can now start the bridge from the IMU to the velocity command topic. The bridge will use the first sensor message as reference for zero, where the robot will not move. So probably lay your phone flat on a table. Whenever you put the phone back in this orientation that robot will stop moving. In addition when you completely close the app, the robot stops also.\n  <\/p>\n  \n  \n  <p>\n   <em>\n    rosrun teleop_imu teleop_imu_bridge.py\n   <\/em>\n  <\/p>\n  \n  \n  <p>\n   Congratulations, you can now control you robot by turning your phone. Feel free to open the\n  <\/p>\n  \n  \n  <p>\n   <i>\n    ~\/ros_ws\/src\/teleop_imu\/scripts\/teleop_imu_bridge.py\n   <\/i>\n  <\/p>\n  \n  \n  <p>\n   and change it to your needs. Probably your might want to change the x and y axis or the scaling to move faster or more precise.\n  <\/p>\n  \n  \n  <p>\n   To speedup the startup I have also put a launch file inside the teleop_imu\/launch folder, which starts the turtlebot core and the imu bridge. Run it by:\n  <\/p>\n  \n  \n  <p>\n   <i>\n    roslaunch teleop_imu tb3_core_imu.launch\n   <\/i>\n  <\/p>\n  \n <\/body>\n<\/html>","protected":false},"excerpt":{"rendered":"<p>Introduction &#8211; Turtlebot tutorial step by step In this tutorial we will use the inertial measurement unit of a standard Android phone to control a ROS compatible robot. We have chosen a classical ROS robot, the Turtlebot3 Burger , to be our test platform. Requirements: Prepare the Android App As we are not reinventing the[&#8230;]<br \/> <a class=\"button\" href=\"https:\/\/www.generationrobots.com\/blog\/en\/tutorial-turtlebot-teleoperation-android-phone\/\" style=\"float:right;\">Read this article &gt;&gt;<\/a><\/p>\n","protected":false},"author":300,"featured_media":5621,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10535],"tags":[],"class_list":["post-5629","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-guides-and-tutorials"],"_links":{"self":[{"href":"https:\/\/www.generationrobots.com\/blog\/wp-json\/wp\/v2\/posts\/5629","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.generationrobots.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.generationrobots.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.generationrobots.com\/blog\/wp-json\/wp\/v2\/users\/300"}],"replies":[{"embeddable":true,"href":"https:\/\/www.generationrobots.com\/blog\/wp-json\/wp\/v2\/comments?post=5629"}],"version-history":[{"count":7,"href":"https:\/\/www.generationrobots.com\/blog\/wp-json\/wp\/v2\/posts\/5629\/revisions"}],"predecessor-version":[{"id":13170,"href":"https:\/\/www.generationrobots.com\/blog\/wp-json\/wp\/v2\/posts\/5629\/revisions\/13170"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.generationrobots.com\/blog\/wp-json\/wp\/v2\/media\/5621"}],"wp:attachment":[{"href":"https:\/\/www.generationrobots.com\/blog\/wp-json\/wp\/v2\/media?parent=5629"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.generationrobots.com\/blog\/wp-json\/wp\/v2\/categories?post=5629"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.generationrobots.com\/blog\/wp-json\/wp\/v2\/tags?post=5629"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}