This is the complete source code for the exploration demo that I wrote for the Turtlebot 2i platform. As well as all the actual source code, it also includes various utilities for configuring the robot and running the code.
Provisioning the robot can be done via Ansible.
Note that I have only tested this on a robot with a completely fresh Ubuntu 16.04 installation. If you already
have other stuff installed, YMMV. I have configured a turtlebot
user on the robot, with the password "turtlebot", and
access to sudo
. Make sure that your robot is also connected to the internet via WiFi before you start.
A note on 64-bit vs 32-bit: I have seen some Turtlebots come pre-installed with 32-bit OSes. If this is the case for yours, it will not work! You have no choice but to re-install a 64-bit version from scratch.
Also note that these instructions assume your host machine is running a recent version of Ubuntu.
-
Install Ansible:
pip install --user ansible
-
Edit the hosts.yml file, changing the listed IP address to the actual IP address of your robot.
-
Run the provisioning playbook:
ansible-playbook -i hosts.yml -u turtlebot -K provision_turtlebot.yml
This process will take awhile, but when it is finished, your robot should be properly provisioned with the correct version of all software packages installed.
The code is built in Docker, in an attempt to minimize the amount of system configuration necessary in order to build
it. Therefore, Docker must be installed on your host machine.
A new-ish version of docker-compose
is also necessary.
-
Build the Docker image:
docker-compose build
-
Run the Docker container:
docker-compose up -d builder
-
SSH into the container:
ssh -p 1824 turtlebot@localhost
. The password is "password". -
Build the code:
cd turtlebot2i
mkdir -p build
cd build
catkin_cmake ..
make -j $(nproc)
- Exit the SSH session.
After building, you can deploy the code to the robot. Replace ROBOT_IP
with the IP address of your robot.
scripts/deploy.sh turtlebot@ROBOT_IP
If you are already using the CLion IDE, the build process is designed to integrate well with it.
- Make sure you have the Docker plugin installed. Add a new build configuration. For the type, select
docker-compose
. Use "docker-compose.yml" as the compose file, and select the "builder" service. The first time you run this configuration, it will have to build the Docker image, which will take awhile. After it is done, it should start the builder service successfully. You will have to keep this configuration running whenever you are building the Turtlebot code.
- Go to "Settings > Build, Execution, Deployment > Toolchains". Add a new "Remote Host" toolchain. For the credentials,
use "turtlebot" as the username, "localhost" as the host, and "1824" as the port. Change the CMake executable to
/usr/bin/catkin_cmake
.
- Go to the "CMake" tab, and add a new profile. Configure it as shown below. (You can delete the default profile, as it won't work correctly anyway.)
- Go to the "Deployment" tab. A deployment configuration should have already been automatically created.
Set the path mappings as shown, substituting the actual path to the repository on your disk for the source path.
Set the repository root as an excluded path, as shown by the last item in the configuration below.
Once CLion is configured, you should be able to successfully load the CMake project. After this, you can build CMake targets as you would normally.
After building, you can deploy the code to the robot. Replace ROBOT_IP
with the IP address of your robot.
scripts/deploy.sh turtlebot@ROBOT_IP
Once the code has been deployed to the robot, running it is straightforward.
- SSH into the robot, and
cd turtlebot2i
. - Start ROS:
scripts/start_ros.sh
.