Skip to content

Commit

Permalink
Merge pull request #302 from leggedrobotics/dev/jackal-sim-improvements
Browse files Browse the repository at this point in the history
Jackal simulation completed
  • Loading branch information
JonasFrey96 authored Apr 11, 2024
2 parents 22d26c4 + 51bd848 commit 0fe93c7
Show file tree
Hide file tree
Showing 31 changed files with 1,169 additions and 10,486 deletions.
302 changes: 174 additions & 128 deletions README.md

Large diffs are not rendered by default.

Binary file added assets/images/sim_demo.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,6 @@ RUN mkdir -p /root/catkin_ws/src \

RUN echo "source /root/catkin_ws/devel/setup.bash" >> ~/.bashrc
RUN echo "source /root/env/bin/activate" >> ~/.bashrc

COPY docker/first_run.sh first_run.sh
ENV DEBIAN_FRONTEND=dialog
73 changes: 49 additions & 24 deletions docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,70 +5,95 @@ We provide an example package to demonstrate Wild Visual Navigation on a simulat
This example should be self-contained and it should run on a Docker container. This was tested on Ubuntu machines, we do not expect the GUI to run on Windows or Mac computers (due to X11 support).


## Build the image

To build the container:
## Preliminaries
The instructions assume you have Docker installed. If you haven't used Docker before, please take a look at the excellent resources prepared by Tobit Flatscher in [docker-for-robotics](https://github.com/2b-t/docker-for-robotics), which this demo builds upon.

# Get the required repositories
First clone the WVN and our STEGO reimplementation.
```shell
mkdir ~/git && cd ~/git
git clone [email protected]:leggedrobotics/wild_visual_navigation.git
git clone [email protected]:leggedrobotics/self_supervised_segmentation.git
```

Then, go to the `docker` folder in `wild_visual_navigation`

```shell
cd ~/git/wild_visual_navigation/docker
```

> Note: All the following commands must be executed in this folder
## Build the image
Build the Docker image running:

```sh
docker compose -f docker-compose-gui-nvidia.yaml build
```

## Run the container
## Run the simulation environment in the container

To run the container (terminal-based):
Start the container in detached mode:

```sh
docker compose -f docker-compose-gui-nvidia.yaml up -d
```

To launch bash on the container:
Launch a first bash terminal in the container to start the simulation environment:

```sh
docker compose exec wvn bash
docker compose -f docker-compose-gui-nvidia.yaml exec wvn_nvidia /bin/bash
```

## Stop the container

To stop the container:
Once in the container, source the `first_run` script to install the WVN package that is mounted automatically when the container starts:

```sh
docker compose -f docker-compose.yaml stop
source first_run.sh
```

## Running Wild Visual Navigation

You can either run the following commands in 4 terminals that initialize a bash terminal in the container, or you can use VS Code with the Docker extension to instantiate terminal in the container directly.

### Launch Jackal sim
Launch the Gazebo simulation environment and an RViz window as the main interface.

```sh
roslaunch wild_visual_navigation_jackal sim.launch
```
If this doesn't open any window, please check the troubleshooting section below.

### Launch WVN

Open a new terminal to launch WVN in the same container:

```sh
roslaunch wild_visual_navigation_jackal wild_visual_navigation.launch
docker compose -f docker-compose-gui-nvidia.yaml exec wvn_nvidia /bin/bash
```

### Launch Teleop node

And then, once you are in the container:
```sh
roslaunch wild_visual_navigation_jackal teleop.launch
roslaunch wild_visual_navigation_jackal wild_visual_navigation.launch
```

### Launch RViz window
Wait until the Rviz window show the simulation environment. Once it's ready, you can drive the Jackal robot by sending 2D Nav goals using RViz. We implemented a simple [carrot follower](../wild_visual_navigation_jackal/scripts/carrot_follower.py) that was tuned for the demo (not actually used in real experiments)


## Stop the example

Kill all the terminals as usual (Ctrl + D). Then, stop the container using:

```sh
roslaunch wild_visual_navigation_jackal view.launch
docker compose -f docker-compose-gui-nvidia.yaml down
```


## Troubleshooting

If the GUI doesn't work, you might need to allow the X Server to connect before running the container:
If RViz doesn't show up, you'll see an error like this in the terminal:

> No protocol specified
> qt.qpa.xcb: could not connect to display :1
To fix it, you might need to allow the X Server to connect before running the container. Stop everything (including the container) and then run:

```sh
xhost +Local:*
xhost
```

Then restart the container and run the other commands. Now RViz should pop up.
1 change: 0 additions & 1 deletion docker/docker-compose-gui-nvidia.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
version: "3.9"
services:
wvn_nvidia:
extends:
Expand Down
1 change: 0 additions & 1 deletion docker/docker-compose-gui.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
version: "3.9"
services:
wvn:
extends:
Expand Down
1 change: 0 additions & 1 deletion docker/docker-compose-nvidia.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
version: "3.9"
services:
wvn_nvidia:
extends:
Expand Down
9 changes: 1 addition & 8 deletions docker/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
version: "3.9"
services:
wvn:
build:
Expand All @@ -13,10 +12,4 @@ services:
- ../../self_supervised_segmentation:/root/catkin_ws/src/self_supervised_segmentation
environment:
- ROS_IP=127.0.0.1
command: "/bin/bash"
# command: >
# /bin/bash -c "pip3 install -e /root/catkin_ws/src/wild_visual_navigation
# && pip3 install -e /root/catkin_ws/src/self_supervised_segmentation
# && cd /root/catkin_ws && catkin build
# && cd /root
# && source /root/catkin_ws/devel/setup.bash"
command: "/bin/bash"
15 changes: 15 additions & 0 deletions docker/first_run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

echo "pip3 install -e /root/catkin_ws/src/self_supervised_segmentation ..."
pip3 install -e /root/catkin_ws/src/self_supervised_segmentation > /dev/null

echo "pip3 install -e /root/catkin_ws/src/wild_visual_navigation ..."
pip3 install -e /root/catkin_ws/src/wild_visual_navigation > /dev/null

echo "catkin build ..."
catkin build > /dev/null

echo "source devel/setup.bash ..."
source devel/setup.bash > /dev/null

echo "Setup ready!"
12 changes: 3 additions & 9 deletions wild_visual_navigation_jackal/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,6 @@ catkin_package(
CATKIN_DEPENDS
)

# catkin_python_setup()
# catkin_install_python(PROGRAMS scripts/wvn_feature_extractor_node.py
# scripts/wvn_learning_node.py
# scripts/overlay_images.py
# scripts/smart_carrot.py
# scripts/rosbag_play.sh
# DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION})

message(${CATKIN_PACKAGE_SHARE_DESTINATION})
install(DIRECTORY launch Media worlds
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
Expand All @@ -29,5 +21,7 @@ install(DIRECTORY launch Media worlds
############
## Python ##
############
catkin_install_python(PROGRAMS scripts/jackal_state_converter_node.py
catkin_install_python(PROGRAMS scripts/carrot_follower.py
scripts/jackal_state_converter_node.py
scripts/gazebo_world_publisher.py
DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION})
Loading

0 comments on commit 0fe93c7

Please sign in to comment.