Skip to content

Commit e27dc89

Browse files
committed
Add Toy example package and the skeleton of a simple example.
1 parent 2c151dc commit e27dc89

File tree

9 files changed

+183
-1
lines changed

9 files changed

+183
-1
lines changed

.github/workflows/simple.yaml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Simple Build
2+
on:
3+
push:
4+
# Will trigger on MERGES (or pushes) to main branch.
5+
branches:
6+
- 'main'
7+
pull_request:
8+
# Will ALSO trigger any time a PR is opened merging to main.
9+
# Specify '*' here to merge on PRs being opened against ANY branch.
10+
branches:
11+
- 'main'
12+
13+
jobs:
14+
# The name of the job is "build". All jobs run in SEPARATE containers, so
15+
# they may run on separate machines and have the workspace wiped inbetween.
16+
build:
17+
# Run on a github-hosted runner. To specify our own, select:
18+
# [self-hosted, linux] instead.
19+
runs-on: ubuntu-latest
20+
# This is the docker container that the image will run in. This is 20.04
21+
# with ros-noetic-desktop meta-package.
22+
container: osrf/ros:noetic-desktop
23+
steps:
24+
# Name is optional, uses: specify which ACTION is used (basically github
25+
# macros). You can write your own! Use with: to specify extra parameters.
26+
- name: Check out depository
27+
- uses: actions/checkout@v3
28+
with:
29+
path: ${HOME}/catkin_ws/src/toy_example_package
30+
submodules: recursive
31+
#- name: Install catkin-tools on Noetic
32+
# run: |
33+
# apt update && apt install -y python3-pip
34+
# pip3 install osrf-pycommon
35+
# apt update && apt install -y python3-wstool python3-catkin-tools
36+
- name: Build test
37+
run: |
38+
cd ${HOME}/catkin_ws
39+
catkin init
40+
catkin config --extend "/opt/ros/noetic"
41+
catkin config --merge-devel
42+
rosdep update
43+
rosdep install --from-paths src --ignore-src -y --rosdistro noetic
44+
catkin config --cmake-args -DCMAKE_BUILD_TYPE=Release
45+
catkin build --continue toy_example_package
46+
# shell: bash

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
11
# asl-actions
2-
Github Actions for ASL
2+
Github Actions and documentation for ASL.
3+
4+
## Getting Started
5+
First, you can start with the quick-start docs from GitHub: https://docs.github.com/en/actions/quickstart
6+
7+
Then you can follow along with a few simple tutorial workflows.
8+
File renamed without changes.

action.yml renamed to actions/delete-workspace/action.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ description: 'Clean up the workspace state before and/or after running.'
55
runs:
66
using: 'docker'
77
image: 'Dockerfile'
8+
File renamed without changes.

example_workflows/simple_catkin.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Build and Test Catkin Package
2+
on:
3+
push:
4+
# Will trigger on MERGES (or pushes) to main branch.
5+
branches:
6+
- 'main'
7+
pull_request:
8+
# Will ALSO trigger any time a PR is opened merging to main.
9+
# Specify '*' here to merge on PRs being opened against ANY branch.
10+
branches:
11+
- 'main'
12+
13+
jobs:
14+
# The name of the job is "build". All jobs run in SEPARATE containers, so
15+
# they may run on separate machines and have the workspace wiped inbetween.
16+
build:
17+
# Run on a github-hosted runner. To specify our own, select:
18+
# [self-hosted, linux] instead.
19+
runs-on: ubuntu-latest
20+
# This is the docker container that the image will run in. This is 20.04
21+
# with ros-noetic-desktop meta-package.
22+
container: osrf/ros:noetic-desktop
23+
steps:
24+
# Name is optional, uses: specify which ACTION is used (basically github
25+
# macros). You can write your own! Use with: to specify extra parameters.
26+
- name: Check out depository
27+
- uses: actions/checkout@v3
28+
with:
29+
path: ${HOME}/catkin_ws/src/my_package_name
30+
submodules: recursive
31+
- name: Install catkin-tools on Noetic
32+
run: |
33+
apt update && apt install -y python3-pip
34+
pip3 install osrf-pycommon
35+
apt update && apt install -y python3-wstool python3-catkin-tools
36+
- name: Install Dependencies
37+
run: |
38+
$GITHUB_WORKSPACE/install/prepare-jenkins-slave.sh
39+
shell: bash
40+
- name: Build test
41+
working-directory:
42+
env:
43+
DEBIAN_FRONTEND: noninteractive
44+
run: |
45+
apt update
46+
apt install -y autoconf libtool git qt5-default
47+
mkdir -p ${HOME}/catkin_ws/src;
48+
cd ${HOME}/catkin_ws
49+
catkin init
50+
catkin config --extend "/opt/ros/${{matrix.config.rosdistro}}"
51+
catkin config --merge-devel
52+
cd ${HOME}/catkin_ws
53+
rosdep update
54+
rosdep install --from-paths src --ignore-src -y --rosdistro noetic
55+
catkin config --cmake-args -DCMAKE_BUILD_TYPE=Release
56+
catkin build --continue my_package_name
57+
shell: bash

toy_example_package/CMakeLists.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
cmake_minimum_required(VERSION 3.0.2)
2+
project(toy_example_package)
3+
4+
add_compile_options(-std=c++11)
5+
6+
find_package(catkin REQUIRED COMPONENTS roscpp std_msgs)
7+
catkin_package(
8+
CATKIN_DEPENDS std_msgs roscpp
9+
)
10+
11+
include_directories(include ${catkin_INCLUDE_DIRS})
12+
13+
add_executable(publisher_node src/publisher.cpp)
14+
add_dependencies(publisher_node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
15+
target_link_libraries(publisher_node
16+
${catkin_LIBRARIES}
17+
)
18+
19+

toy_example_package/package.xml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0"?>
2+
<package format="2">
3+
<name>toy_example_package</name>
4+
<version>0.0.0</version>
5+
<description>Toy example package for Github Actions workflows.</description>
6+
7+
<maintainer email="[email protected]">Helen Oleynikova</maintainer>
8+
9+
<license>BSD</license>
10+
11+
<depend>roscpp</depend>
12+
<depend>std_msgs</depend>
13+
<buildtool_depend>catkin</buildtool_depend>
14+
15+
<export>
16+
</export>
17+
</package>

toy_example_package/src/publisher.cpp

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#include <ros/ros.h>
2+
#include <std_msgs/String.h>
3+
4+
#include <sstream>
5+
6+
// All this code is from the publisher tutorial:
7+
// https://wiki.ros.org/ROS/Tutorials/WritingPublisherSubscriber%28c%2B%2B%29
8+
int main(int argc, char **argv) {
9+
ros::init(argc, argv, "toy_example_publisher");
10+
11+
ros::NodeHandle nh, nh_private("~");
12+
13+
ros::Publisher pub = nh_private.advertise<std_msgs::String>("hello", 1);
14+
15+
ros::Rate loop_rate(10); // Hz
16+
17+
int count = 0;
18+
while (ros::ok()) {
19+
std_msgs::String msg;
20+
21+
std::stringstream ss;
22+
ss << "hello world " << count;
23+
msg.data = ss.str();
24+
25+
ROS_INFO("%s", msg.data.c_str());
26+
27+
pub.publish(msg);
28+
29+
ros::spinOnce();
30+
31+
loop_rate.sleep();
32+
++count;
33+
}
34+
35+
return 0;
36+
}

0 commit comments

Comments
 (0)