From 63a3729786ad37a7c4fa4b910f8bec03f4262b16 Mon Sep 17 00:00:00 2001 From: Nico Schubert Date: Tue, 5 May 2026 17:23:23 +0200 Subject: [PATCH 1/9] Revise README for Volksbot ROS2 project Updated README.md to reflect project changes and structure. --- README.md | 64 ++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 42 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index f005efb..4421134 100644 --- a/README.md +++ b/README.md @@ -1,34 +1,27 @@ -# Volksbot ROS2 branch +# Volksbot ROS2 +This project is an adaptation of the original code to the modern ROS2 alternative for the Volksbot rovers. -This branch contains the in progess migration of the volksbot package to ROS2 after applying the ros-migration-tool. After successful use of the migration tool not all ROS code snippets are converted into ROS2, like the subscriber, publisher and services. This further migration is now done manually. +## How To Build +1. clone the repository locally and `cd` into the ros2_ws folder +2. source ros2 (on initial build) or the current ros2 workspace +3. TODO: conmtinue -# Expanded Joystick Driver for Volksbot ROS2 +## How to Run +> TODO: add -This branch is used to convert the old joystick backend into a new and expanded ROS2 implementation. It will expand the useability and agility of the original implementation to allow easier project integration and force feedback. -The new implementation will no longer use the `/dev/input/js*` joystick devices but the more general `/dev/input/event*` event devices. -> It is usually advised to use the general event interface instead of the the more constraint joystick interface. +## Trouble shoot +> TODO: add -### Information - -To use the general event interface the joysticks event file handle needs to be ruled to a non dynamic device handle. At the moment only the **Logitech F710** and the **Microsoft X-Box One** joysticks are _used_ and will be fully integrated. Therefor the backend will currently only implement these joysticks. - -However integrating further joysticks is easily possible by adapting the applied rules and adding the necessary interface implementations. - - -### How to use - -Unlike the old implementation it is no longer necessary to preemptively define the joysticks `/dev/input/*` Path. -It will now automatically select one of the connected (and implemented) Joysticks. - -If multiple implemented joysticks are recognized, the one with the lowest number of its `/dev/input/js*` handle will be selected. This is usually the first connected joystick device. +## Bugs or Issues? +Any Bugs or Issues, pls open an Issue on this repository or conntact us directly. # Sick LMS -## Info -The library used is the [official ROS2 library](https://github.com/SICKAG/sick_scan_xd/tree/master) version 3.5.0 for sick scanners. +> [!Note] +> The library used is the [official ROS2 library](https://github.com/SICKAG/sick_scan_xd/tree/master) version 3.5.0 for sick scanners. ## [Building](https://github.com/SICKAG/sick_scan_xd/blob/master/INSTALL-ROS2.md#summary-for-the-different-build-options) @@ -88,4 +81,31 @@ Enter the following line in your terminal to set the logging directory for all l export ROS_LOG_DIR=./log/latest ``` -the logs can then be found under the linked folder `./logs/latest/` where `latest/` is a symlink to the folder of the latest build \ No newline at end of file +the logs can then be found under the linked folder `./logs/latest/` where `latest/` is a symlink to the folder of the latest build + + + + +--- +## Notes for Developers +# Expanded Joystick Driver for Volksbot ROS2 + +This branch is used to convert the old joystick backend into a new and expanded ROS2 implementation. It will expand the useability and agility of the original implementation to allow easier project integration and force feedback. + +The new implementation will no longer use the `/dev/input/js*` joystick devices but the more general `/dev/input/event*` event devices. +> It is usually advised to use the general event interface instead of the the more constraint joystick interface. + + +### Information + +To use the general event interface the joysticks event file handle needs to be ruled to a non dynamic device handle. At the moment only the **Logitech F710** and the **Microsoft X-Box One** joysticks are _used_ and will be fully integrated. Therefor the backend will currently only implement these joysticks. + +However integrating further joysticks is easily possible by adapting the applied rules and adding the necessary interface implementations. + + +### How to use + +Unlike the old implementation it is no longer necessary to preemptively define the joysticks `/dev/input/*` Path. +It will now automatically select one of the connected (and implemented) Joysticks. + +If multiple implemented joysticks are recognized, the one with the lowest number of its `/dev/input/js*` handle will be selected. This is usually the first connected joystick device. From 80402e2cae5ade84b1cf65581e8a55bf8826541d Mon Sep 17 00:00:00 2001 From: Nico Schubert Date: Tue, 12 May 2026 20:28:46 +0200 Subject: [PATCH 2/9] Rework main README.md --- README.md | 185 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 104 insertions(+), 81 deletions(-) diff --git a/README.md b/README.md index 4421134..1c1d759 100644 --- a/README.md +++ b/README.md @@ -1,111 +1,134 @@ # Volksbot ROS2 -This project is an adaptation of the original code to the modern ROS2 alternative for the Volksbot rovers. - - -## How To Build -1. clone the repository locally and `cd` into the ros2_ws folder -2. source ros2 (on initial build) or the current ros2 workspace -3. TODO: conmtinue - -## How to Run -> TODO: add - - -## Trouble shoot -> TODO: add +This project is an adaptation of the original code to the modern ROS2 alternative for the Volksbot rovers (the original ROS version can be found under the branch [ROS](https://github.com/JMUWRobotics/volksbot/tree/ROS1)). +--- +# Prerequisits +- Ubuntu 22.04 or Ubuntu 24.04 +- GCC 11.0 or greater +- [ROS2 humble](https://docs.ros.org/en/humble/index.html) -## Bugs or Issues? -Any Bugs or Issues, pls open an Issue on this repository or conntact us directly. +> [!Warning] +> Other Linux distributions may or may not work correctly. Therefore, it is recommented to use one of the distributions mentioned above. +> Please let us know your experience and success with other systems. +> [!Important] +> If you use Ubuntu 24.04, you will probably encounter a `Permission Denied` error when trying to run the `volksbot` node. +> To fix this error regard the section [Touble Shooting - Permission Denied](#permission-denied). -# Sick LMS +# Quickstart > [!Note] -> The library used is the [official ROS2 library](https://github.com/SICKAG/sick_scan_xd/tree/master) version 3.5.0 for sick scanners. - -## [Building](https://github.com/SICKAG/sick_scan_xd/blob/master/INSTALL-ROS2.md#summary-for-the-different-build-options) - -Building the library for the lms100 +> For advanced build options regard the section [How To Build - Advanced](#how-to-build---advanced). - colcon build --packages-select sick_scan_xd --cmake-args " -DROS_VERSION=2" " -DLDMRS=0" " -DSCANSEGMENT_XD=0" --event-handlers console_direct+ +## How To Build +1. clone the repository locally and `cd` into the ros2_ws folder +2. set the udev rules (once) so that the motor controllers are recognized by the code. + Copy the `42-usb-serial-volksbot.rules` from the `motor_controller` package into your udev rules: + ```bash + sudo cp src/motor_controller/42-usb-serial-volksbot.rules /etc/udev/rules.d/ + ``` + Afterwards, either restart or reset the udev server to load the new rules: + ```bash + udevadm control --reload-rules && udevadm trigger + ``` +4. *on your initial build* source the global ros2 environment *else* source the ROS2 workspace +5. build the project with the build script `volksbuild.sh`: + ```bash + ./volksbuild.sh + ``` + +> [!Tip] +> You can run the build with a set number of concurrent worker threads by supplying an argument to the build script. +> This is usefull when your system is limited in RAM or your OS freezes while building. (building with 2-4 threads should work on any system): +> ```bash +> ./volksbuild.sh n +> ``` -> TODO: (if possible?) add cmake args to the cmake file used for building +## How to Run +The `volksbot` node from the `volksbot` package must always be started as this node determines the connected rover and comunicates the configureation over the `rover` topic to all other nodes: +```bash +ros2 run volksbot volksbot +``` -## [Running / Launching](https://github.com/SICKAG/sick_scan_xd?tab=readme-ov-file#running-the-driver) +> [!Tip] +> If you want to select a specific rover supply the name of the rover as an argument: +> ```bash +> ros2 run volksbot volksbot [RoverName] +> ``` -Launching the sick driver for the lms100 ! Attention: must set the correct host-ip manually +In an other terminal you can run any node or the default launch script `praktikum_launch.py` of the package `volkslaunch`, which launches the remaining (not your customs) nodes. +```bash +ros2 launch volkslaunch praktikum_launch.py +``` - ros2 run sick_scan_xd sick_generic_caller ./src/sick_scan_xd/launch/sick_lms_1xx.launch hostname:=192.168.0.XX +--- +# Trouble Shooting +## Permission Denied +If you are running the `volksbot` node on Ubuntu 24, you might encounter a `Permission Denied` error during the selection process. +This happens because the program attempts to use ICMP sockets for pinging, which requires specific kernel permissions. +By default, some Ubuntu configurations set the allowed group range to `1 0`, meaning only the root user is permitted to open these sockets. -> TODO: configure and add laser specific settings like in the ROS1 volksbot parameter.yaml +To allow all users to use ICMP sockets, you have to type in the command: +```bash +sudo sysctl -w net.ipv4.ping_group_range="0 2147483647" +``` +To make this setting permanent, you have to edit your `/etc/sysctl.conf` and add the line `net.ipv4.ping_group_range=0 2147483647`. -# Building -> Hint: When your OS freezes on building consider using less parallel workers by adding ```--parallel-workers n``` to the colcon build command. (2 or 3 should usually work for everyone) +## maxon EPSO4 connection failure +> [!Note] +> This problem may only be temporary as it will be corrected by this [issue](https://github.com/JMUWRobotics/volksbot/issues/7). -### When building for the first follow the following steps: +If the maxon epos4 motor controller gets recognized under the correct `/dev/` device directive but you get any of the errors: +> `0x10000003`, `0x10000005`, `0x10000007`, `0x10000008` -1) source ros2 -```bash -source ${ros2_distro} -``` +you may need to set the correct USB port in the [rovers.yaml](). +Usually it is: `USB0`, `USB1`, `USB2`, `USB3` or `USB4` -2) only build the SICK LMS package -```bash -colcon build --packages-select sick_scan_xd --cmake-args " -DROS_VERSION=2" " -DLDMRS=0" " -DSCANSEGMENT_XD=0" --event-handlers console_direct+ -``` +--- +# Bugs or Issues? +Any Bugs or Issues, please open an [issue](https://docs.github.com/en/issues/tracking-your-work-with-issues/learning-about-issues/quickstart) on this [repository](https://github.com/JMUWRobotics/volksbot/issues) or conntact us directly. -3) source the project -```bash -source ./install/setup.bash -``` +--- +# How To Build - Advanced +> [!Tip] +> When your OS freezes on building consider using less parallel workers by adding ```--parallel-workers n``` to the colcon build command (2-4 should usually work for everyone). + +## When building for the first time: +1. source global ros2 environment + ```bash + source ${ros2_distro} + ``` +2. only build the SICK LMS package + ```bash + colcon build --packages-select sick_scan_xd --cmake-args " -DROS_VERSION=2" " -DLDMRS=0" " -DSCANSEGMENT_XD=0" --event-handlers console_direct+ + ``` +3. source the ros2 workspace + ```bash + source ./install/setup.bash + ``` +4. build the remaining packages + ```bash + colcon build --packages-ignore sick_scan_xd + ``` + +## Regular building: +> [!Caution] +> Make sure you are sourced into the workspace with +> ```bash +> source ./install/setup.bash +> ``` -4) build all other packages ```bash colcon build --packages-ignore sick_scan_xd ``` - -### For normal building use the following command -> Make sure you are source into the workspace with -> `source ./install/setup.bash` - +or just a subset of the packages: ```bash -colcon build --packages-ignore sick_scan_xd +colcon build --packages-select [package1] [package2] [package3] [...] ``` - +--- # Logging - Enter the following line in your terminal to set the logging directory for all logs: - ```bash export ROS_LOG_DIR=./log/latest ``` - the logs can then be found under the linked folder `./logs/latest/` where `latest/` is a symlink to the folder of the latest build - - - - ---- -## Notes for Developers -# Expanded Joystick Driver for Volksbot ROS2 - -This branch is used to convert the old joystick backend into a new and expanded ROS2 implementation. It will expand the useability and agility of the original implementation to allow easier project integration and force feedback. - -The new implementation will no longer use the `/dev/input/js*` joystick devices but the more general `/dev/input/event*` event devices. -> It is usually advised to use the general event interface instead of the the more constraint joystick interface. - - -### Information - -To use the general event interface the joysticks event file handle needs to be ruled to a non dynamic device handle. At the moment only the **Logitech F710** and the **Microsoft X-Box One** joysticks are _used_ and will be fully integrated. Therefor the backend will currently only implement these joysticks. - -However integrating further joysticks is easily possible by adapting the applied rules and adding the necessary interface implementations. - - -### How to use - -Unlike the old implementation it is no longer necessary to preemptively define the joysticks `/dev/input/*` Path. -It will now automatically select one of the connected (and implemented) Joysticks. - -If multiple implemented joysticks are recognized, the one with the lowest number of its `/dev/input/js*` handle will be selected. This is usually the first connected joystick device. From d936194177e050e68f03f34acdedddcdd1ce39f7 Mon Sep 17 00:00:00 2001 From: Nico Schubert Date: Tue, 12 May 2026 20:33:18 +0200 Subject: [PATCH 3/9] Add readme to lms strater --- ros2_ws/src/lms_starter/README.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 ros2_ws/src/lms_starter/README.md diff --git a/ros2_ws/src/lms_starter/README.md b/ros2_ws/src/lms_starter/README.md new file mode 100644 index 0000000..95a477a --- /dev/null +++ b/ros2_ws/src/lms_starter/README.md @@ -0,0 +1,17 @@ +# Sick LMS +> [!Note] +> The used version of the SICK LMS library is the [official ROS2 library](https://github.com/SICKAG/sick_scan_xd/tree/master) version 3.5.0 for sick scanners. + +## [Building](https://github.com/SICKAG/sick_scan_xd/blob/master/INSTALL-ROS2.md#summary-for-the-different-build-options) + +Building the library for the lms100 +```bash +colcon build --packages-select sick_scan_xd --cmake-args " -DROS_VERSION=2" " -DLDMRS=0" " -DSCANSEGMENT_XD=0" --event-handlers console_direct+ +``` + +## [Running / Launching](https://github.com/SICKAG/sick_scan_xd?tab=readme-ov-file#running-the-driver) + +Launching the sick driver for the lms100 ! Attention: must set the correct host-ip manually +```bash +ros2 run sick_scan_xd sick_generic_caller ./src/sick_scan_xd/launch/sick_lms_1xx.launch hostname:=192.168.0.XX +``` \ No newline at end of file From c9f3288ebfb74559fe0bf3ff450c9ce3acca1b99 Mon Sep 17 00:00:00 2001 From: Nico Schubert Date: Sun, 24 May 2026 00:20:29 +0200 Subject: [PATCH 4/9] add gamepad_driver readme --- ros2_ws/src/gamepad_driver/README.md | 86 ++++++++++++++++++++++++++-- 1 file changed, 80 insertions(+), 6 deletions(-) diff --git a/ros2_ws/src/gamepad_driver/README.md b/ros2_ws/src/gamepad_driver/README.md index 096f68a..b10e8e4 100644 --- a/ros2_ws/src/gamepad_driver/README.md +++ b/ros2_ws/src/gamepad_driver/README.md @@ -1,19 +1,93 @@ # Expanded Joystick Driver for Volksbot ROS2 -This branch is used to convert the old joystick backend into a new and expanded ROS2 implementation. It will expand the useability and agility of the original implementation to allow easier project integration and force feedback. +This package handles the gamepad input for the volksbot rovers. It dynamically recognizes connected gamepads and communicates the gamepad inputs vie the `gamepad` topic. In addition to that it also directly translates the gamepad inputs into velocity commands and publishes them on the `cmd_vel` topic. This allows for a direct control of the rover via the gamepad without the need for an additional node to translate the volksbot velocity command ROS2 messages. The driver is designed to be flexible and can support multiple types of controllers and can make use of the haptic feedback rumble if implemented in the controllers. + +The currently supported controllers are: +- **Logitech F710** +- **Microsoft X-Box One** + +## How To Use +To use the gamepad driver, simply run the `gamepad_driver` node: +```bash +ros2 run gamepad_driver gamepad_driver +``` + +Currently **two** drive modes are implemented to control the rover via the gamepad: +- **Arcade Drive**: The left thumb stick controls the forward and backward movement and left and right steering. +- **Throttle Drive**: The left thumb stick controls the left and right steering, the right trigger controls the forward acceleration and the left trigger controls the backward acceleration. This allows for a more intuitive control of the rover, especially for users familiar with racing games. + + + +The drive modes can be switched by pressing the `START` button on the controller. +In all drive modes the right thumb stick can be used to turn on the spot, where left and right movement of the stick will cause the rover to rotate left and right respectively. +Likewise, pressing the index Buttons `RB` and `LB` will increase or decrease the max speed of the rover, respectively. + +- Arcade Drive: +```yaml + / LT \ Switch Mode / RT \ + Slower--> | LB | | | RB | <--Faster + |------+--------------V--+------| + ) ^ Back Start Y ( + / < + > Logitech X A \ + ( v Mode Vibrate B ) + Accelerate ------> ^ ^ | + Steering ----> < O > < O > <---- Rotate <-CCW / CW-> + Decelerate ------> V V ) + \ /^^^^^^^^^^^^^^^^^^^\ / + \-__-/ \-__-/ +``` + +- Throttle Drive: +```yaml +Decelerate-> / LT \ Switch Mode / RT \ <--Accelerate + Slower--> | LB | | | RB | <--Faster + |------+--------------V--+------| + ) ^ Back Start Y ( + / < + > Logitech X A \ + ( v Mode Vibrate B ) + | ^ ^ | + Steering ----> < O > < O > <---- Rotate <-CCW / CW-> + ( V V ) + \ /^^^^^^^^^^^^^^^^^^^\ / + \-__-/ \-__-/ +``` + -The new implementation will no longer use the `/dev/input/js*` joystick devices but the more general `/dev/input/event*` event devices. -> It is usually advised to use the general event interface instead of the the more constraint joystick interface. +> [!Caution] +> For the **Logitech F710**: Make sure to set the switch on the back of the controller to the **X** mode, otherwise the controller will not be recognized by the driver and that you do not have the **mode** button activated (as indicated by the LED) as it switches the functions from the thumb stick to the D-pad. -### Information -To use the general event interface the joysticks event file handle needs to be ruled to a non dynamic device handle. At the moment only the **Logitech F710** and the **Microsoft X-Box One** joysticks are _used_ and will be fully integrated. Therefor the backend will currently only implement these joysticks. + + + + +# Information for Developer +The new implementation will no longer use the `/dev/input/js*` joystick devices but the more general `/dev/input/event*` event devices. +> It is usually advised to use the general event interface instead of the the more constraint joystick interface. + +## Information + +To use the general event interface the joysticks event file handle needs to be ruled to a non dynamic device handle. At the moment only the **Logitech F710** and the **Microsoft X-Box One** joysticks are _used_ and fully integrated. However integrating further joysticks is easily possible by adapting the applied rules and adding the necessary interface implementations. +## Internal Defines and Debug Symbols +The `volksbot_adapter.cpp` contains some internal defines that can be used for debugging and development. +These can be activated by uncommenting the corresponding `#define` statement. +The following are symbols which enable different print outputs to the console for display or debuging, by default the `PRINT_STATE` is activated: +| Symbol | Description | Printed Once | Printed Per Update Loop | +|:-------|:------------|:------------:|:-------------------------:| +| `PRINT_EVIO` | This will print the raw configuration data of the connected gamepad, once the connection is established, can be useful for debugging and setting up new joysticks. | ✅ | ❌ | +| `PRINT_STATE` | This will print a visualization of the gamepad inputs. | ❌ | ✅ | +| `PRINT_EVENT` | This will print every recorded input event. | ❌ | ✅ | +| `PRINT_VEL_CTRL` | This will print debug information for debugging the ACCEL_FORCE_FEEDBACK. | ❌ | ✅ | + +> **The following feature is currently unstable and currently disabled** +> +> `ACCEL_FORCE_FEEDBACK` is a feature that emulates force feedback by applying an acceleration to the rover when the trigger buttons are pressed. This can be used to give the user a better feel for the speed of the rover and can be useful for controlling the rover in tight spaces. -### How to use +## How to use Unlike the old implementation it is no longer necessary to preemptively define the joysticks `/dev/input/*` Path. It will now automatically select one of the connected (and implemented) Joysticks. From 00c9ba8bf5b7ff20718a1d8cae939f5a08949807 Mon Sep 17 00:00:00 2001 From: Nico Schubert Date: Sun, 24 May 2026 00:21:33 +0200 Subject: [PATCH 5/9] add test of selected printing mode for gamepad_driver --- .../gamepad_driver/src/volksbot_adapter.cpp | 35 ++++++++++++++++--- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/ros2_ws/src/gamepad_driver/src/volksbot_adapter.cpp b/ros2_ws/src/gamepad_driver/src/volksbot_adapter.cpp index cc02a15..8367e65 100644 --- a/ros2_ws/src/gamepad_driver/src/volksbot_adapter.cpp +++ b/ros2_ws/src/gamepad_driver/src/volksbot_adapter.cpp @@ -32,19 +32,42 @@ using namespace std::chrono_literals; //-----------------// // debug symbols // //-----------------// -// print a visualization of the gamepad inputs +// print the evio data of the gamepad (e.g. for debugging and setup of new gamepads) +// #define PRINT_EVIO + +// print a visualization of the gamepad inputs (gets called every update loop) // #define PRINT_STATE -// debug print every recorded input event +// debug print every recorded input event (gets called every update loop) // #define PRINT_EVENT -// debug print for debuging ACCEL_FORCE_FEEDBACK +// debug print for debuging ACCEL_FORCE_FEEDBACK (gets called every update loop) // #define PRINT_VEL_CTRL // enable emulated force feedback // works currently unstable // #define ACCEL_FORCE_FEEDBACK +//============================================================================= +// CODE +//============================================================================= + +// assert that at most one of the debug print options is enabled to avoid cluttered output +static_assert( + 0 + #ifdef PRINT_STATE + + 1 + #endif + #ifdef PRINT_EVENT + + 1 + #endif + #ifdef PRINT_VEL_CTRL + + 1 + #endif + <= 1, + "At most one of the debug print options PRINT_STATE, PRINT_EVENT and PRINT_VEL_CTRL can be enabled at the same time to avoid cluttered output!" +) + using std::placeholders::_1; using std::placeholders::_2; @@ -247,7 +270,6 @@ class Volks_gamepad : public rclcpp::Node { _pub_gp = create_publisher( VB::TOPIC_NAME_GAMEPAD, 10 ); _service_rumble = create_service( VB::SERVICE_NAME_RUMBLE, std::bind( &Volks_gamepad::set_rumble, this, _1, _2) ); - while( rclcpp::ok() ) { active_gamepad = device_util::select_and_connect_gamepad(true); @@ -256,7 +278,10 @@ class Volks_gamepad : public rclcpp::Node { rclcpp::sleep_for( nanoseconds( 1000ms ) ); } - active_gamepad->print_evio(); + + #ifdef PRINT_EVIO + active_gamepad->print_evio(); + #endif } void run( rclcpp::Executor& executor ) { From 13820a3151aa77a4f6e3a5b42f0eecb44a5a8bfa Mon Sep 17 00:00:00 2001 From: Nico Schubert Date: Sun, 24 May 2026 00:22:10 +0200 Subject: [PATCH 6/9] Add logging documentation --- ros2_ws/src/volksface/logging.md | 36 ++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 ros2_ws/src/volksface/logging.md diff --git a/ros2_ws/src/volksface/logging.md b/ros2_ws/src/volksface/logging.md new file mode 100644 index 0000000..a79824d --- /dev/null +++ b/ros2_ws/src/volksface/logging.md @@ -0,0 +1,36 @@ +# Logging +Enter the following line in your terminal to set the logging directory for all logs: +```bash +export ROS_LOG_DIR=./log/latest +``` +the logs can then be found under the linked folder `./logs/latest/` where `latest/` is a symlink to the folder of the latest build. + +## Logging for Developers and Debugging +The `volksface/logging.h` and `volksface/ansi.h` files define macros that should be used for debugging and logging in this project. + +### Base Logging Macros +Five logging levels are defined: `DEBUG`, `INFO`, `WARN`, `ERROR` and `FATAL` with the corresponding macros for logging: +- `LOG_DEBUG( args... )` (and `LOG_LN_DEBUG( args... )`) +- `LOG_INFO( args... )` (and `LOG_LN_INFO( args... )`) +- `LOG_WARN( args... )` (and `LOG_LN_WARN( args... )`) +- `LOG_ERROR( args... )` (and `LOG_LN_ERROR( args... )`) +- `LOG_FATAL( args... )` (and `LOG_LN_FATAL( args... )`) + +> [!Note] +> To append a new line to the log message (only for console logging as logging to a file will always place individual messages on new lines) you can use the corresponding `LOG_LN_*` macros. + +### Logging Configuration +To configure the logging behavior, the following preprocessor defines can be used before including the `logging.h` header: +- `USE_LOGGING`: This symbol defines the target of the logging macros, defaults to `0` (*Log to Console*) if not defined. The two possible versions are: + - `1` (*Log to File*): All logging calls are directed to the ROS2 logging system, writing the messages to a file in the specified logging directory (`ROS_LOG_DIR`). This should be used if no debugging or direct access to the console is required. + - `0` (*Log to Console*): If this logging method is selected all logging calls are directed to the standard C print functions, printing the messages directly to the console. It is useful for real-time debugging or explicit console rendering. However, with this method, no log messages will be saved to the log file. In this case use the `ROS_LOG_[LEVEL]` macros for ROS2 logging, but be aware that this may inadvertently cause some the log message to also be printed to the console (depending on the ROS2 logging configuration). + +- `USE_COLORED_LOGGING`: This symbol defines whether ANSI escape codes for coloring and special console commands are to be ignored when used in the logging string. `0` will omit any ANSI escape codes in the log messages. `1` will allow the use of ANSI escape codes in the log messages, which can be used for coloring or special console commands (like clearing the console or moving the cursor). Defaults to `0` if not defined. + +The concrete logging behavior used by each package is defined in the `project_config.cmake` file. + +### Advanced Logging +The `ansi.h` header defines a set of macros for using ANSI escape codes in the logging strings, which can be used for coloring or special console commands when logging to the console, like clearing the console or moving the cursor. These macros can be used in the logging strings when `USE_COLORED_LOGGING` is set to `1`. + +Special ANSI commands that are only meant to be emitted in console logging mode can be used in the `LOG_ANSI( args... )` and `LOG_LN_ANSI( args... )` macros. +Similar the `IF_PRINT( ... )` and `IF_LOG( ... )` macros can be used to conditionally include code only to be included in console logging or file logging mode, respectively. \ No newline at end of file From 88d080ade175b6a9128dc61c00d148cba9329615 Mon Sep 17 00:00:00 2001 From: Nico Schubert Date: Sun, 24 May 2026 00:23:00 +0200 Subject: [PATCH 7/9] Add RCLCPP logging alias for streamlined ROS2 logging calls --- ros2_ws/cmake/project_config.cmake | 2 +- .../src/volksface/include/volksface/logging.h | 18 +++++++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/ros2_ws/cmake/project_config.cmake b/ros2_ws/cmake/project_config.cmake index de17d9e..4a719a3 100644 --- a/ros2_ws/cmake/project_config.cmake +++ b/ros2_ws/cmake/project_config.cmake @@ -20,7 +20,7 @@ add_compile_definitions( USE_COLORED_LOGGING=1 # set logging for individual packages, will override the global logging config - # comment out to use global logging config + # [comment out to use global logging config} # USE_LOGGING_GAME_PAD=0 # USE_LOGGING_KEYBOARD=0 # USE_LOGGING_LMS_STARTER=0 diff --git a/ros2_ws/src/volksface/include/volksface/logging.h b/ros2_ws/src/volksface/include/volksface/logging.h index d7eafc8..8f02125 100644 --- a/ros2_ws/src/volksface/include/volksface/logging.h +++ b/ros2_ws/src/volksface/include/volksface/logging.h @@ -26,12 +26,18 @@ #define USE_COLORED_LOGGING 0 #endif +#define ROS_LOG_DEBUG( args... ) RCLCPP_DEBUG( LOGGER_ENTITY, args ) +#define ROS_LOG_INFO( args... ) RCLCPP_INFO( LOGGER_ENTITY, args ) +#define ROS_LOG_WARN( args... ) RCLCPP_WARN( LOGGER_ENTITY, args ) +#define ROS_LOG_ERROR( args... ) RCLCPP_ERROR( LOGGER_ENTITY, args ) +#define ROS_LOG_FATAL( args... ) RCLCPP_FATAL( LOGGER_ENTITY, args ) + #if USE_LOGGING - #define LOG_DEBUG( args... ) RCLCPP_DEBUG( LOGGER_ENTITY, args ) - #define LOG_INFO( args... ) RCLCPP_INFO( LOGGER_ENTITY, args ) - #define LOG_WARN( args... ) RCLCPP_WARN( LOGGER_ENTITY, args ) - #define LOG_ERROR( args... ) RCLCPP_ERROR( LOGGER_ENTITY, args ) - #define LOG_FATAL( args... ) RCLCPP_FATAL( LOGGER_ENTITY, args ) + #define LOG_DEBUG( args... ) ROS_LOG_DEBUG( args ) + #define LOG_INFO( args... ) ROS_LOG_INFO( args ) + #define LOG_WARN( args... ) ROS_LOG_WARN( args ) + #define LOG_ERROR( args... ) ROS_LOG_ERROR( args ) + #define LOG_FATAL( args... ) ROS_LOG_FATAL( args ) #define LOG_LN_DEBUG( args... ) LOG_DEBUG( args ) #define LOG_LN_INFO( args... ) LOG_INFO( args ) @@ -39,6 +45,7 @@ #define LOG_LN_ERROR( args... ) LOG_ERROR( args ) #define LOG_LN_FATAL( args... ) LOG_FATAL( args ) + // flags for "ansi.h" #define DISABLE_CONTROL_CODES 1 #define DISABLE_COLOR !USE_COLORED_LOGGING @@ -66,6 +73,7 @@ #define LOG_LN_ERROR( args... ) LOG_ERROR( args ) #define LOG_LN_FATAL( args... ) LOG_FATAL( args ) + // flags for "ansi.h" #define DISABLE_CONTROL_CODES 0 #define DISABLE_COLOR 0 From ce20eea7ff72e49d3291bc5a3506e818cbcb037c Mon Sep 17 00:00:00 2001 From: Nico Schubert Date: Sun, 24 May 2026 00:23:32 +0200 Subject: [PATCH 8/9] Update README.md --- README.md | 42 ++++++++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 1c1d759..2a0a9a9 100644 --- a/README.md +++ b/README.md @@ -13,14 +13,21 @@ This project is an adaptation of the original code to the modern ROS2 alternativ > [!Important] > If you use Ubuntu 24.04, you will probably encounter a `Permission Denied` error when trying to run the `volksbot` node. -> To fix this error regard the section [Touble Shooting - Permission Denied](#permission-denied). +> To fix this error regard the section [Trouble Shooting - Permission Denied](#permission-denied). # Quickstart > [!Note] > For advanced build options regard the section [How To Build - Advanced](#how-to-build---advanced). ## How To Build -1. clone the repository locally and `cd` into the ros2_ws folder +1. clone the repository locally + ```bash + git clone git@github.com:JMUWRobotics/volksbot.git + ``` +2. change to the `ros2_ws` directory + ```bash + cd volksbot/ros2_ws + ``` 2. set the udev rules (once) so that the motor controllers are recognized by the code. Copy the `42-usb-serial-volksbot.rules` from the `motor_controller` package into your udev rules: ```bash @@ -30,9 +37,18 @@ This project is an adaptation of the original code to the modern ROS2 alternativ ```bash udevadm control --reload-rules && udevadm trigger ``` -4. *on your initial build* source the global ros2 environment *else* source the ROS2 workspace -5. build the project with the build script `volksbuild.sh`: +4. + a) *on your **initial** build*: source the global ros2 environment: ```bash + source ${ros2_distro} + ``` + + b) ***else*** source the ROS2 workspace: + ```bash + source ./install/setup.bash + ``` +5. build the project with the build script `volksbuild.sh`: + ```bash ./volksbuild.sh ``` @@ -60,6 +76,16 @@ In an other terminal you can run any node or the default launch script `praktiku ros2 launch volkslaunch praktikum_launch.py ``` +> [!Caution] +> When playing back rosbags while connected to the rover you may want to comment out the `gamepad_driver` node from the launch script to avoid unwanted velocity commands to the motors with the recorded data. + +--- + +# Documentation & more Information +Regard the following documentation markdowns for further information on usage and configuration of the project: +- [Gamepad Driver](gamepad_driver/README.md): Information on how to use the gamepad and the different drive modes. +- [Logging](logging.md): Information on how to set up logging for the packages and how to use the logging macros for debugging and development and console prints. + --- # Trouble Shooting ## Permission Denied @@ -124,11 +150,3 @@ or just a subset of the packages: ```bash colcon build --packages-select [package1] [package2] [package3] [...] ``` - ---- -# Logging -Enter the following line in your terminal to set the logging directory for all logs: -```bash -export ROS_LOG_DIR=./log/latest -``` -the logs can then be found under the linked folder `./logs/latest/` where `latest/` is a symlink to the folder of the latest build From 44dbe32819dfa627fc8b8bf19393e67d3003ed72 Mon Sep 17 00:00:00 2001 From: Nico Schubert Date: Sun, 24 May 2026 00:33:20 +0200 Subject: [PATCH 9/9] fix markdown links and remove obsolete trouble shooting entry maxon EPOS4 connection failure noted as issue #7 was fixed with PR #12 --- README.md | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 2a0a9a9..12ab303 100644 --- a/README.md +++ b/README.md @@ -83,8 +83,8 @@ ros2 launch volkslaunch praktikum_launch.py # Documentation & more Information Regard the following documentation markdowns for further information on usage and configuration of the project: -- [Gamepad Driver](gamepad_driver/README.md): Information on how to use the gamepad and the different drive modes. -- [Logging](logging.md): Information on how to set up logging for the packages and how to use the logging macros for debugging and development and console prints. +- [Gamepad Driver](ros2_ws/src/gamepad_driver/README.md): Information on how to use the gamepad and the different drive modes. +- [Logging](ros2_ws/src/volksface/logging.md): Information on how to set up logging for the packages and how to use the logging macros for debugging and development and console prints. --- # Trouble Shooting @@ -99,15 +99,6 @@ sudo sysctl -w net.ipv4.ping_group_range="0 2147483647" ``` To make this setting permanent, you have to edit your `/etc/sysctl.conf` and add the line `net.ipv4.ping_group_range=0 2147483647`. -## maxon EPSO4 connection failure -> [!Note] -> This problem may only be temporary as it will be corrected by this [issue](https://github.com/JMUWRobotics/volksbot/issues/7). - -If the maxon epos4 motor controller gets recognized under the correct `/dev/` device directive but you get any of the errors: -> `0x10000003`, `0x10000005`, `0x10000007`, `0x10000008` - -you may need to set the correct USB port in the [rovers.yaml](). -Usually it is: `USB0`, `USB1`, `USB2`, `USB3` or `USB4` --- # Bugs or Issues?