Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

To new CLI #5

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
FROM osrf/ros:galactic-desktop
FROM osrf/ros:humble-desktop
RUN apt-get update && apt-get install -y --no-install-recommends \
python3-pip \
unzip \
&& rm -rf /var/lib/apt/lists/*
RUN pip install --upgrade setuptools
RUN pip install artefacts-client --extra-index-url https://d5cw4z7oemmfd.cloudfront.net/pep503/ -U
RUN pip install artefacts-cli
ENV DISPLAY=$DISPLAY
WORKDIR turtle
COPY artefacts.yaml .
Expand Down
66 changes: 29 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,63 +1,55 @@
# Turtlesim Demo Project

This project demonstrates how to run a basic ros2 end to end tests in simulation (here turtlesim).
This project demonstrates how to run a basic ROS2 end-to-end test in simulation (here turtlesim).

## Prerequisite

You will need ROS2 galactic or humble installed.
This demo runs either natively or in containers. Native runs work only on Ubuntu version compatible with the tested ROS2 Humble versions (originally working with Galactic too). Container runs work on Linux, Darwin and Windows, with the later run in X11-compatible shells.

See instructions [here](https://docs.ros.org/en/humble/Installation.html)

## ROS2 tests
## Prerequisite

You can run the tests with:
### Container for Linux/Darwin/Windows

```
launch_test launch_turtle.py
```
* Container system: Docker (Podman coming)
* X11 window system, like XQuartz on Darwin and MobaXterm on Windows, configured to accept local network connections.

As it is, the test will fail.
### Native for supported Ubuntu

If you take a look at the code, you should be able to find what is wrong and make the test pass.
This is tested and likely to work only on ROS2 Humble Ubuntu systems.

See instructions for example [here for Humble](https://docs.ros.org/en/humble/Installation.html)

## Tests with ArtefactsCI
## Usage

Usage assumes you clone this repository where you intend to run the demo:

You can use one of the 2 options below.
git clone https://github.com/art-e-fact/example-turtlesim.git
cd example-turtlesim

### With local ROS2 install
From this point on, you can either run natively (supported Ubuntu versions only), or through containers.

Additionally, you can use ArtefactsCI to keep track of your tests results.
### Native for supported Ubuntu

1. Create an account and project on ArtefactsCI
#### Preliminary: Direct test run

2. Install the artefacts client
You can run the tests directly with:

```
pip install artefacts-client --extra-index-url https://d5cw4z7oemmfd.cloudfront.net/pep503/ -U
launch_test launch_turtle.py
```

2. Edit the project name in artefacts.yaml

3. Run the tests with tracking enabled
The test should succeed. One way to make it fail for demo purpose is to, say, increment by 0 the turtle velocity, so it never reaches the edge expeced by the test case (see line 19 in `sample_node.py`).

```
artefacts run basic_tests
```
#### Tests with Artefacts

### Using Docker
1. Create a free account and project on [Artefacts](https://app.artefacts.com)
2. Install the Artefacts CLI: `pip3 install artefacts-cli`
3. Edit the project name in `artefacts.yaml` to the name of your project in Artefacts (step 1).
4. Run the tests with tracking enabled: `artefacts run basic_tests`
5. Results and detail should shortly be available in your Artefacts dashboard.

### Container runs

Tests on MacOS and Ubuntu 20 often require explictly authorizing access to X11:
Runs should work out of the box, assuming complete X11 configuration:

[MacOS] xhost +127.0.0.1: This will start an X11 server if needed, and allow the container to connect.
[Ubuntu 20] xhost +local:docker
artefacts run --in-package basic_tests

Then build and run the docker container:

```
git clone [email protected]:art-e-fact/warp-client.git
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we should keep the menton that you need to clone before doing the artefacts run?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added on cloning under the Usage section. Does that flow well for now?

docker build -t turtle2 .
docker run --env ARTEFACTS_KEY=[YOUR-API-KEY] --net host --env DISPLAY=$DISPLAY -v $(pwd):/turtle turtle2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I may have missed it, but I don't see where you specify the -env DISPLAY=$DISPLAY in the in-package option

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that necessary on Linux? For Darwin, and most likely Windows (TBC), it is done in the code.

I see that as part of CLI UX, so definitely interested in iterating toward very useful experience.

```
This command will build any missing image before running a container. Please add `--repackage` to force a rebuild as needed.
4 changes: 2 additions & 2 deletions artefacts.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
version: 0.1.0

project: test-project # Update to your project name
project: artefacts-tests/example-turtlesim
jobs:
basic_tests: # Overall job name
type: test
runtime:
simulator: turtlesim
framework: ros2:galactic
framework: ros2:humble
timeout: 2 #minutes
scenarios:
defaults: # Global to all scenarios, and overriden in specific scenarios.
Expand Down
2 changes: 1 addition & 1 deletion sample_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def __init__(self):

def gt_callback(self, msg):
vel_msg = Twist()
vel_msg.linear.y = 1.0
vel_msg.linear.x = 1.0
self.velocity_publisher.publish(vel_msg)
self.gt_pose = msg
if self.gt_pose.x > 8:
Expand Down