-
Notifications
You must be signed in to change notification settings - Fork 161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP | ROS2 port #40
WIP | ROS2 port #40
Changes from all commits
fa61d0d
51c25e7
e144a2c
c7f9f21
bc1ae72
bfe6abb
de97604
a67d777
6dfb858
3d712f4
94aaa78
60804cc
c6724d4
132835f
2f0b920
427dbd4
b42cb35
b89842b
f57abe2
b4796c2
4213acf
4e67a83
62ea2a5
f1b44c1
944b303
0f54fa9
33a178a
d6ef999
0c7d421
1695260
6619537
a28ba3f
fd561b2
cfb535e
711a5fd
7791668
f0f0eaf
9d34cc0
c51a73d
e78fe9e
e85e277
2ab53a7
f504d00
8b095df
0afd144
02158a6
7224894
89e925c
ac71a13
151cb92
4906b2a
bb48b3c
f8184d2
9573f43
c37eb66
cf204c9
07fa9ef
0d011b4
fabb4e0
2bb7c28
090251d
3a1749c
e121cca
12dabe1
dab3d15
0ac6fc8
aea12d0
5550107
ecef41f
579dcb3
f0b61d6
4887973
419fda1
ca5587b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
################################################################################ | ||
# Repo | ||
|
||
.git/* | ||
.dockerignore | ||
.gitignore | ||
**Dockerfile | ||
**.Dockerfile |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,4 +35,8 @@ | |
*.app | ||
|
||
# Vscode files | ||
.vscode/ | ||
.vscode/ | ||
build/* | ||
|
||
# Clion files | ||
.idea/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,164 @@ | ||
ARG FROM_IMAGE=ros:eloquent | ||
|
||
# multi-stage for caching | ||
FROM $FROM_IMAGE AS cache | ||
|
||
# clone underlay source | ||
ENV UNDERLAY_WS /opt/underlay_ws | ||
RUN mkdir -p $UNDERLAY_WS/src | ||
WORKDIR $UNDERLAY_WS | ||
COPY ./install/underlay.repos ./ | ||
RUN vcs import src < underlay.repos | ||
|
||
# copy overlay source | ||
ENV OVERLAY_WS /opt/overlay_ws | ||
RUN mkdir -p $OVERLAY_WS/src | ||
WORKDIR $OVERLAY_WS | ||
COPY ./install/overlay.repos ./ | ||
RUN vcs import src < overlay.repos | ||
|
||
# copy ros source | ||
ENV ROS_WS /opt/ros_ws | ||
RUN mkdir -p $ROS_WS/src | ||
WORKDIR $ROS_WS | ||
COPY ./install/ros.repos ./ | ||
RUN vcs import src < ros.repos | ||
COPY ./ src/MIT-SPARK/Kimera-VIO-ROS | ||
|
||
# copy manifests for caching | ||
WORKDIR /opt | ||
RUN find ./ -name "package.xml" | \ | ||
xargs cp --parents -t /tmp | ||
# && find ./ -name "COLCON_IGNORE" | \ | ||
# xargs cp --parents -t /tmp | ||
|
||
# multi-stage for building | ||
FROM $FROM_IMAGE AS build | ||
|
||
# install CI dependencies | ||
RUN apt-get update && apt-get install -q -y \ | ||
ccache \ | ||
lcov \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# install opencv dependencies | ||
RUN apt-get update && apt-get install -y \ | ||
gfortran \ | ||
libatlas-base-dev \ | ||
libgtk-3-dev \ | ||
libjpeg-dev \ | ||
libpng-dev \ | ||
libtiff-dev \ | ||
libvtk6-dev \ | ||
unzip \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# copy underlay manifests | ||
ENV UNDERLAY_WS /opt/underlay_ws | ||
COPY --from=cache /tmp/underlay_ws $UNDERLAY_WS | ||
WORKDIR $UNDERLAY_WS | ||
|
||
# install underlay dependencies | ||
RUN . /opt/ros/$ROS_DISTRO/setup.sh && \ | ||
apt-get update && rosdep install -q -y \ | ||
--from-paths src \ | ||
--ignore-src \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# copy underlay source | ||
COPY --from=cache $UNDERLAY_WS ./ | ||
|
||
# build underlay source | ||
ARG UNDERLAY_MIXINS="release" | ||
RUN . /opt/ros/$ROS_DISTRO/setup.sh && \ | ||
colcon build \ | ||
--symlink-install \ | ||
--mixin $UNDERLAY_MIXINS \ | ||
--cmake-args \ | ||
--no-warn-unused-cli \ | ||
-DGTSAM_BUILD_TESTS=OFF \ | ||
-DGTSAM_BUILD_EXAMPLES_ALWAYS=OFF \ | ||
-DGTSAM_BUILD_UNSTABLE=ON \ | ||
-DGTSAM_POSE3_EXPMAP=ON \ | ||
-DGTSAM_ROT3_EXPMAP=ON \ | ||
-DOPENCV_EXTRA_MODULES_PATH=$UNDERLAY_WS/src/opencv/opencv/contrib/modules | ||
# --event-handlers console_direct+ | ||
|
||
# copy overlay manifests | ||
ENV OVERLAY_WS /opt/overlay_ws | ||
COPY --from=cache /tmp/overlay_ws $OVERLAY_WS | ||
WORKDIR $OVERLAY_WS | ||
|
||
# install overlay dependencies | ||
RUN . $UNDERLAY_WS/install/setup.sh && \ | ||
apt-get update && rosdep install -q -y \ | ||
--from-paths \ | ||
src \ | ||
$UNDERLAY_WS/src \ | ||
--ignore-src \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# copy overlay source | ||
COPY --from=cache $OVERLAY_WS ./ | ||
|
||
# build overlay source | ||
ARG OVERLAY_MIXINS="release ccache" | ||
RUN . $UNDERLAY_WS/install/setup.sh && \ | ||
colcon build \ | ||
--symlink-install \ | ||
--mixin $OVERLAY_MIXINS \ | ||
--cmake-args \ | ||
--no-warn-unused-cli \ | ||
-DCMAKE_CXX_FLAGS="\ | ||
-Wno-parentheses \ | ||
-Wno-reorder \ | ||
-Wno-sign-compare \ | ||
-Wno-unused-but-set-variable \ | ||
-Wno-unused-function \ | ||
-Wno-unused-parameter \ | ||
-Wno-unused-value \ | ||
-Wno-unused-variable" | ||
# --event-handlers console_direct+ | ||
|
||
# copy ros manifests | ||
ENV ROS_WS /opt/ros_ws | ||
COPY --from=cache /tmp/ros_ws $ROS_WS | ||
WORKDIR $ROS_WS | ||
|
||
# install overlay dependencies | ||
RUN . $OVERLAY_WS/install/setup.sh && \ | ||
apt-get update && rosdep install -q -y \ | ||
--from-paths \ | ||
src \ | ||
$UNDERLAY_WS/src \ | ||
$OVERLAY_WS/src \ | ||
--ignore-src \ | ||
--skip-keys "\ | ||
Boost" \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# copy overlay source | ||
COPY --from=cache $ROS_WS ./ | ||
|
||
# build overlay source | ||
ARG ROS_MIXINS="release ccache" | ||
RUN . $OVERLAY_WS/install/setup.sh && \ | ||
colcon build \ | ||
--symlink-install \ | ||
--mixin $ROS_MIXINS \ | ||
--cmake-args \ | ||
--no-warn-unused-cli \ | ||
-DCMAKE_CXX_FLAGS="\ | ||
-Wno-sign-compare \ | ||
-Wno-unused-value \ | ||
-Wno-unused-variable \ | ||
-Wno-unused-but-set-variable \ | ||
-Wno-reorder \ | ||
-Wno-parentheses \ | ||
-Wno-unused-parameter" | ||
# --event-handlers console_direct+ | ||
|
||
# source overlay from entrypoint | ||
RUN sed --in-place \ | ||
's|^source .*|source "$ROS_WS/install/setup.bash"|' \ | ||
/ros_entrypoint.sh | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't this file in another pr? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This PR is still labeled WIP, so I haven't refactored everything possible into separate PRs yet. This is also used for development of the PR, so it was handy for me to keep in branch. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// #include <chrono> | ||
#include <functional> | ||
#include <future> | ||
#include <memory> | ||
#include <string> | ||
#include <thread> | ||
|
||
// Still need gflags for parameters in VIO | ||
#include <gflags/gflags.h> | ||
#include <glog/logging.h> | ||
|
||
#include "image_transport/subscriber_filter.h" | ||
|
||
#include "message_filters/subscriber.h" | ||
#include "message_filters/synchronizer.h" | ||
#include "message_filters/sync_policies/exact_time.h" | ||
|
||
#include "rclcpp/rclcpp.hpp" | ||
|
||
#include "sensor_msgs/msg/image.hpp" | ||
#include "sensor_msgs/msg/imu.hpp" | ||
|
||
#include <kimera-vio/pipeline/Pipeline.h> | ||
#include "kimera_vio_ros/RosDataProviderInterface.hpp" | ||
|
||
|
||
using namespace message_filters::sync_policies; | ||
using namespace sensor_msgs::msg; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we avoid
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure thing, I'll migrate to alias when I refactor. |
||
|
||
class KimeraVioNode : public VIO::RosDataProviderInterface{ | ||
public: | ||
KimeraVioNode( | ||
const std::string & node_name, | ||
const rclcpp::NodeOptions & options = rclcpp::NodeOptions()); | ||
|
||
~KimeraVioNode(); | ||
|
||
private: | ||
VIO::FrameId frame_count_; | ||
|
||
bool spin_outputs(); | ||
void stereo_cb( | ||
const Image::SharedPtr left_msg, | ||
const Image::SharedPtr right_msg); | ||
void imu_cb(const Imu::SharedPtr imu_msg); | ||
std::string timing_string(); | ||
|
||
rclcpp::callback_group::CallbackGroup::SharedPtr callback_group_stereo_; | ||
rclcpp::callback_group::CallbackGroup::SharedPtr callback_group_imu_; | ||
rclcpp::Subscription<Imu>::SharedPtr imu_sub_; | ||
|
||
typedef ExactTime<Image, Image> ExactPolicy; | ||
typedef message_filters::Synchronizer<ExactPolicy> ExactSync; | ||
std::shared_ptr<ExactSync> exact_sync_; | ||
image_transport::SubscriberFilter left_sub_, right_sub_; | ||
|
||
std::shared_ptr<message_filters::Subscriber<Image> > l_sub_; | ||
std::shared_ptr<message_filters::Subscriber<Image> > r_sub_; | ||
|
||
VIO::Pipeline vio_pipeline_; | ||
std::future<bool> handle_pipeline_; | ||
std::future<bool> handle_outputs_; | ||
rclcpp::WallRate outputs_loop_rate_; | ||
|
||
rclcpp::Time last_imu_timestamp_; | ||
rclcpp::Time last_stereo_timestamp_; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ruffsl I am not familiar with ROS2, but is this necessary? Or even, is this standard?
Why not using catkin_simple?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The officially supported method for integrating ROS2 with cmake is ament, please see:
https://design.ros2.org/articles/ament.html
It's hygienic to explicitly declare which dependencies are to be used in cmake, rather than roping just anything in the package.xml. This can be an issue when the package dependency name, and library the depency exports are not perfectly aligned strings. Also, it seems that catkin_simple hasn't been maintained since 2015.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see,
ament_cmake
seems like a big deal. Thanks for the pointer.