-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from AlexanderBarbie/main
updated docker compose files and added github actions
- Loading branch information
Showing
21 changed files
with
609 additions
and
300 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: PiCar-X Main Build | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
build: | ||
runs-on: self-hosted, rpi4 | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Build with Docker Compose | ||
run: | | ||
TAG=arm64v8 docker-compose -f docker-compose-core.yml build | ||
# - name: Run pytest in Docker container | ||
# run: | | ||
# docker-compose -f docker-compose-core.yml run --rm app pytest | ||
|
||
# - name: Start roslaunch in Docker container | ||
# run: | | ||
# docker-compose -f docker-compose-core.yml run --rm app roslaunch | ||
|
||
- name: Push to Docker Hub | ||
run: | | ||
TAG=arm64v8 docker-compose -f docker-compose-core.yml push |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,31 @@ | ||
FROM git.geomar.de:11411/open-source/arches/arches_core:1-0-0 | ||
ARG TAG=latest | ||
|
||
FROM ${TAG:+${TAG}/}ros:noetic as rosnoetic | ||
WORKDIR /root/catkin_ws/ | ||
RUN apt update -y \ | ||
&& apt-get install -y python3-pip python3-setuptools python3-catkin-tools wget unzip curl nano \ | ||
&& apt-get clean \ | ||
&& update-ca-certificates -f \ | ||
&& pip3 install --upgrade pip \ | ||
&& pip3 install pytest pytest-cov avro \ | ||
&& mkdir -p ./src/arches | ||
|
||
|
||
FROM rosnoetic as adtf | ||
RUN wget -c https://git.geomar.de/open-source/arches/arches_msgs/-/archive/master/arches_msgs-master.tar.gz -O - | tar -xz \ | ||
&& mv arches_msgs-master ./src/arches/arches_msgs \ | ||
&& wget -c https://git.geomar.de/open-source/arches/arches_core/-/archive/main/arches_core-main.tar.gz -O - | tar -xz \ | ||
&& mv arches_core-main ./src/arches/arches_core | ||
|
||
RUN /bin/bash -c "source /opt/ros/noetic/setup.bash && catkin config --isolate-devel --install && catkin build" \ | ||
&& touch /root/.bashrc \ | ||
&& echo "source /opt/ros/noetic/setup.bash" >> /root/.bashrc | ||
|
||
FROM adtf | ||
ENV ASSET_NAME '' | ||
|
||
COPY ./core ./src/core | ||
COPY ./ros/picarx_msgs ./src/picarx_msgs | ||
|
||
RUN pip3 install -e ./src/core/picarx \ | ||
&& /bin/bash -c "source /opt/ros/noetic/setup.bash && catkin build" | ||
|
||
ENTRYPOINT [ "/root/catkin_ws/src/arches/arches_core/ENTRYPOINT.sh" ] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
ROS_MASTER_URI=http://picarx:11311 | ||
ROS_HOST_PORT=11311 | ||
TAG=arm64v8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
ROS_MASTER_URI=http://picarx:11311 | ||
ROS_HOST_PORT=11311 | ||
TAG=arm64v8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import pytest | ||
from picarx.interfaces.actuators import TravelDirection, MotorSide | ||
from picarx.drivers.dcmotor import AbstractDCMotorDriver | ||
|
||
class TestAbstractDCMotorDriver: | ||
@pytest.fixture | ||
def dcmotor(self): | ||
return AbstractDCMotorDriver("test_motor", 1, 2, motor_side=MotorSide.LEFT) | ||
|
||
def test_name(self, dcmotor): | ||
assert dcmotor.name == "test_motor" | ||
|
||
def test_direction_pin(self, dcmotor): | ||
assert dcmotor.direction_pin == 1 | ||
|
||
def test_pwm_pin(self, dcmotor): | ||
assert dcmotor.pwm_pin == {'channel': 2, 'i2c_port': '\dev\i2c-1'} | ||
|
||
def test_motor_side(self, dcmotor): | ||
assert dcmotor.motor_side == MotorSide.LEFT | ||
|
||
def test_direction(self, dcmotor): | ||
assert dcmotor.direction == TravelDirection.FORWARD | ||
|
||
def test_speed(self, dcmotor): | ||
assert dcmotor.speed is None | ||
|
||
def test_drive_with_speed(self, dcmotor): | ||
dcmotor.drive_with_speed(50) | ||
assert dcmotor.speed == 50 | ||
|
||
def test_start(self, dcmotor): | ||
with pytest.raises(NotImplementedError): | ||
dcmotor.start() | ||
|
||
def test_stop(self, dcmotor): | ||
with pytest.raises(NotImplementedError): | ||
dcmotor.stop() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import unittest | ||
from unittest.mock import patch, mock_open, MagicMock, call | ||
import builtins | ||
import os | ||
import weakref | ||
from picarx.gpio import GPIO, Value, Pin, Direction, Edge, Active | ||
from twisted.internet import reactor | ||
from watchdog.observers import Observer | ||
from watchdog.events import FileSystemEventHandler | ||
|
||
class TestGPIO(unittest.TestCase): | ||
|
||
@patch('builtins.open', new_callable=mock_open) | ||
@patch.object(reactor, 'callInThread') | ||
@patch.object(FileSystemEventHandler, 'on_modified') | ||
@patch('os.path.exists', return_value=True) | ||
@patch('weakref.finalize', return_value=MagicMock()) | ||
def test_set_value_gpio(self, mock_weakref, mock_os, mock_watchdog, mock_reactor, mock_file): | ||
pin= GPIO().setup(17, direction=Direction.OUT, callback=None) | ||
pin.value = Value.HIGH.value | ||
mock_file.assert_called_with(Pin.SYSFS_GPIO_PIN_VALUE.format(17), 'w') | ||
mock_file().write.assert_called_with(str(1)) | ||
mock_os.assert_called_once() | ||
mock_weakref.assert_called_once() | ||
|
||
@patch('builtins.open', new_callable=mock_open) | ||
@patch.object(reactor, 'callInThread') | ||
@patch.object(FileSystemEventHandler, 'on_modified') | ||
@patch('os.path.exists', return_value=True) | ||
@patch('weakref.finalize', return_value=MagicMock()) | ||
def test_set_value_pin(self, mock_weakref, mock_os, mock_watchdog, mock_reactor, mock_file): | ||
pin = Pin(17) | ||
pin.value = 1 | ||
mock_file.assert_called_with(Pin.SYSFS_GPIO_PIN_VALUE.format(17), 'w') | ||
mock_file().write.assert_called_with(str(1)) | ||
mock_os.assert_called_once() | ||
mock_weakref.assert_called_once() | ||
|
||
@patch('builtins.open', new_callable=mock_open, read_data="1") | ||
@patch.object(reactor, 'callInThread') | ||
@patch.object(FileSystemEventHandler, 'on_modified') | ||
@patch('os.path.exists', return_value=True) | ||
@patch('weakref.finalize', return_value=MagicMock()) | ||
def test_read_value_pin(self, mock_weakref, mock_os, mock_watchdog, mock_reactor, mock_file): | ||
pin = Pin(17) | ||
self.assertEqual(pin.value, 1) | ||
mock_file.assert_called_with(Pin.SYSFS_GPIO_PIN_VALUE.format(17), 'r') | ||
mock_os.assert_called_once() | ||
mock_weakref.assert_called_once() | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
services: | ||
picarx-core-build: | ||
build: | ||
dockerfile: Dockerfile | ||
context: . | ||
image: abarbie/picarx:${TAG} | ||
|
||
networks: | ||
default: | ||
driver: bridge |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.