Skip to content

Commit

Permalink
Continuous integration (#29)
Browse files Browse the repository at this point in the history
Co-authored-by: Darko Lukic <[email protected]>
  • Loading branch information
filiparag and lukicdarkoo authored Dec 7, 2021
1 parent ec2ffa6 commit 23d9f9a
Show file tree
Hide file tree
Showing 12 changed files with 106 additions and 77 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
on:
pull_request:
types: [opened, synchronize, reopened, labeled, unlabeled]

env:
WEBOTS_VERSION: 2021b
WEBOTS_OFFSCREEN: 1
CI: 1
DEBIAN_FRONTEND: noninteractive
QTWEBENGINE_DISABLE_SANDBOX: 1

jobs:
ros2:
name: Build and test ROS 2 packages
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install ROS2
uses: ros-tooling/[email protected]
with:
required-ros-distributions: foxy
- name: Install Webots
run: |
sudo -E apt-get update
sudo -E apt-get install -y wget dialog apt-utils psmisc
wget "https://github.com/cyberbotics/webots/releases/download/R$WEBOTS_VERSION/webots_${WEBOTS_VERSION}_amd64.deb"
sudo -E apt-get install -y "./webots_${WEBOTS_VERSION}_amd64.deb" xvfb
- name: Build packages and run and tests
uses: ros-tooling/[email protected]
with:
target-ros2-distro: foxy
24 changes: 24 additions & 0 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
on:
pull_request:
types: [opened, synchronize, reopened, labeled, unlabeled]

jobs:
linter:
name: Check code using Ament linter
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
linter: [flake8, pep257, xmllint]
package: [mep3_driver, mep3_simulation]
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install ROS2
uses: ros-tooling/[email protected]
- name: Run ${{ matrix.linter }} linter for ${{ matrix.package }}
uses: ros-tooling/[email protected]
with:
distribution: foxy
linter: ${{ matrix.linter }}
package-name: ${{ matrix.package }}
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
.vscode/
.idea/
build/
install/
log/
**.pyc
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,13 @@ ros2 run teleop_twist_keyboard teleop_twist_keyboard
To launch simulation with `rviz` and `nav2` run
```sh
ros2 launch mep3_simulation robot_launch.py rviz:=true nav:=true
```
```

## Testing

- Change working directory to `foxy_ws`
- Run the following command:
```sh
source /opt/ros/foxy/local_setup.bash
colcon test --event-handlers console_cohesion+ --return-code-on-test-failure
```
13 changes: 8 additions & 5 deletions mep3_driver/launch/driver_launch.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
import os
import pathlib
from launch import LaunchDescription

from ament_index_python.packages import get_package_share_directory
from launch import LaunchDescription
from launch_ros.actions import Node


def generate_launch_description():
package_dir = get_package_share_directory('mep3_driver')

robot_description = pathlib.Path(os.path.join(package_dir, 'resource', 'mep3_big_config.urdf')).read_text()
ros2_control_params = os.path.join(package_dir, 'resource', 'mep3_big_ros2_control.yaml')
robot_description = pathlib.Path(os.path.join(
package_dir, 'resource', 'mep3_big_config.urdf')).read_text()
ros2_control_params = os.path.join(
package_dir, 'resource', 'mep3_big_ros2_control.yaml')

controller_manager_node = Node(
package="controller_manager",
executable="ros2_control_node",
package='controller_manager',
executable='ros2_control_node',
parameters=[
{'robot_description': robot_description},
ros2_control_params
Expand Down
2 changes: 2 additions & 0 deletions mep3_driver/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

<test_depend>ament_lint_auto</test_depend>
<test_depend>ament_lint_common</test_depend>
<test_depend>ament_flake8</test_depend>
<test_depend>ament_pep257</test_depend>

<export>
<build_type>ament_cmake</build_type>
Expand Down
30 changes: 16 additions & 14 deletions mep3_simulation/launch/robot_launch.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import os
import pathlib

from ament_index_python.packages import get_package_share_directory
import launch
from launch_ros.actions import Node
from launch.substitutions import LaunchConfiguration
from launch.actions import IncludeLaunchDescription
from launch.launch_description_sources import PythonLaunchDescriptionSource
from ament_index_python.packages import get_package_share_directory
from launch.substitutions import LaunchConfiguration
from launch_ros.actions import Node
from webots_ros2_core.webots_launcher import WebotsLauncher


Expand Down Expand Up @@ -41,11 +42,12 @@ def generate_launch_description():
arguments=['joint_state_broadcaster'] + controller_manager_timeout,
)

# The node which interacts with a robot in the Webots simulation is located in the
# `webots_ros2_driver` package under name `driver`.
# The node which interacts with a robot in the Webots simulation is located
# in the `webots_ros2_driver` package under name `driver`.
# It is necessary to run such a node for each robot in the simulation.
# Typically, we provide it the `robot_description` parameters from a URDF file and
# `ros2_control_params` from the `ros2_control` configuration file.
# Typically, we provide it the `robot_description` parameters from a URDF
# file and `ros2_control_params` from the `ros2_control`
# configuration file.
webots_robot_driver = Node(
package='webots_ros2_driver',
executable='driver',
Expand All @@ -58,13 +60,13 @@ def generate_launch_description():
]
)

# Often we want to publish robot transforms, so we use the `robot_state_publisher`
# node for that.
# If robot model is not specified in the URDF file then Webots can help us with the
# URDF exportation feature.
# Since the exportation feature is available only once the simulation has started and
# the `robot_state_publisher` node requires a `robot_description` parameter before we
# have to specify a dummy robot.
# Often we want to publish robot transforms, so we use the
# `robot_state_publisher` node for that.
# If robot model is not specified in the URDF file then Webots can help
# us with the URDF exportation feature.
# Since the exportation feature is available only once the simulation has
# started and the `robot_state_publisher` node requires a
# `robot_description` parameter before we have to specify a dummy robot.
robot_state_publisher = Node(
package='robot_state_publisher',
executable='robot_state_publisher',
Expand Down
1 change: 0 additions & 1 deletion mep3_simulation/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
<depend>webots_ros2_driver</depend>
<depend>webots_ros2_control</depend>
<depend>robot_state_publisher</depend>
<test_depend>ament_copyright</test_depend>
<test_depend>ament_flake8</test_depend>
<test_depend>ament_pep257</test_depend>
<test_depend>python3-pytest</test_depend>
Expand Down
15 changes: 10 additions & 5 deletions mep3_simulation/setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from setuptools import setup
from glob import glob
import os

from setuptools import setup


package_name = 'mep3_simulation'

data = {
Expand All @@ -18,15 +20,18 @@
}


def files_in_directory(dir, extension=None):
def files_in_directory(path, extension=None):
files = []
for i in os.listdir(dir):
if not os.path.isdir(f'{dir}/{i}') and (extension is None or i.endswith(extension)):
files.append(f'{dir}/{i}')
for i in os.listdir(path):
if not os.path.isdir(f'{path}/{i}') and \
(extension is None or i.endswith(extension)):
files.append(f'{path}/{i}')
return files


data_files = []


data_files.extend([
('share/ament_index/resource_index/packages',
['resource/' + package_name]),
Expand Down
23 changes: 0 additions & 23 deletions mep3_simulation/test/test_copyright.py

This file was deleted.

14 changes: 0 additions & 14 deletions mep3_simulation/test/test_flake8.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,3 @@
# Copyright 2017 Open Source Robotics Foundation, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from ament_flake8.main import main_with_errors
import pytest

Expand Down
14 changes: 0 additions & 14 deletions mep3_simulation/test/test_pep257.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,3 @@
# Copyright 2015 Open Source Robotics Foundation, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from ament_pep257.main import main
import pytest

Expand Down

0 comments on commit 23d9f9a

Please sign in to comment.