]> defiant.homedns.org Git - a4wd3.git/commitdiff
Display: Add time
authorErik Andresen <erik@vontaene.de>
Fri, 24 Apr 2026 16:29:42 +0000 (18:29 +0200)
committerErik Andresen <erik@vontaene.de>
Fri, 24 Apr 2026 16:29:42 +0000 (18:29 +0200)
CMakeLists.txt
launch/a4wd3_launch.py
params/wiimote.config.yaml
src/display.cpp

index a0cb2d1140473bcb3279939bf1dc3d246ce36a67..d3edb0d297d776bd643ce9733943dc269b10fba0 100644 (file)
@@ -24,10 +24,11 @@ target_include_directories(hw_node PUBLIC
   $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
   $<INSTALL_INTERFACE:include>)
 target_link_libraries(hw_node i2c)
-target_compile_features(hw_node PUBLIC c_std_99 cxx_std_17)  # Require C99 and C++17
+target_compile_features(hw_node PUBLIC c_std_99 cxx_std_17)
 
 add_executable(display src/display.cpp)
 ament_target_dependencies(display rclcpp sensor_msgs)
+target_compile_features(display PUBLIC cxx_std_20)
 
 install(TARGETS hw_node
   DESTINATION lib/${PROJECT_NAME})
index 51cf9d217e03964cc408455d34059d72f4fdc696..3e257dd72661ae48f89cfa1ba9c5b3fa08e5c52e 100644 (file)
@@ -34,6 +34,7 @@ def generate_launch_description():
           'base_frame': 'base_link',
        }],
        namespace='',
+       condition=IfCondition(with_nav)
     )
 
     return LaunchDescription([
index 2f5e1f702d89e7d4eedc85889ef2603b36225c3d..36386d9c3fa7f44253883dbc91b08963cf45ba61 100644 (file)
@@ -3,7 +3,7 @@ teleop_twist_joy_node:
     axis_linear:
       x: 1
     scale_linear:
-      x: -1.0
+      x: -2.0
     scale_linear_turbo:
       x: 4.0
 
index 243503aae7959488ec5f1a69f870ceaef2e5114f..cd4cc741c631f2017df5df7d1762ba33fa78ebcd 100644 (file)
@@ -1,4 +1,6 @@
 #include <memory>
+#include <chrono>
+#include <format>
 
 #include "rclcpp/rclcpp.hpp"
 #include "sensor_msgs/msg/battery_state.hpp"
@@ -33,14 +35,16 @@ class A4wd3display : public rclcpp::Node {
                        const char *svg_template = R"""(
                                <svg width="128" height="64" xmlns="http://www.w3.org/2000/svg">"
                                        <rect width="128" height="64" x="0" y="0" style="fill:rgb(255,255,255)" />
-                                       <text x="0" y="15" font-family="monospace" xml:space="preserve">%5.2f V</text>
-                                       <text x="0" y="30" font-family="monospace" xml:space="preserve">%5.2f A</text>
+                                       <text x="0" y="15" font-family="monospace" xml:space="preserve">%s</text>
+                                       <text x="0" y="30" font-family="monospace" xml:space="preserve">%5.2f V   %5.2f A</text>
                                        <text x="0" y="45" font-family="monospace" xml:space="preserve"></text>
                                        <text x="0" y="60" font-family="monospace" xml:space="preserve"></text>
                                </svg>
                        )""";
 
-                       snprintf(svg, 1024, svg_template, msg->voltage, msg->current);
+                       const auto now = std::chrono::system_clock::now();
+                       std::string timestr = std::format("{:%d.%m.%y %H:%M:%OS}", now);
+                       snprintf(svg, 1024, svg_template, timestr.c_str(), msg->voltage, msg->current);
                        RCLCPP_DEBUG(this->get_logger(), "%s", svg);
                        if (sendto(sock, svg, strlen(svg), 0, (struct sockaddr *)&addr, sizeof(addr)) < 0 ) {
                                perror("sendto");