Skip to content

Commit

Permalink
Add Toy example package and the skeleton of a simple example.
Browse files Browse the repository at this point in the history
  • Loading branch information
helenol committed Nov 7, 2023
1 parent 2c151dc commit e27dc89
Show file tree
Hide file tree
Showing 9 changed files with 183 additions and 1 deletion.
46 changes: 46 additions & 0 deletions .github/workflows/simple.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Simple Build
on:
push:
# Will trigger on MERGES (or pushes) to main branch.
branches:
- 'main'
pull_request:
# Will ALSO trigger any time a PR is opened merging to main.
# Specify '*' here to merge on PRs being opened against ANY branch.
branches:
- 'main'

jobs:
# The name of the job is "build". All jobs run in SEPARATE containers, so
# they may run on separate machines and have the workspace wiped inbetween.
build:
# Run on a github-hosted runner. To specify our own, select:
# [self-hosted, linux] instead.
runs-on: ubuntu-latest
# This is the docker container that the image will run in. This is 20.04
# with ros-noetic-desktop meta-package.
container: osrf/ros:noetic-desktop
steps:
# Name is optional, uses: specify which ACTION is used (basically github
# macros). You can write your own! Use with: to specify extra parameters.
- name: Check out depository
- uses: actions/checkout@v3
with:
path: ${HOME}/catkin_ws/src/toy_example_package
submodules: recursive
#- name: Install catkin-tools on Noetic
# run: |
# apt update && apt install -y python3-pip
# pip3 install osrf-pycommon
# apt update && apt install -y python3-wstool python3-catkin-tools
- name: Build test
run: |
cd ${HOME}/catkin_ws
catkin init
catkin config --extend "/opt/ros/noetic"
catkin config --merge-devel
rosdep update
rosdep install --from-paths src --ignore-src -y --rosdistro noetic
catkin config --cmake-args -DCMAKE_BUILD_TYPE=Release
catkin build --continue toy_example_package
# shell: bash
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
# asl-actions
Github Actions for ASL
Github Actions and documentation for ASL.

## Getting Started
First, you can start with the quick-start docs from GitHub: https://docs.github.com/en/actions/quickstart

Then you can follow along with a few simple tutorial workflows.

File renamed without changes.
1 change: 1 addition & 0 deletions action.yml → actions/delete-workspace/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ description: 'Clean up the workspace state before and/or after running.'
runs:
using: 'docker'
image: 'Dockerfile'

File renamed without changes.
57 changes: 57 additions & 0 deletions example_workflows/simple_catkin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Build and Test Catkin Package
on:
push:
# Will trigger on MERGES (or pushes) to main branch.
branches:
- 'main'
pull_request:
# Will ALSO trigger any time a PR is opened merging to main.
# Specify '*' here to merge on PRs being opened against ANY branch.
branches:
- 'main'

jobs:
# The name of the job is "build". All jobs run in SEPARATE containers, so
# they may run on separate machines and have the workspace wiped inbetween.
build:
# Run on a github-hosted runner. To specify our own, select:
# [self-hosted, linux] instead.
runs-on: ubuntu-latest
# This is the docker container that the image will run in. This is 20.04
# with ros-noetic-desktop meta-package.
container: osrf/ros:noetic-desktop
steps:
# Name is optional, uses: specify which ACTION is used (basically github
# macros). You can write your own! Use with: to specify extra parameters.
- name: Check out depository
- uses: actions/checkout@v3
with:
path: ${HOME}/catkin_ws/src/my_package_name
submodules: recursive
- name: Install catkin-tools on Noetic
run: |
apt update && apt install -y python3-pip
pip3 install osrf-pycommon
apt update && apt install -y python3-wstool python3-catkin-tools
- name: Install Dependencies
run: |
$GITHUB_WORKSPACE/install/prepare-jenkins-slave.sh
shell: bash
- name: Build test
working-directory:
env:
DEBIAN_FRONTEND: noninteractive
run: |
apt update
apt install -y autoconf libtool git qt5-default
mkdir -p ${HOME}/catkin_ws/src;
cd ${HOME}/catkin_ws
catkin init
catkin config --extend "/opt/ros/${{matrix.config.rosdistro}}"
catkin config --merge-devel
cd ${HOME}/catkin_ws
rosdep update
rosdep install --from-paths src --ignore-src -y --rosdistro noetic
catkin config --cmake-args -DCMAKE_BUILD_TYPE=Release
catkin build --continue my_package_name
shell: bash
19 changes: 19 additions & 0 deletions toy_example_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
cmake_minimum_required(VERSION 3.0.2)
project(toy_example_package)

add_compile_options(-std=c++11)

find_package(catkin REQUIRED COMPONENTS roscpp std_msgs)
catkin_package(
CATKIN_DEPENDS std_msgs roscpp
)

include_directories(include ${catkin_INCLUDE_DIRS})

add_executable(publisher_node src/publisher.cpp)
add_dependencies(publisher_node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
target_link_libraries(publisher_node
${catkin_LIBRARIES}
)


17 changes: 17 additions & 0 deletions toy_example_package/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0"?>
<package format="2">
<name>toy_example_package</name>
<version>0.0.0</version>
<description>Toy example package for Github Actions workflows.</description>

<maintainer email="[email protected]">Helen Oleynikova</maintainer>

<license>BSD</license>

<depend>roscpp</depend>
<depend>std_msgs</depend>
<buildtool_depend>catkin</buildtool_depend>

<export>
</export>
</package>
36 changes: 36 additions & 0 deletions toy_example_package/src/publisher.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#include <ros/ros.h>
#include <std_msgs/String.h>

#include <sstream>

// All this code is from the publisher tutorial:
// https://wiki.ros.org/ROS/Tutorials/WritingPublisherSubscriber%28c%2B%2B%29
int main(int argc, char **argv) {
ros::init(argc, argv, "toy_example_publisher");

ros::NodeHandle nh, nh_private("~");

ros::Publisher pub = nh_private.advertise<std_msgs::String>("hello", 1);

ros::Rate loop_rate(10); // Hz

int count = 0;
while (ros::ok()) {
std_msgs::String msg;

std::stringstream ss;
ss << "hello world " << count;
msg.data = ss.str();

ROS_INFO("%s", msg.data.c_str());

pub.publish(msg);

ros::spinOnce();

loop_rate.sleep();
++count;
}

return 0;
}

0 comments on commit e27dc89

Please sign in to comment.