Skip to content

Commit

Permalink
enable rviz -d my_config as shortcut to ~/.rviz/my_config.rviz
Browse files Browse the repository at this point in the history
  • Loading branch information
v4hn authored and trixi committed Sep 6, 2019
1 parent b1b5a96 commit ad0aa64
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions src/rviz/visualization_frame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -721,16 +721,38 @@ void VisualizationFrame::loadDisplayConfig( const QString& qpath )
{
std::string path = qpath.toStdString();
std::string actual_load_path = path;
if( !fs::exists( path ) || fs::is_directory( path ) || fs::is_empty( path ))
bool valid_load_path = false;

if( fs::is_regular_file( actual_load_path ) || fs::is_symlink( actual_load_path ) )
{
valid_load_path = true;
}

if( !valid_load_path && fs::portable_posix_name( path ) )
{
actual_load_path = (fs::path(config_dir_) / (path+".rviz") ).BOOST_FILE_STRING();
if( fs::is_regular_file( actual_load_path ) || fs::is_symlink( actual_load_path ) )
{
valid_load_path = true;
}
}

if( !valid_load_path )
{
actual_load_path = (fs::path(package_path_) / "default.rviz").BOOST_FILE_STRING();
if( !fs::exists( actual_load_path ))
if( !fs::is_regular_file( actual_load_path ) && !fs::is_symlink( actual_load_path ) )
{
ROS_ERROR( "Default display config '%s' not found. RViz will be very empty at first.", actual_load_path.c_str() );
return;
}
else
{
valid_load_path = true;
}
}

assert( valid_load_path );

// Check if we have unsaved changes to the current config the same
// as we do during exit, with the same option to cancel.
if( !prepareToExit() )
Expand Down

0 comments on commit ad0aa64

Please sign in to comment.