0
$\begingroup$

I have a different process in my CPP node that writes a separate log file.

Right now, this log is written to a file in ros2_ws/log/additional_process.log but I would like to put that file in the specific ROS log folder of that run, e.g. ros2_ws/log/build_2023-10-09_8-51-26/additional_process.log.

Does anyone know how to get the specific run/build directory in CPP for every run/launch?

$\endgroup$

1 Answer 1

0
$\begingroup$

I interpret your question as follows:

  • You know how to specify a custom log folder,
  • You have folders build, install and log from running colcon build in your ros2_ws workspace,
  • You currently specify ros2_ws/log/ as log folder,
  • However, you would like to log to the the latest build directory for your workspace instead (e.g. ros2_ws/log/build_2023-10-09_8-51-26/).

If this is correct, then the answer is to simply specify ros2_ws/log/latest or ros2_ws/log/latest_build as log directory, as these latest and latest_build are symbolic links to the latest build directory.

I'm not sure though what you mean with "get the specific run/build directory in CPP". In any case: you can retrieve the log folder through rcl_logging_get_logging_directory() or rclcpp::get_logging_directory().

$\endgroup$
1
  • $\begingroup$ Thank you! Adding something to the ros2_ws/log/latest solved the problem! The rclcpp::get_loggin_directory() returned ~/.ros/log/ which I did not intend to use. $\endgroup$
    – moschmdt
    Oct 9, 2023 at 13:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.