Skip to content

Commit

Permalink
Add ROS2 build test (#33)
Browse files Browse the repository at this point in the history
* Add ROS2 build test




Fix format


Remove wstool 




Run with bash

* Address review comments
  • Loading branch information
Jaeyoung-Lim authored Dec 2, 2023
1 parent 0196574 commit e339e1d
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 43 deletions.
38 changes: 16 additions & 22 deletions .github/workflows/build_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Build Test
on:
push:
branches:
- 'master'
- 'ros2'
pull_request:
branches:
- '*'
Expand All @@ -14,8 +14,7 @@ jobs:
fail-fast: false
matrix:
config:
- {rosdistro: 'melodic', container: 'px4io/px4-dev-ros-melodic:2021-12-11'}
- {rosdistro: 'noetic', container: 'px4io/px4-dev-ros-noetic:2021-12-11'}
- {rosdistro: 'humble', container: 'osrf/ros:humble-desktop'}
container: ${{ matrix.config.container }}
steps:
- uses: actions/checkout@v1
Expand All @@ -31,26 +30,21 @@ jobs:
- name: Build Test
working-directory:
run: |
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/src
mkdir -p $HOME/ros2_ws/src;
cd $HOME/ros2_ws/src
ln -s $GITHUB_WORKSPACE
cd $HOME/catkin_ws
wstool init src src/grid_map_geo/dependencies.rosinstall
wstool update -t src -j4
cd $HOME/ros2_ws
source /opt/ros/humble/setup.bash
rosdep update
rosdep install --from-paths src --ignore-src -y --rosdistro ${{matrix.config.rosdistro}}
catkin config --cmake-args -DCMAKE_BUILD_TYPE=Release -DCATKIN_ENABLE_TESTING=False
catkin build -j$(nproc) -l$(nproc) grid_map_geo
- name: unit_tests
working-directory:
run: |
cd $HOME/catkin_ws/src
catkin config --cmake-args -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCATKIN_ENABLE_TESTING=True
catkin build grid_map_geo --no-deps -i --catkin-make-args tests
source $HOME/catkin_ws/devel/setup.bash
status=0 && for f in $HOME/catkin_ws/devel/lib/*/*-test; do $f || exit 1; done
colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release --packages-up-to grid_map_geo
shell: bash
# - name: unit_tests
# working-directory:
# run: |
# cd $HOME/catkin_ws/src
# catkin config --cmake-args -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCATKIN_ENABLE_TESTING=True
# catkin build grid_map_geo --no-deps -i --catkin-make-args tests
# source $HOME/catkin_ws/devel/setup.bash
# status=0 && for f in $HOME/catkin_ws/devel/lib/*/*-test; do $f || exit 1; done
# shell: bash
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ rosdep install --from-paths src --ignore-src -y

Build the package
```
colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release -DCATKIN_ENABLE_TESTING=False --packages-up-to grid_map_geo
colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release --packages-up-to grid_map_geo
```
## Running the package
The default launch file can be run as the following command.
Expand Down
40 changes: 20 additions & 20 deletions src/test_tif_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,32 +48,32 @@
using namespace std::chrono_literals;

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

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

RCLCPP_INFO_STREAM(get_logger(), "file_path " << file_path);
RCLCPP_INFO_STREAM(get_logger(), "color_path " << color_path);
RCLCPP_INFO_STREAM(get_logger(), "file_path " << file_path);
RCLCPP_INFO_STREAM(get_logger(), "color_path " << color_path);

map_ = std::make_shared<GridMapGeo>();
map_->Load(file_path, false, color_path);
timer_ = this->create_wall_timer(5s, std::bind(&MapPublisher::timer_callback, this));
}
private:
void timer_callback() {
auto msg = grid_map::GridMapRosConverter::toMessage(map_->getGridMap());
original_map_pub_->publish(std::move(msg));
}
rclcpp::TimerBase::SharedPtr timer_;
rclcpp::Publisher<grid_map_msgs::msg::GridMap>::SharedPtr original_map_pub_;
std::shared_ptr<GridMapGeo> map_;
map_ = std::make_shared<GridMapGeo>();
map_->Load(file_path, false, color_path);
timer_ = this->create_wall_timer(5s, std::bind(&MapPublisher::timer_callback, this));
}

private:
void timer_callback() {
auto msg = grid_map::GridMapRosConverter::toMessage(map_->getGridMap());
original_map_pub_->publish(std::move(msg));
}
rclcpp::TimerBase::SharedPtr timer_;
rclcpp::Publisher<grid_map_msgs::msg::GridMap>::SharedPtr original_map_pub_;
std::shared_ptr<GridMapGeo> map_;
};

int main(int argc, char **argv) {

rclcpp::init(argc, argv);
rclcpp::spin(std::make_shared<MapPublisher>());
rclcpp::shutdown();
Expand Down

0 comments on commit e339e1d

Please sign in to comment.