Skip to content

Commit

Permalink
Add sim_demo image
Browse files Browse the repository at this point in the history
  • Loading branch information
mmattamala committed Apr 10, 2024
1 parent 4c0963b commit e9dfdfa
Show file tree
Hide file tree
Showing 14 changed files with 77 additions and 55 deletions.
32 changes: 20 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,14 @@

<img align="right" width="40" height="40" src="https://github.com/leggedrobotics/wild_visual_navigation/blob/main/assets/images/dino.png" alt="Dino">

## Installation
## Setup

### Minimal
### Quick simulation demo
We prepared a quick-start simulation with a Jackal robot using Docker. Please check the instructions [here](docker/README.md)

![Overview](./assets/images/sim_demo.jpg)

### Minimal setup
Clone the WVN and our STEGO reimplementation.
```shell
mkdir ~/git && cd ~/git
Expand Down Expand Up @@ -73,8 +78,8 @@ pip3 install -e ./self_supervised_segmentation
┣ 📂wild_visual_navigation_msgs # ROS1 message definitions
┣ 📂wild_visual_navigation_ros # ROS1 nodes for running WVN
┗ 📂scripts
┗ 📜 wvn_feature_extractor_node.py
┗ 📜 wvn_learning_node.py
┗ 📜 wvn_feature_extractor_node.py # Main process for feature extraction and inference
┗ 📜 wvn_learning_node.py # Main process that generates supervision signals and the online training loop
┗ 📜 quick_start.py # Inferencing demo_data from pre-trained checkpoints
```
### Features
Expand All @@ -87,7 +92,7 @@ pip3 install -e ./self_supervised_segmentation

<img align="right" width="40" height="40" src="https://github.com/leggedrobotics/wild_visual_navigation/blob/main/assets/images/dino.png" alt="Dino">

## Experiments
## Demos

### Inference of pre-trained model

