0
$\begingroup$

Rosanswers logo

When I use rtabmap_ros, I need to specify the database save path.The feasible method is to use the following method to assign values in rtabmap node:

param name = "database_path" type = "string" value = "~ / .ros / rtabmap.db"

But I want to add the current time to the generated database file name.For example, when I execute date + '~ / rtabmap_databases / rtabmap_% Y-% m-% d-% Ih-% Mm-% Ss.db' in bash, the screen prints ~ / rtabmap_databases / rtabmap_2020-01-10 -10h-02m-04s.db. I want to pass this string to the database_path parameter of rtabmap node. Therefore, I use the following methods for parameter assignment:

param name="database_path" command="date +'~/rtabmap_databases/rtabmap_%Y-%m-%d-%Ih-%Mm-%Ss.db'"

but the following error occurs:

[FATAL] (2020-01-10 10:12:27.004) Rtabmap.cpp:298::init() Condition (UFile::getExtension(_databasePath).compare("db") == 0) not met!


Originally posted by willzoe on ROS Answers with karma: 29 on 2020-01-09

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

I think the problem is that the resulting string from the command date + '~ / rtabmap_databases / rtabmap_% Y-% m-% d-% Ih-% Mm-% Ss.db' has a trailing newline character, thus the check on the last characters of the string (representing the file extension) fails.

Try to replace the command with the following:

<param name="database_path" command="bash -c &quot;date +'~/rtabmap_databases/rtabmap_%Y-%m-%d-%Ih-%Mm-%Ss.db' | tr -d '\n'&quot;"/>

It worked fine on my laptop using ROS melodic.


Originally posted by d.fenucci with karma: 114 on 2020-01-10

This answer was ACCEPTED on the original site

Post score: 1

$\endgroup$

Your Answer

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