Skip to content

Commit e339e1d

Browse files
authored
Add ROS2 build test (#33)
* Add ROS2 build test Fix format Remove wstool Run with bash * Address review comments
1 parent 0196574 commit e339e1d

File tree

3 files changed

+37
-43
lines changed

3 files changed

+37
-43
lines changed

.github/workflows/build_test.yml

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Build Test
22
on:
33
push:
44
branches:
5-
- 'master'
5+
- 'ros2'
66
pull_request:
77
branches:
88
- '*'
@@ -14,8 +14,7 @@ jobs:
1414
fail-fast: false
1515
matrix:
1616
config:
17-
- {rosdistro: 'melodic', container: 'px4io/px4-dev-ros-melodic:2021-12-11'}
18-
- {rosdistro: 'noetic', container: 'px4io/px4-dev-ros-noetic:2021-12-11'}
17+
- {rosdistro: 'humble', container: 'osrf/ros:humble-desktop'}
1918
container: ${{ matrix.config.container }}
2019
steps:
2120
- uses: actions/checkout@v1
@@ -31,26 +30,21 @@ jobs:
3130
- name: Build Test
3231
working-directory:
3332
run: |
34-
mkdir -p $HOME/catkin_ws/src;
35-
cd $HOME/catkin_ws
36-
catkin init
37-
catkin config --extend "/opt/ros/${{matrix.config.rosdistro}}"
38-
catkin config --merge-devel
39-
cd $HOME/catkin_ws/src
33+
mkdir -p $HOME/ros2_ws/src;
34+
cd $HOME/ros2_ws/src
4035
ln -s $GITHUB_WORKSPACE
41-
cd $HOME/catkin_ws
42-
wstool init src src/grid_map_geo/dependencies.rosinstall
43-
wstool update -t src -j4
36+
cd $HOME/ros2_ws
37+
source /opt/ros/humble/setup.bash
4438
rosdep update
4539
rosdep install --from-paths src --ignore-src -y --rosdistro ${{matrix.config.rosdistro}}
46-
catkin config --cmake-args -DCMAKE_BUILD_TYPE=Release -DCATKIN_ENABLE_TESTING=False
47-
catkin build -j$(nproc) -l$(nproc) grid_map_geo
48-
- name: unit_tests
49-
working-directory:
50-
run: |
51-
cd $HOME/catkin_ws/src
52-
catkin config --cmake-args -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCATKIN_ENABLE_TESTING=True
53-
catkin build grid_map_geo --no-deps -i --catkin-make-args tests
54-
source $HOME/catkin_ws/devel/setup.bash
55-
status=0 && for f in $HOME/catkin_ws/devel/lib/*/*-test; do $f || exit 1; done
40+
colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release --packages-up-to grid_map_geo
5641
shell: bash
42+
# - name: unit_tests
43+
# working-directory:
44+
# run: |
45+
# cd $HOME/catkin_ws/src
46+
# catkin config --cmake-args -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCATKIN_ENABLE_TESTING=True
47+
# catkin build grid_map_geo --no-deps -i --catkin-make-args tests
48+
# source $HOME/catkin_ws/devel/setup.bash
49+
# status=0 && for f in $HOME/catkin_ws/devel/lib/*/*-test; do $f || exit 1; done
50+
# shell: bash

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ rosdep install --from-paths src --ignore-src -y
2121

2222
Build the package
2323
```
24-
colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release -DCATKIN_ENABLE_TESTING=False --packages-up-to grid_map_geo
24+
colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release --packages-up-to grid_map_geo
2525
```
2626
## Running the package
2727
The default launch file can be run as the following command.

src/test_tif_loader.cpp

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -48,32 +48,32 @@
4848
using namespace std::chrono_literals;
4949

5050
class MapPublisher : public rclcpp::Node {
51-
public:
52-
MapPublisher() : Node("map_publisher") {
53-
original_map_pub_ = this->create_publisher<grid_map_msgs::msg::GridMap>("elevation_map", 1);
51+
public:
52+
MapPublisher() : Node("map_publisher") {
53+
original_map_pub_ = this->create_publisher<grid_map_msgs::msg::GridMap>("elevation_map", 1);
5454

55-
std::string file_path = this->declare_parameter("tif_path", ".");
56-
std::string color_path = this->declare_parameter("tif_color_path", ".");
55+
std::string file_path = this->declare_parameter("tif_path", ".");
56+
std::string color_path = this->declare_parameter("tif_color_path", ".");
5757

58-
RCLCPP_INFO_STREAM(get_logger(), "file_path " << file_path);
59-
RCLCPP_INFO_STREAM(get_logger(), "color_path " << color_path);
58+
RCLCPP_INFO_STREAM(get_logger(), "file_path " << file_path);
59+
RCLCPP_INFO_STREAM(get_logger(), "color_path " << color_path);
6060

61-
map_ = std::make_shared<GridMapGeo>();
62-
map_->Load(file_path, false, color_path);
63-
timer_ = this->create_wall_timer(5s, std::bind(&MapPublisher::timer_callback, this));
64-
}
65-
private:
66-
void timer_callback() {
67-
auto msg = grid_map::GridMapRosConverter::toMessage(map_->getGridMap());
68-
original_map_pub_->publish(std::move(msg));
69-
}
70-
rclcpp::TimerBase::SharedPtr timer_;
71-
rclcpp::Publisher<grid_map_msgs::msg::GridMap>::SharedPtr original_map_pub_;
72-
std::shared_ptr<GridMapGeo> map_;
61+
map_ = std::make_shared<GridMapGeo>();
62+
map_->Load(file_path, false, color_path);
63+
timer_ = this->create_wall_timer(5s, std::bind(&MapPublisher::timer_callback, this));
64+
}
65+
66+
private:
67+
void timer_callback() {
68+
auto msg = grid_map::GridMapRosConverter::toMessage(map_->getGridMap());
69+
original_map_pub_->publish(std::move(msg));
70+
}
71+
rclcpp::TimerBase::SharedPtr timer_;
72+
rclcpp::Publisher<grid_map_msgs::msg::GridMap>::SharedPtr original_map_pub_;
73+
std::shared_ptr<GridMapGeo> map_;
7374
};
7475

7576
int main(int argc, char **argv) {
76-
7777
rclcpp::init(argc, argv);
7878
rclcpp::spin(std::make_shared<MapPublisher>());
7979
rclcpp::shutdown();

0 commit comments

Comments
 (0)