ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

This is set in the VisualizationFrame::initConfigs()

void VisualizationFrame::initConfigs()
 {
   home_dir_ = QDir::toNativeSeparators(QDir::homePath()).toStdString();

   config_dir_ = (fs::path(home_dir_) / ".rviz").string();
   persistent_settings_file_ = (fs::path(config_dir_) / "persistent_settings").string();
   default_display_config_file_ = (fs::path(config_dir_) / "default." CONFIG_EXTENSION).string();
   ...

With the config_dir in this cas ending up as ".rviz" because home_dir is null. home_dir is derived from QDir::homePath() documented here: https://doc.qt.io/qt-5/qdir.html#homePath

This includes the helpful statement:

Under non-Windows operating systems the HOME environment variable is used if it exists, otherwise the path returned by the rootPath().

Which is the answer sought. Without HOME being set QDir::rootPath() will return "/".

Adding environment

Environment="HOME=/home/<my_username>/catkin_ws/"

This is set in the VisualizationFrame::initConfigs()

void VisualizationFrame::initConfigs()
 {
   home_dir_ = QDir::toNativeSeparators(QDir::homePath()).toStdString();

   config_dir_ = (fs::path(home_dir_) / ".rviz").string();
   persistent_settings_file_ = (fs::path(config_dir_) / "persistent_settings").string();
   default_display_config_file_ = (fs::path(config_dir_) / "default." CONFIG_EXTENSION).string();
   ...

With the config_dir in this cas ending up as ".rviz" because home_dir is null. home_dir is derived from QDir::homePath() documented here: https://doc.qt.io/qt-5/qdir.html#homePath

This includes the helpful statement:

Under non-Windows operating systems the HOME environment variable is used if it exists, otherwise the path returned by the rootPath().

Which is the answer sought. Without HOME being set QDir::rootPath() will return "/"."/". This environment variable is set after the service is started.

Adding Added environment

Environment="HOME=/home/<my_username>"

Environment="HOME=/home/<my_username>/catkin_ws/"to system.d service file

Fixed