From db96f9bdfbae9f22112ecd34e115e564375ee6f2 Mon Sep 17 00:00:00 2001 From: sskorol Date: Sun, 22 Oct 2023 23:26:52 +0300 Subject: [PATCH] GH-42: added RAE logo restoring on container shutdown. Signed-off-by: sskorol --- .dockerignore | 3 +++ Dockerfile | 23 +++++++++++++++++- assets/rae-logo-white.jpg | Bin 0 -> 4140 bytes rae_hw/include/rae_hw/peripherals/lcd.hpp | 4 ++++ rae_hw/launch/peripherals.launch.py | 4 ++++ rae_hw/src/peripherals/lcd.cpp | 27 ++++++++++++++++++---- 6 files changed, 55 insertions(+), 6 deletions(-) create mode 100644 .dockerignore create mode 100644 assets/rae-logo-white.jpg diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..ed34f38 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,3 @@ +.git +.github +.devcontainer \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 5994dcc..38923ef 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,12 +6,33 @@ ARG BUILD_TYPE="RelWithDebInfo" ENV DEBIAN_FRONTEND=noninteractive RUN apt-get update \ - && apt-get -y install --no-install-recommends software-properties-common git libusb-1.0-0-dev wget zsh python3-colcon-common-extensions python3-rosdep build-essential neovim tmux htop net-tools iputils-ping gpiod gstreamer1.0-plugins-bad gstreamer1.0-alsa libasound2-dev busybox + && apt-get -y install --no-install-recommends \ + software-properties-common \ + git \ + nano \ + libusb-1.0-0-dev \ + wget \ + zsh \ + python3-colcon-common-extensions \ + python3-rosdep \ + build-essential \ + neovim \ + tmux \ + htop \ + net-tools \ + iputils-ping \ + gpiod \ + gstreamer1.0-plugins-bad \ + gstreamer1.0-alsa \ + libasound2-dev \ + busybox ENV WS=/ws RUN mkdir -p $WS/src COPY ./ .$WS/src/rae-ros +RUN cp -R .$WS/src/rae-ros/assets/. /usr/share +RUN rm -rf .$WS/src/rae-ros/assets RUN rm -rf .$WS/src/rae-ros/rae_gazebo RUN cd .$WS/ && apt update && rosdep update && rosdep install --from-paths src --ignore-src -y --skip-keys depthai --skip-keys depthai_bridge --skip-keys depthai_ros_driver --skip-keys audio_msgs --skip-keys laserscan_kinect --skip-keys ira_laser_tools diff --git a/assets/rae-logo-white.jpg b/assets/rae-logo-white.jpg new file mode 100644 index 0000000000000000000000000000000000000000..079e8f978363e7383a7d357467ac75932a3183c1 GIT binary patch literal 4140 zcmbtXc|4SB`@d(58Cf#ISh61~`x0`*A#0eBb!MV5mPAIjImli}l(opd6e{~t)|6dQ z5iPb#gis=7H@{~by`A%W-*etS-fKQH&-cEz=UVRPp6j8$roIDcLp=jM0E58*0r~*y zdw98lwl>k!%tX%ss|yJLfakb5ki8Ld0Fd2%yv+2qgm8F*5NZn019rd(P=KD~;O%k5 z)D#Q;mcG9PkS758rD?wYR_#9vSR9?a9RPp{L1Ik@4=*1G+d){_*T;i~uS1x_;WWt+ z!o?7l@`3_{@M{|1{trAy!_M0n4ne@-Wnrcb<;DSFA?H6~`#)ia(_UmqM-kEybtJn( z{^7Vkup!pXv<#V@+%3(at0?s41Ny)K90R662-pJ(Z~<<>2S`I#cZlN+ z%pkee-`MkR+nYjG_K=keaDXgyz*#^Bq-}dZ>j9(#(a+j?pE{_p&4Mv&0YLwTO8qJZ z04fQ9&3GzxJ(o(|%maXK1b~O`Kkd)v0HE>>;>Z8wiDm=98V20>C}! zLGmJP--izRg`YYFz+xc)EO-FedjViP@kiYt8BGpuyaK=isulJL0I6vJ>~n^E+x$)5 z43NRU>h_O1JN2Uu18v&={hx^D|#XHLo$xPu(zeuA;3%r18_7Q8rs2A8$WDzu5{DverhY~00DyFXF)h?763Df zeP27ThH?e&fklfpx%vxcJ$y=+A_P#x0!T_tt{tHmg;#!8fsCfNM|8>)cd z55Be$%Cu#@_)t)@H6(wm@P4T{9-<`@+0&zXF1=+Of5Hw|?9T{a;VwlS zVB&UgW5T?~>=Sn+n3iU+q_5QUhiyqJihajpVoJ)TuvLCGDH3lr2eb5vmfkI;Ww*b` z+&Lk!t1qH2oEhmtp#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E)3Cw=y&biTi-Oib+tTjssl!?*9)t}dkFU7gd?^516jBqt6mk8F*{8hgB>iC^C? zuuWY^Jw-_U`qZ?>ti?uXSw#-^)^Dl9gKyiOb~mRX;dJ{8xx zJPws;dxqT}|DiGVue3`v5eB^-ArcLQ5|0AFfB;8mFH4~e2)HJ+1c?Tsq0mwj0sf8t zVZNaaK)~cOQIQy8PCVs7tU7fe_he+%*M^V8_C8UlXX>MIwG|u`hjI1)4{Wx!MWO`R1YE| zS28#jM}@MU&eS{^#w2YL*{blaiBV3Dk6A>XOWpR;Z|$*6DpB}T=J!nOdQ4D@6?Oiq1X#H3M$yu-CspDG%S iM%41UrQR5_`aF)B`)+Zo9ZI`f+THj;7E=jz@c#e;V;+70 literal 0 HcmV?d00001 diff --git a/rae_hw/include/rae_hw/peripherals/lcd.hpp b/rae_hw/include/rae_hw/peripherals/lcd.hpp index 08d230f..44ef2fa 100644 --- a/rae_hw/include/rae_hw/peripherals/lcd.hpp +++ b/rae_hw/include/rae_hw/peripherals/lcd.hpp @@ -2,11 +2,13 @@ #include #include #include +#include #include "rclcpp/rclcpp.hpp" #include "sensor_msgs/msg/image.hpp" #include "cv_bridge/cv_bridge.h" #include "opencv2/opencv.hpp" + namespace rae_hw { class LCDNode : public rclcpp::Node @@ -16,6 +18,7 @@ namespace rae_hw ~LCDNode(); void image_callback(const sensor_msgs::msg::Image::SharedPtr msg); + void display_image(const cv::Mat& img); private: rclcpp::Subscription::SharedPtr subscription_; @@ -24,5 +27,6 @@ namespace rae_hw struct fb_var_screeninfo vinfo; struct fb_fix_screeninfo finfo; long screensize; + std::string default_logo_path; }; } \ No newline at end of file diff --git a/rae_hw/launch/peripherals.launch.py b/rae_hw/launch/peripherals.launch.py index a0b9bee..aa5010e 100644 --- a/rae_hw/launch/peripherals.launch.py +++ b/rae_hw/launch/peripherals.launch.py @@ -34,6 +34,9 @@ def launch_setup(context, *args, **kwargs): name='lcd_node', package='rae_hw', plugin='rae_hw::LCDNode', + parameters=[{ + 'default_logo_path': LaunchConfiguration('default_logo_path') + }], ), ComposableNode( name='led_node', @@ -62,6 +65,7 @@ def generate_launch_description(): DeclareLaunchArgument('name', default_value='rae'), DeclareLaunchArgument('run_container', default_value='true'), DeclareLaunchArgument('enable_battery_status', default_value='true'), + DeclareLaunchArgument('default_logo_path', default_value='/usr/share/rae-logo-white.jpg'), ] return LaunchDescription( diff --git a/rae_hw/src/peripherals/lcd.cpp b/rae_hw/src/peripherals/lcd.cpp index 2a74386..27f9e07 100644 --- a/rae_hw/src/peripherals/lcd.cpp +++ b/rae_hw/src/peripherals/lcd.cpp @@ -15,6 +15,10 @@ namespace rae_hw LCDNode::LCDNode(const rclcpp::NodeOptions &options) : Node("lcd_node", options) { + std::string logo_key = "default_logo_path"; + declare_parameter(logo_key); + default_logo_path = get_parameter(logo_key).as_string(); + // Open the framebuffer device fbfd = open("/dev/fb0", O_RDWR); if (fbfd == -1) @@ -52,16 +56,22 @@ namespace rae_hw "lcd", 10, std::bind(&LCDNode::image_callback, this, std::placeholders::_1)); RCLCPP_INFO(this->get_logger(), "LCD node running!"); } + LCDNode::~LCDNode() { + // Load default image + cv::Mat default_img = cv::imread(default_logo_path); + if (!default_img.empty()) + { + display_image(default_img); + } + munmap(fbp, screensize); close(fbfd); } - void LCDNode::image_callback(const sensor_msgs::msg::Image::SharedPtr msg) + void LCDNode::display_image(const cv::Mat& img) { - // Convert ROS image message to OpenCV image - cv::Mat img = cv_bridge::toCvCopy(msg, "bgr8")->image; // Resize to match the screen dimensions cv::resize(img, img, cv::Size(vinfo.xres, vinfo.yres)); // Iterate over the image pixels @@ -77,8 +87,15 @@ namespace rae_hw *((cv::Vec3b *)(fbp + location)) = pixel; } } - }; + } + void LCDNode::image_callback(const sensor_msgs::msg::Image::SharedPtr msg) + { + // Convert ROS image message to OpenCV image + cv::Mat img = cv_bridge::toCvCopy(msg, "bgr8")->image; + display_image(img); + }; } + #include "rclcpp_components/register_node_macro.hpp" -RCLCPP_COMPONENTS_REGISTER_NODE(rae_hw::LCDNode); \ No newline at end of file +RCLCPP_COMPONENTS_REGISTER_NODE(rae_hw::LCDNode);