Expand All @@ -105,11 +110,11 @@ python3 quick_start.py
```

### Online adaptation [Simulation]
Instructions can be found within [wild_visual_navigation_jackal/README.md](wild_visual_navigation_jackal/README.md).
We prepared a Docker image to run a simulation with a Jackal robot, check the instructions [here](docker/README.md).

### Online adaptation [Rosbag]
#### Download Rosbags:
To quickly test out online training and adaption we provide some example rosbags ( [GDrive](https://drive.google.com/drive/folders/1Rf2TRPT6auFxOpnV9-ZfVMjmsvdsrSD3?usp=sharing) ), collected with our ANYmal D robot.
#### Download rosbags:
To quickly test out online training and adaption we provide some example rosbags ([GDrive](https://drive.google.com/drive/folders/1Rf2TRPT6auFxOpnV9-ZfVMjmsvdsrSD3?usp=sharing)), collected with our ANYmal D robot.

#### Example Result:
<div align="center">
Expand All @@ -121,7 +126,7 @@ To quickly test out online training and adaption we provide some example rosbags

</div>

#### ROS-Setup:
#### ROS Setup:
```shell
# Create new catkin workspace
source /opt/ros/noetic/setup.bash
Expand Down Expand Up @@ -150,7 +155,7 @@ source /opt/ros/noetic/setup.bash
source ~/catkin_ws/devel/setup.bash
```

After successfully building the ros workspace, you can run the entire pipeline by either using the launch file or by running the nodes individually.
After successfully building the ROS workspace, you can run the entire pipeline by either using the launch file or by running the nodes individually.
Open multiple terminals and run the following commands:

- Run wild_visual_navigation
Expand Down Expand Up @@ -184,13 +189,15 @@ python wild_visual_navigation_ros/scripts/wvn_learning_node.py
- The general configuration files can be found under: `wild_visual_navigation/cfg/experiment_params.py`
- This configuration is used in the `offline-model-training` and in the `online-ros` mode.
- When running the `online-ros` mode, additional configurations for the individual nodes are defined in `wild_visual_navigation/cfg/ros_params.py`.
- These configuration file is filled based on the rosparameter-server during runtime.
- These configuration file is filled based on the ROS parameter server during runtime.
- The default values for this configuration can be found under `wild_visual_navigation/wild_visual_navigation_ros/config/wild_visual_navigation`.


<img align="right" width="40" height="40" src="https://github.com/leggedrobotics/wild_visual_navigation/blob/main/assets/images/dino.png" alt="Dino">

## Development
<details>
<summary>Here we provide additional details if you want to contribute.</summary>

### Install pre-commit
```shell
Expand Down Expand Up @@ -219,7 +226,7 @@ pytest
### Open-Sourcing
Generating headers
```shell
pip3 install adheader
pip3 install addheader

# If your are using zsh otherwise remove \
addheader wild_visual_navigation -t header.txt -p \*.py --sep-len 79 --comment='#' --sep=' '
Expand All @@ -238,6 +245,7 @@ rosrun procman_ros sheriff -l ~/git/wild_visual_navigation/wild_visual_navigatio
```shell
rosbag_play --tf --sem --flp --wvn mission/*.bag
```
</details>

<img align="right" width="40" height="40" src="https://github.com/leggedrobotics/wild_visual_navigation/blob/main/assets/images/dino.png" alt="Dino">

Expand Down
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
46 changes: 25 additions & 21 deletions docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,60 +13,64 @@ To build the container:
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
Once in the container, run the `first_run` script to install the WVN package that is mounted automatically when the container starts:
```sh
source first_run.sh
```

To stop the container:
Launch the Gazebo simulation environment and an RViz window as the main interface.

```sh
docker compose -f docker-compose.yaml stop
roslaunch wild_visual_navigation_jackal sim.launch
```
If this doesn't open any window, pelase check the troubleshooting section below.

## 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
Open a new terminal to launch WVN in the container

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

### Launch WVN

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

### Launch Teleop node
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)

```sh
roslaunch wild_visual_navigation_jackal teleop.launch
```

### Launch RViz window
## Stop the example

Kill all the terminal 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 the GUI doesn't work, you'll see an error like:

> 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:

```sh
xhost +Local:*
Expand Down
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!"
4 changes: 1 addition & 3 deletions wild_visual_navigation_jackal/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ sudo apt-get update
sudo apt update
sudo apt install -y \
ros-noetic-jackal-simulator \
ros-noetic-jackal-desktop \
ros-noetic-teleop-twist-keyboard \
ros-noetic-rqt-robot-steering \
ros-noetic-jackal-desktop
```

## Running
Expand Down
3 changes: 3 additions & 0 deletions wild_visual_navigation_jackal/launch/sim.launch
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,7 @@
<node name="gazebo_world_publisher" pkg="wild_visual_navigation_jackal" type="gazebo_world_publisher.py"/>
<node name="jackal_carrot_follower" pkg="wild_visual_navigation_jackal" type="carrot_follower.py"/>

<!-- RViz window -->
<include file="$(find wild_visual_navigation_jackal)/launch/view.launch"/>

</launch>
7 changes: 0 additions & 7 deletions wild_visual_navigation_jackal/launch/teleop.launch

This file was deleted.

2 changes: 1 addition & 1 deletion wild_visual_navigation_jackal/scripts/carrot_follower.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
MAX_LINEAR_VEL = 0.5
MAX_ANGULAR_VEL = 0.7
GAIN_LINEAR = 1.0
GAIN_ANGULAR = 1.0
GAIN_ANGULAR = 1.5
DIST_THR = 0.1 # 10 cms


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
import tf.transformations as tr


last_stamp = None


def msg_to_se3(msg):
"""Conversion from geometric ROS messages into SE(3)
Based on Jarvis Schultz's: https://answers.ros.org/question/332407/transformstamped-to-transformation-matrix-python/
Expand Down Expand Up @@ -54,7 +57,11 @@ def msg_to_se3(msg):


def gazebo_callback(msg):
global last_stamp
stamp = rospy.Time.now()
if stamp == last_stamp:
return

T_world_base = msg_to_se3(msg.pose[1]) # this is the base_link pose in world frame (from gazebo)
T_base_world = np.linalg.inv(T_world_base)

Expand All @@ -74,10 +81,12 @@ def gazebo_callback(msg):
br.sendTransform(t)

pub.publish(marker)
last_stamp = stamp


if __name__ == "__main__":
rospy.init_node("gazebo_world_publisher")
last_stamp = rospy.Time.now()

# Default variables
rospack = rospkg.RosPack()
Expand Down

0 comments on commit e9dfdfa

Please sign in to comment.