Skip to content

Commit

Permalink
Playback Scrubber (gazebosim#299)
Browse files Browse the repository at this point in the history
Signed-off-by: John Shepherd <[email protected]>
Signed-off-by: Louise Poubel <[email protected]>

Co-authored-by: Louise Poubel <[email protected]>
Signed-off-by: Guillaume Doisy <[email protected]>
  • Loading branch information
2 people authored and Guillaume Doisy committed Dec 13, 2020
1 parent 22ecd09 commit c1f3f40
Show file tree
Hide file tree
Showing 15 changed files with 767 additions and 11 deletions.
48 changes: 48 additions & 0 deletions include/ignition/gazebo/components/LogPlaybackStatistics.hh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright (C) 2020 Open Source Robotics Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef IGNITION_GAZEBO_COMPONENTS_LogPlaybackStatistics_HH_
#define IGNITION_GAZEBO_COMPONENTS_LogPlaybackStatistics_HH_

#include <ignition/msgs/log_playback_stats.pb.h>
#include <ignition/gazebo/components/Factory.hh>
#include <ignition/gazebo/components/Component.hh>
#include <ignition/gazebo/components/Serialization.hh>
#include <ignition/gazebo/config.hh>
#include <ignition/gazebo/Conversions.hh>

namespace ignition
{
namespace gazebo
{
// Inline bracket to help doxygen filtering.
inline namespace IGNITION_GAZEBO_VERSION_NAMESPACE {
namespace components
{
/// \brief A component type that contains log playback,
/// systems::LogPlayback, information.
/// The log playback is created from world entity upon the playback plugin
/// being loaded
using LogPlaybackStatistics = Component<ignition::msgs::LogPlaybackStatistics,
class LogPlaybackStatisticsTag, serializers::MsgSerializer>;
IGN_GAZEBO_REGISTER_COMPONENT("ign_gazebo_components.LogPlaybackStatistics",
LogPlaybackStatistics)
}
}
}
}

#endif
7 changes: 7 additions & 0 deletions src/cmd/cmdgazebo.rb.in
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,13 @@ class Cmd
# Import the runGui function
Importer.extern 'int runGui(const char *)'

# If playback is specified, and the user has not specified a
# custom gui config, set the gui config to load the playback
# gui config
if (options['playback'] != '' and options['gui_config'] == '')
options['gui_config'] = "_playback_"
end

# Neither the -s nor -g options were used, so run both the server
# and gui.
if options['server'] == 0 && options['gui'] == 0
Expand Down
1 change: 1 addition & 0 deletions src/gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ set(CMAKE_AUTORCC OFF)

install(TARGETS ${gui_target} DESTINATION ${IGN_LIB_INSTALL_DIR})
install (FILES gui.config DESTINATION ${IGN_DATA_INSTALL_DIR}/gui)
install (FILES playback_gui.config DESTINATION ${IGN_DATA_INSTALL_DIR}/gui)

# Tests
set (gtest_sources
Expand Down
27 changes: 18 additions & 9 deletions src/gui/Gui.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,21 @@ std::unique_ptr<ignition::gui::Application> createGui(

// add import path so we can load custom modules
app->Engine()->addImportPath(IGN_GAZEBO_GUI_PLUGIN_INSTALL_DIR);
std::string defaultGuiConfigName = "gui.config";

// Set default config file for Gazebo
std::string defaultConfig;
if (nullptr == _defaultGuiConfig)
{
// The playback flag (and not the gui-config flag) was
// specified from the command line
if (nullptr != _guiConfig && std::string(_guiConfig) == "_playback_")
{
defaultGuiConfigName = "playback_gui.config";
}
ignition::common::env(IGN_HOMEDIR, defaultConfig);
defaultConfig = ignition::common::joinPaths(defaultConfig, ".ignition",
"gazebo", "gui.config");
"gazebo", defaultGuiConfigName);
}
else
{
Expand Down Expand Up @@ -150,14 +157,9 @@ std::unique_ptr<ignition::gui::Application> createGui(
std::size_t runnerCount = 0;

// Configuration file from command line
if (_guiConfig != nullptr && std::strlen(_guiConfig) > 0)
if (_guiConfig != nullptr && std::strlen(_guiConfig) > 0 &&
std::string(_guiConfig) != "_playback_")
{
if (!app->LoadConfig(_guiConfig))
{
ignwarn << "Failed to load config file[" << _guiConfig << "]."
<< std::endl;
}

// Use the first world name with the config file
// TODO(anyone) Most of ign-gazebo's transport API includes the world name,
// which makes it complicated to mix configurations across worlds.
Expand All @@ -167,6 +169,13 @@ std::unique_ptr<ignition::gui::Application> createGui(
&ignition::gazebo::GuiRunner::OnPluginAdded);
++runnerCount;
runner->setParent(ignition::gui::App());

// Load plugins after runner is up
if (!app->LoadConfig(_guiConfig))
{
ignwarn << "Failed to load config file[" << _guiConfig << "]."
<< std::endl;
}
}
// GUI configuration from SDF (request to server)
else
Expand Down Expand Up @@ -236,7 +245,7 @@ std::unique_ptr<ignition::gui::Application> createGui(
if (!ignition::common::exists(defaultConfig))
{
auto installedConfig = ignition::common::joinPaths(
IGNITION_GAZEBO_GUI_CONFIG_PATH, "gui.config");
IGNITION_GAZEBO_GUI_CONFIG_PATH, defaultGuiConfigName);
if (!ignition::common::copyFile(installedConfig, defaultConfig))
{
ignerr << "Failed to copy installed config [" << installedConfig
Expand Down
97 changes: 97 additions & 0 deletions src/gui/playback_gui.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
<?xml version="1.0"?>

<!-- Window -->
<window>
<width>1000</width>
<height>845</height>
<style
material_theme="Light"
material_primary="DeepOrange"
material_accent="LightBlue"
toolbar_color_light="#f3f3f3"
toolbar_text_color_light="#111111"
toolbar_color_dark="#414141"
toolbar_text_color_dark="#f3f3f3"
plugin_toolbar_color_light="#bbdefb"
plugin_toolbar_text_color_light="#111111"
plugin_toolbar_color_dark="#607d8b"
plugin_toolbar_text_color_dark="#eeeeee"
/>
<menus>
<drawer default="false">
</drawer>
</menus>
</window>

<!-- GUI plugins -->

<!-- 3D scene -->
<plugin filename="GzScene3D" name="3D View">
<ignition-gui>
<title>3D View</title>
<property type="bool" key="showTitleBar">false</property>
<property type="string" key="state">docked</property>
</ignition-gui>

<engine>ogre2</engine>
<scene>scene</scene>
<ambient_light>0.4 0.4 0.4</ambient_light>
<background_color>0.8 0.8 0.8</background_color>
<camera_pose>6 0 6 0 0.5 3.14</camera_pose>
</plugin>

<!-- Play / pause / step -->
<plugin filename="WorldControl" name="World control">
<ignition-gui>
<title>World control</title>
<property type="bool" key="showTitleBar">false</property>
<property type="bool" key="resizable">false</property>
<property type="double" key="height">72</property>
<property type="double" key="width">121</property>
<property type="double" key="z">1</property>

<property type="string" key="state">floating</property>
<anchors target="3D View">
<line own="left" target="left"/>
<line own="bottom" target="bottom"/>
</anchors>
</ignition-gui>

<play_pause>true</play_pause>
<step>true</step>
<start_paused>true</start_paused>

</plugin>

<!-- Playback Scrubber -->
<plugin filename="PlaybackScrubber" name="PlaybackScrubber">
<ignition-gui>
<property type="bool" key="showTitleBar">false</property>
<property type="double" key="height">90</property>
<property type="double" key="width">350</property>
<property type="double" key="z">1</property>
<property key="cardBackground" type="string">#66666666</property>

<property type="string" key="state">floating</property>
<anchors target="3D View">
<line own="horizontalCenter" target="horizontalCenter"/>
<line own="bottom" target="bottom"/>
</anchors>
</ignition-gui>
</plugin>

<!-- Inspector -->
<plugin filename="ComponentInspector" name="Component inspector">
<ignition-gui>
<property type="bool" key="showTitleBar">false</property>
<property type="string" key="state">docked</property>
</ignition-gui>
</plugin>

<!-- Entity tree -->
<plugin filename="EntityTree" name="Entity tree">
<ignition-gui>
<property type="bool" key="showTitleBar">false</property>
<property type="string" key="state">docked</property>
</ignition-gui>
</plugin>
1 change: 1 addition & 0 deletions src/gui/plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ add_subdirectory(align_tool)
add_subdirectory(component_inspector)
add_subdirectory(entity_tree)
add_subdirectory(grid_config)
add_subdirectory(playback_scrubber)
add_subdirectory(resource_spawner)
add_subdirectory(scene3d)
add_subdirectory(shapes)
Expand Down
4 changes: 4 additions & 0 deletions src/gui/plugins/playback_scrubber/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
gz_add_gui_plugin(PlaybackScrubber
SOURCES PlaybackScrubber.cc
QT_HEADERS PlaybackScrubber.hh
)
Loading

0 comments on commit c1f3f40

Please sign in to comment.