Skip to content

Instantly share code, notes, and snippets.

@cardboardcode
Last active June 14, 2024 23:52
Show Gist options
  • Save cardboardcode/5ca580f1b631c3085a80b74dd43a671b to your computer and use it in GitHub Desktop.
Save cardboardcode/5ca580f1b631c3085a80b74dd43a671b to your computer and use it in GitHub Desktop.
For People In A Hurry: Setting up nav_rest_api_turtlebot for simulated Turtlebot3

For People In A Hurry: Setting up nav_rest_api_turtlebot for simulated Turtlebot3

TLDR:These are a quick list of instructions to quickly install and run nav_rest_api_turtlebot on your local workstation.

Environment 📚

  1. Ubuntu 22.04.4 LTS
  2. ROS 2 Humble
  3. Docker version 26.1.1, build 4cf5afa

Download nav_rest_api_turtlebot repository locally:

cd $HOME
git clone https://github.com/cardboardcode/nav_rest_api_turtlebot --single-branch --depth 1
cd nav_rest_api_turtlebot

Build docker image using provided Dockerfile:

docker build -t ros1_turtlebot3_rest_api .

Enable gui display forwarding for applications within docker:

xhost +local:docker

Create docker container from newly built docker image:

docker run -it --rm \
 --name ros1_turtlebot3_rest_api_c \
 -e DISPLAY=$DISPLAY \
 -v /tmp/.X11-unix:/tmp/.X11-unix \
 --net=host \
 ros1_turtlebot3_rest_api:latest /bin/bash

Run the following command to launch the REST API in the docker container:

source devel/setup.bash && roslaunch nav_rest_api server.launch

Run the turtlebot3 simulation in a new terminal within the docker container:

docker exec -it ros1_turtlebot3_rest_api_c bash
export TURTLEBOT3_MODEL=waffle
source devel/setup.bash && roslaunch nav_rest_api_turtlebot test.launch

Verify ✅

Send a nav goal command to move the Turtlebot3 Waffle in simulation via REST API call:

curl --header "Content-Type: application/json" \
  --request POST \
  --data '{"robot_name": "robot0","location_x": "3","location_y": "0","location_th": "1.5707"}' \
  http://localhost:8080/api/goal
@cardboardcode
Copy link
Author

20240615_turtlebot3_nav_rest_api

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment