From: Erik Andresen Date: Fri, 24 Apr 2026 16:29:42 +0000 (+0200) Subject: Display: Add time X-Git-Url: https://defiant.homedns.org/gitweb/?a=commitdiff_plain;h=1fe884eb75724f225eb28708e9b954c495ce365c;p=a4wd3.git Display: Add time --- diff --git a/CMakeLists.txt b/CMakeLists.txt index a0cb2d1..d3edb0d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,10 +24,11 @@ target_include_directories(hw_node PUBLIC $ $) 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}) diff --git a/launch/a4wd3_launch.py b/launch/a4wd3_launch.py index 51cf9d2..3e257dd 100644 --- a/launch/a4wd3_launch.py +++ b/launch/a4wd3_launch.py @@ -34,6 +34,7 @@ def generate_launch_description(): 'base_frame': 'base_link', }], namespace='', + condition=IfCondition(with_nav) ) return LaunchDescription([ diff --git a/params/wiimote.config.yaml b/params/wiimote.config.yaml index 2f5e1f7..36386d9 100644 --- a/params/wiimote.config.yaml +++ b/params/wiimote.config.yaml @@ -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 diff --git a/src/display.cpp b/src/display.cpp index 243503a..cd4cc74 100644 --- a/src/display.cpp +++ b/src/display.cpp @@ -1,4 +1,6 @@ #include +#include +#include #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"""( " - %5.2f V - %5.2f A + %s + %5.2f V %5.2f A )"""; - 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");