From 32bd43b369f801a000c94d72ff286cbbda48863e Mon Sep 17 00:00:00 2001 From: Jenn Nguyen Date: Fri, 16 Sep 2022 16:01:22 -0700 Subject: [PATCH] updates for gazebo garden Signed-off-by: Jenn Nguyen --- CMakeLists.txt | 22 +- README.md | 27 ++- common/Common.cc | 11 +- common/Keyframe.cc | 15 +- common/include/simslides/common/Common.hh | 8 +- common/include/simslides/common/Keyframe.hh | 6 +- gazebo/CMakeLists.txt | 52 +++++ .../SimSlidesIgn.cc => gazebo/SimSlidesGz.cc | 120 +++++----- .../SimSlidesIgn.hh => gazebo/SimSlidesGz.hh | 37 +-- .../SimSlidesGz.qml | 4 +- .../SimSlidesGz.qmlc | Bin gazebo/SimSlidesGz.qrc | 5 + .../simslides_gazebo.sh.in | 4 +- ignition/CMakeLists.txt | 53 ----- ignition/SimSlidesIgn.qrc | 5 - ...ides_Ignition.gif => SimSlides_Gazebo.gif} | Bin setup.sh.in | 8 +- worlds/simslides_gazebo.sdf | 218 ++++++++++++++++++ worlds/simslides_ignition.sdf | 131 ----------- 19 files changed, 406 insertions(+), 320 deletions(-) create mode 100644 gazebo/CMakeLists.txt rename ignition/SimSlidesIgn.cc => gazebo/SimSlidesGz.cc (63%) rename ignition/SimSlidesIgn.hh => gazebo/SimSlidesGz.hh (76%) rename ignition/SimSlidesIgn.qml => gazebo/SimSlidesGz.qml (93%) rename ignition/SimSlidesIgn.qmlc => gazebo/SimSlidesGz.qmlc (100%) create mode 100644 gazebo/SimSlidesGz.qrc rename ignition/simslides_ignition.sh.in => gazebo/simslides_gazebo.sh.in (78%) delete mode 100644 ignition/CMakeLists.txt delete mode 100644 ignition/SimSlidesIgn.qrc rename images/{SimSlides_Ignition.gif => SimSlides_Gazebo.gif} (100%) create mode 100644 worlds/simslides_gazebo.sdf delete mode 100644 worlds/simslides_ignition.sdf diff --git a/CMakeLists.txt b/CMakeLists.txt index 3d125ee..ae1f7b1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,23 +2,23 @@ cmake_minimum_required(VERSION 3.5.1 FATAL_ERROR) project(simslides) -find_package(ignition-common4 REQUIRED) -set(IGN_COMMON_VER ${ignition-common4_VERSION_MAJOR}) +find_package(gz-common5 REQUIRED) +set(GZ_COMMON_VER ${gz-common5_VERSION_MAJOR}) -find_package(ignition-gazebo6 REQUIRED COMPONENTS gui) -set(IGN_GAZEBO_VER ${ignition-gazebo6_VERSION_MAJOR}) +find_package(gz-sim7 REQUIRED COMPONENTS gui) +set(GZ_SIM_VER ${gz-sim7_VERSION_MAJOR}) -find_package(ignition-rendering6 REQUIRED) -set(IGN_RENDERING_VER ${ignition-rendering6_VERSION_MAJOR}) +find_package(gz-rendering7 REQUIRED) +set(GZ_RENDERING_VER ${gz-rendering7_VERSION_MAJOR}) -find_package(ignition-gui6 REQUIRED) -set(IGN_GUI_VER ${ignition-gui6_VERSION_MAJOR}) +find_package(gz-gui7 REQUIRED) +set(GZ_GUI_VER ${gz-gui7_VERSION_MAJOR}) -find_package(sdformat12 REQUIRED) -set(SDF_VER ${sdformat12_VERSION_MAJOR}) +find_package(sdformat13 REQUIRED) +set(SDF_VER ${sdformat13_VERSION_MAJOR}) add_subdirectory(common) -add_subdirectory(ignition) +add_subdirectory(gazebo) install(DIRECTORY models diff --git a/README.md b/README.md index 1dea4f4..fbc1d71 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -## This branch only works with Ignition Fortress. For Gazebo 11 and Ignition Citadel, see the `main` branch. +## This branch only works with Gazebo Garden. For Gazebo 11 and Gazebo Citadel, see the `main` branch. --- @@ -11,20 +11,20 @@ Import PDF files into robot simulation and present flying from slide to slide. ## Features SimSlides consists of plugins for two simulators: -[Gazebo Classic](http://gazebosim.org/) and -[Ignition Gazebo](https://ignitionrobotics.org/). There are different features for +[Gazebo Classic](http://classic.gazebosim.org/) and +[Gazebo](https://gazebosim.org/). There are different features for each simulator. -### Ignition +### Gazebo -![SimSlides Ignition](images/SimSlides_Ignition.gif) +![SimSlides Gazebo](images/SimSlides_Gazebo.gif) * Navigate through keyframes using **mouse**, **keyboard** or wireless **presenter** * Keyframes can: * Look at a **slide** (even if it has moved) * **Move camera** to a specific pose * Go through slides **stacked** on the same pose -* ... plus all **Ignition** features! +* ... plus all **Gazebo** features! ### Gazebo classic @@ -49,15 +49,15 @@ want to setup keyboard triggers? Control a robot using ## Install -SimSlides' main branch supports both Gazebo Classic and Ignition. It's ok if +SimSlides' `main` branch supports both Gazebo Classic and Gazebo. It's ok if you don't have both simulators installed, only the plugin for the simulator present will be compiled. -### Ignition +### Gazebo -The main branch has been tested on Ignition Fortress. +The `garden` branch has been tested on Gazebo Garden. -Follow the official install [instructions](https://ignitionrobotics.org/docs/fortress/install). +Follow the official install [instructions](https://gazebosim.org/docs/garden/install). ### Gazebo Classic (doesn't work on this branch) @@ -72,11 +72,11 @@ Follow the official install [instructions](https://ignitionrobotics.org/docs/for ## Run SimSlides -### Ignition +### Gazebo Run simslides: - simslides_ignition + simslides_gazebo ### Gazebo Classic (doesn't work on this branch) @@ -93,7 +93,7 @@ Run it as follows: 1. Load the world - simslides_ignition worlds/demo_slide.sdf + simslides_gazebo worlds/demo_slide.sdf ## Your own presentation @@ -191,4 +191,3 @@ gaining more features for each presentation. The repository was ported to GitHub + Git in August 2019, when BitBucket dropped Mercurial support. - diff --git a/common/Common.cc b/common/Common.cc index cc20cd1..a78d324 100644 --- a/common/Common.cc +++ b/common/Common.cc @@ -15,6 +15,7 @@ */ #include +#include #include "include/simslides/common/Common.hh" @@ -136,23 +137,23 @@ void simslides::Common::Update() // Target in world frame auto origin = this->Common::Instance()->VisualPose(keyframe->Visual()); - auto bbPos = origin.Pos() + ignition::math::Vector3d(0, 0, 0.5); - auto targetWorld = ignition::math::Matrix4d(ignition::math::Pose3d( + auto bbPos = origin.Pos() + gz::math::Vector3d(0, 0, 0.5); + auto targetWorld = gz::math::Matrix4d(gz::math::Pose3d( bbPos, origin.Rot())); // Eye in target frame auto offset = keyframe->EyeOffset(); - if (offset == ignition::math::Pose3d::Zero) + if (offset == gz::math::Pose3d::Zero) { offset = this->kEyeOffset; } - ignition::math::Matrix4d eyeTarget(offset); + gz::math::Matrix4d eyeTarget(offset); // Eye in world frame auto eyeWorld = targetWorld * eyeTarget; // Look At - auto mat = ignition::math::Matrix4d::LookAt(eyeWorld.Translation(), + auto mat = gz::math::Matrix4d::LookAt(eyeWorld.Translation(), targetWorld.Translation()); this->MoveCamera(mat.Pose()); diff --git a/common/Keyframe.cc b/common/Keyframe.cc index 5d14e23..bcbe2fe 100644 --- a/common/Keyframe.cc +++ b/common/Keyframe.cc @@ -42,10 +42,10 @@ class simslides::KeyframePrivate public: std::string visual; /// \brief Camera offset in LOOKAT slide frame - public: ignition::math::Pose3d eyeOffset; + public: gz::math::Pose3d eyeOffset; /// \brief Camera pose in world frame - public: ignition::math::Pose3d camPose; + public: gz::math::Pose3d camPose; /// \brief Log time to seek to public: std::chrono::steady_clock::duration logSeek; @@ -65,7 +65,7 @@ Keyframe::Keyframe(sdf::ElementPtr _sdf) : dataPtr(new KeyframePrivate) if (_sdf->HasAttribute("eye_offset")) { - this->dataPtr->eyeOffset = _sdf->Get("eye_offset"); + this->dataPtr->eyeOffset = _sdf->Get("eye_offset"); } if (_sdf->HasAttribute("text")) { @@ -91,14 +91,14 @@ Keyframe::Keyframe(sdf::ElementPtr _sdf) : dataPtr(new KeyframePrivate) } else if (type == "log_seek") { - this->dataPtr->camPose = _sdf->Get("cam_pose"); + this->dataPtr->camPose = _sdf->Get("cam_pose"); auto logSeek = _sdf->Get("time"); this->dataPtr->logSeek = std::chrono::seconds(logSeek.sec) + std::chrono::nanoseconds(logSeek.nsec); } else if (type == "cam_pose") { - this->dataPtr->camPose = _sdf->Get("pose"); + this->dataPtr->camPose = _sdf->Get("pose"); } else { @@ -132,13 +132,13 @@ std::string Keyframe::Visual() const } ////////////////////////////////////////////////// -ignition::math::Pose3d Keyframe::CamPose() const +gz::math::Pose3d Keyframe::CamPose() const { return this->dataPtr->camPose; } ////////////////////////////////////////////////// -ignition::math::Pose3d Keyframe::EyeOffset() const +gz::math::Pose3d Keyframe::EyeOffset() const { return this->dataPtr->eyeOffset; } @@ -202,4 +202,3 @@ KeyframeType KeyframePrivate::StrToType(const std::string &_type) const return KeyframeType::NONE; } - diff --git a/common/include/simslides/common/Common.hh b/common/include/simslides/common/Common.hh index 3b490ec..7c523ea 100644 --- a/common/include/simslides/common/Common.hh +++ b/common/include/simslides/common/Common.hh @@ -55,7 +55,7 @@ namespace simslides public: void ChangeKeyframe(int _keyframe); /// \brief Function called to move camera, containing the target pose. - public: std::function MoveCamera; + public: std::function MoveCamera; /// \brief Function called to move camera, containing the target pose. public: std::function SetVisualVisible; @@ -68,7 +68,7 @@ namespace simslides /// \brief Function called to get a visual's pose according to its scoped /// name. - public: std::function + public: std::function VisualPose; /// \brief Function called to set text, containing the the text. @@ -95,8 +95,8 @@ namespace simslides /// -1 means not presenting. public: int slideCount{-1}; - public: const ignition::math::Pose3d kEyeOffset - {0.0, -3.0, 0.0, 0.0, 0.0, IGN_PI_2}; + public: const gz::math::Pose3d kEyeOffset + {0.0, -3.0, 0.0, 0.0, 0.0, GZ_PI_2}; /// \brief Static instance private: static Common *instance; diff --git a/common/include/simslides/common/Keyframe.hh b/common/include/simslides/common/Keyframe.hh index 1ec31fa..2a6fa50 100644 --- a/common/include/simslides/common/Keyframe.hh +++ b/common/include/simslides/common/Keyframe.hh @@ -20,7 +20,7 @@ #include #include #include -#include +#include namespace simslides { @@ -69,11 +69,11 @@ namespace simslides /// \brief For LOG_SEEK and CAM_POSE /// \return Camera pose in the world - public: ignition::math::Pose3d CamPose() const; + public: gz::math::Pose3d CamPose() const; /// \brief For LOOKAT /// \return Offset from target slide origin. - public: ignition::math::Pose3d EyeOffset() const; + public: gz::math::Pose3d EyeOffset() const; /// \brief Log time to seek to /// \return Log time diff --git a/gazebo/CMakeLists.txt b/gazebo/CMakeLists.txt new file mode 100644 index 0000000..76b4aac --- /dev/null +++ b/gazebo/CMakeLists.txt @@ -0,0 +1,52 @@ +set(library_name SimSlidesGz) + +set(client_src + ${library_name}.cc +) + +set (qt_headers + ${library_name}.hh +) + +find_package(Qt5 + COMPONENTS + Core + Quick + QuickControls2 + REQUIRED +) + +set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GZ-GUI_CXX_FLAGS} -std=c++17 -lstdc++fs") + +QT5_ADD_RESOURCES(resources_RCC ${library_name}.qrc) +QT5_WRAP_CPP(headers_MOC ${qt_headers}) + +add_library(${library_name} SHARED + ${client_src} + ${headers_MOC} + ${resources_RCC} +) + +target_link_libraries(${library_name} + stdc++fs + SimSlidesCommon + gz-common${GZ_COMMON_VER}::gz-common${GZ_COMMON_VER} + gz-sim${GZ_SIM_VER}::gz-sim${GZ_SIM_VER} + gz-gui${GZ_GUI_VER}::gz-gui${GZ_GUI_VER} + gz-rendering${GZ_RENDERING_VER}::gz-rendering${GZ_RENDERING_VER} +) + +include(GNUInstallDirs) +install(TARGETS ${library_name} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}/gz-gui/ +) + +configure_file( + "simslides_gazebo.sh.in" + "${CMAKE_CURRENT_BINARY_DIR}/share/simslides_gazebo" @ONLY +) + +install(PROGRAMS + ${CMAKE_CURRENT_BINARY_DIR}/share/simslides_gazebo + DESTINATION bin +) diff --git a/ignition/SimSlidesIgn.cc b/gazebo/SimSlidesGz.cc similarity index 63% rename from ignition/SimSlidesIgn.cc rename to gazebo/SimSlidesGz.cc index 5c8547e..349380c 100644 --- a/ignition/SimSlidesIgn.cc +++ b/gazebo/SimSlidesGz.cc @@ -18,38 +18,38 @@ #include #include -#include -#include +#include +#include #include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include -#include "SimSlidesIgn.hh" +#include "SimSlidesGz.hh" using namespace simslides; ///////////////////////////////////////////////// -SimSlidesIgn::SimSlidesIgn() +SimSlidesGz::SimSlidesGz() : Plugin() { } ///////////////////////////////////////////////// -SimSlidesIgn::~SimSlidesIgn() +SimSlidesGz::~SimSlidesGz() { } ///////////////////////////////////////////////// -void SimSlidesIgn::LoadConfig(const tinyxml2::XMLElement *_pluginXml) +void SimSlidesGz::LoadConfig(const tinyxml2::XMLElement *_pluginXml) { if (this->title.empty()) this->title = "SimSlides"; @@ -71,41 +71,41 @@ void SimSlidesIgn::LoadConfig(const tinyxml2::XMLElement *_pluginXml) auto pluginElem = sdfParsed->Root()->GetElement("plugin"); if (nullptr == pluginElem) { - ignerr << "Error getting plugin element from:" << std::endl << stream.str() + gzerr << "Error getting plugin element from:" << std::endl << stream.str() << std::endl; return; } Common::Instance()->LoadPluginSDF(pluginElem); - this->node.Subscribe("/keyboard/keypress", &SimSlidesIgn::OnKeyPress, this); + this->node.Subscribe("/keyboard/keypress", &SimSlidesGz::OnKeyPress, this); // this->logPlaybackControlPub = this->node-> // Advertise("~/playback_control"); - ignition::gui::App()->findChild + gz::gui::App()->findChild ()->installEventFilter(this); simslides::Common::Instance()->MoveCamera = - std::bind(&SimSlidesIgn::OnMoveCamera, this, std::placeholders::_1); + std::bind(&SimSlidesGz::OnMoveCamera, this, std::placeholders::_1); simslides::Common::Instance()->SetVisualVisible = - std::bind(&SimSlidesIgn::OnSetVisualVisible, this, std::placeholders::_1, + std::bind(&SimSlidesGz::OnSetVisualVisible, this, std::placeholders::_1, std::placeholders::_2); simslides::Common::Instance()->SeekLog = - std::bind(&SimSlidesIgn::OnSeekLog, this, std::placeholders::_1); + std::bind(&SimSlidesGz::OnSeekLog, this, std::placeholders::_1); simslides::Common::Instance()->ResetCameraPose = - std::bind(&SimSlidesIgn::OnResetCameraPose, this); + std::bind(&SimSlidesGz::OnResetCameraPose, this); simslides::Common::Instance()->VisualPose = - std::bind(&SimSlidesIgn::OnVisualPose, this, std::placeholders::_1); + std::bind(&SimSlidesGz::OnVisualPose, this, std::placeholders::_1); simslides::Common::Instance()->SetText = - std::bind(&SimSlidesIgn::OnSetText, this, std::placeholders::_1); + std::bind(&SimSlidesGz::OnSetText, this, std::placeholders::_1); - ignmsg << "Start presentation. Total of [" << Common::Instance()->keyframes.size() + gzmsg << "Start presentation. Total of [" << Common::Instance()->keyframes.size() << "] keyframes" << std::endl; // Trigger first slide @@ -114,9 +114,9 @@ void SimSlidesIgn::LoadConfig(const tinyxml2::XMLElement *_pluginXml) } ///////////////////////////////////////////////// -bool SimSlidesIgn::eventFilter(QObject *_obj, QEvent *_event) +bool SimSlidesGz::eventFilter(QObject *_obj, QEvent *_event) { - if (_event->type() == ignition::gui::events::Render::kType) + if (_event->type() == gz::gui::events::Render::kType) { this->LoadScene(); this->ProcessCommands(); @@ -125,18 +125,18 @@ bool SimSlidesIgn::eventFilter(QObject *_obj, QEvent *_event) } ///////////////////////////////////////////////// -void SimSlidesIgn::LoadScene() +void SimSlidesGz::LoadScene() { if (nullptr != this->scene) return; - this->scene = ignition::rendering::sceneFromFirstRenderEngine(); + this->scene = gz::rendering::sceneFromFirstRenderEngine(); if (nullptr == this->scene) return; for (int i = 0; i < this->scene->NodeCount(); ++i) { - auto cam = std::dynamic_pointer_cast( + auto cam = std::dynamic_pointer_cast( this->scene->NodeByIndex(i)); if (nullptr != cam) { @@ -149,9 +149,9 @@ void SimSlidesIgn::LoadScene() } // Match Gazebo Classic's user camera FOV so the "zoom" looks the same - camera->SetHFOV(IGN_DTOR(60)); + camera->SetHFOV(GZ_DTOR(60)); - igndbg << "SimSlides attached to camera [" + gzdbg << "SimSlides attached to camera [" << this->camera->Name() << "]" << std::endl; break; } @@ -159,26 +159,26 @@ void SimSlidesIgn::LoadScene() if (!this->camera) { - ignerr << "Camera is not available" << std::endl; + gzerr << "Camera is not available" << std::endl; } } ///////////////////////////////////////////////// -void SimSlidesIgn::OnKeyframeChanged(int _keyframe) +void SimSlidesGz::OnKeyframeChanged(int _keyframe) { Common::Instance()->ChangeKeyframe(_keyframe); this->pendingCommand = true; } ///////////////////////////////////////////////// -void SimSlidesIgn::ProcessCommands() +void SimSlidesGz::ProcessCommands() { if (!this->pendingCommand) return; this->pendingCommand = false; - ignmsg << "Changing to slide [" << Common::Instance()->currentKeyframe << "]" + gzmsg << "Changing to slide [" << Common::Instance()->currentKeyframe << "]" << std::endl; simslides::Common::Instance()->Update(); @@ -187,18 +187,18 @@ void SimSlidesIgn::ProcessCommands() } ///////////////////////////////////////////////// -void SimSlidesIgn::OnKeyPress(const ignition::msgs::Int32 &_msg) +void SimSlidesGz::OnKeyPress(const gz::msgs::Int32 &_msg) { Common::Instance()->HandleKeyPress(_msg.data()); this->pendingCommand = true; } ///////////////////////////////////////////////// -void SimSlidesIgn::OnMoveCamera(const ignition::math::Pose3d &_pose) +void SimSlidesGz::OnMoveCamera(const gz::math::Pose3d &_pose) { if (nullptr == this->camera) { - ignerr << "No camera, failed to move camera." << std::endl; + gzerr << "No camera, failed to move camera." << std::endl; return; } @@ -206,19 +206,19 @@ void SimSlidesIgn::OnMoveCamera(const ignition::math::Pose3d &_pose) if ((this->camera->WorldPose().Pos() - _pose.Pos()).Length() < 0.001) return; - ignition::msgs::GUICamera req; - ignition::msgs::Set(req.mutable_pose(), _pose); + gz::msgs::GUICamera req; + gz::msgs::Set(req.mutable_pose(), _pose); - std::function cb = - [](const ignition::msgs::Boolean &_res, const bool _result) + std::function cb = + [](const gz::msgs::Boolean &_res, const bool _result) { if (!_result) { - ignerr << "Timed out requesting to move camera" << std::endl; + gzerr << "Timed out requesting to move camera" << std::endl; } if (!_res.data()) { - ignerr << "Failed to move camera" << std::endl; + gzerr << "Failed to move camera" << std::endl; } }; @@ -226,11 +226,11 @@ void SimSlidesIgn::OnMoveCamera(const ignition::math::Pose3d &_pose) } ///////////////////////////////////////////////// -void SimSlidesIgn::OnSetVisualVisible(const std::string &_name, bool _visible) +void SimSlidesGz::OnSetVisualVisible(const std::string &_name, bool _visible) { if (nullptr == this->camera) { - ignerr << "No scene, failed to set visual visibility." << std::endl; + gzerr << "No scene, failed to set visual visibility." << std::endl; return; } @@ -238,7 +238,7 @@ void SimSlidesIgn::OnSetVisualVisible(const std::string &_name, bool _visible) if (!vis) { - ignerr << "Couldn't find visual [" << _name << "]" << std::endl; + gzerr << "Couldn't find visual [" << _name << "]" << std::endl; return; } @@ -246,7 +246,7 @@ void SimSlidesIgn::OnSetVisualVisible(const std::string &_name, bool _visible) } ///////////////////////////////////////////////// -void SimSlidesIgn::OnSeekLog(std::chrono::steady_clock::duration _time) +void SimSlidesGz::OnSeekLog(std::chrono::steady_clock::duration _time) { std::cout << "Log seek not supported yet" << std::endl; // if (!this->logPlaybackControlPub) @@ -269,20 +269,20 @@ void SimSlidesIgn::OnSeekLog(std::chrono::steady_clock::duration _time) } ///////////////////////////////////////////////// -void SimSlidesIgn::OnResetCameraPose() +void SimSlidesGz::OnResetCameraPose() { - ignition::msgs::Vector3d req; + gz::msgs::Vector3d req; - std::function cb = - [](const ignition::msgs::Boolean &_res, const bool _result) + std::function cb = + [](const gz::msgs::Boolean &_res, const bool _result) { if (!_result) { - ignerr << "Timed out requesting to reset camera" << std::endl; + gzerr << "Timed out requesting to reset camera" << std::endl; } if (!_res.data()) { - ignerr << "Failed to reset camera" << std::endl; + gzerr << "Failed to reset camera" << std::endl; } }; @@ -290,11 +290,11 @@ void SimSlidesIgn::OnResetCameraPose() } ///////////////////////////////////////////////// -ignition::math::Pose3d SimSlidesIgn::OnVisualPose(const std::string &_name) +gz::math::Pose3d SimSlidesGz::OnVisualPose(const std::string &_name) { if (nullptr == this->camera) { - ignerr << "No camera, failed to get visual pose." << std::endl; + gzerr << "No camera, failed to get visual pose." << std::endl; return { std::numeric_limits::quiet_NaN(), std::numeric_limits::quiet_NaN(), @@ -308,7 +308,7 @@ ignition::math::Pose3d SimSlidesIgn::OnVisualPose(const std::string &_name) auto vis = this->camera->Scene()->VisualByName(_name); if (!vis) { - ignerr << "Failed to find visual [" << _name << "]" << std::endl; + gzerr << "Failed to find visual [" << _name << "]" << std::endl; return { std::numeric_limits::quiet_NaN(), std::numeric_limits::quiet_NaN(), @@ -324,11 +324,11 @@ ignition::math::Pose3d SimSlidesIgn::OnVisualPose(const std::string &_name) } ///////////////////////////////////////////////// -void SimSlidesIgn::OnSetText(const std::string &_name) +void SimSlidesGz::OnSetText(const std::string &_name) { // TODO(louise) Support setting text } // Register this plugin -IGNITION_ADD_PLUGIN(simslides::SimSlidesIgn, - ignition::gui::Plugin); +GZ_ADD_PLUGIN(simslides::SimSlidesGz, + gz::gui::Plugin); diff --git a/ignition/SimSlidesIgn.hh b/gazebo/SimSlidesGz.hh similarity index 76% rename from ignition/SimSlidesIgn.hh rename to gazebo/SimSlidesGz.hh index ec95c06..cc25b16 100644 --- a/ignition/SimSlidesIgn.hh +++ b/gazebo/SimSlidesGz.hh @@ -15,27 +15,28 @@ * */ -#ifndef SIMSLIDES_IGNITION_SIMSLIDESIGN_HH_ -#define SIMSLIDES_IGNITION_SIMSLIDESIGN_HH_ +#ifndef SIMSLIDES_GAZEBO_SIMSLIDESGZ_HH_ +#define SIMSLIDES_GAZEBO_SIMSLIDESGZ_HH_ -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include namespace simslides { -class SimSlidesIgn : public ignition::gui::Plugin +class SimSlidesGz : public gz::gui::Plugin { Q_OBJECT /// \brief Constructor - public: SimSlidesIgn(); + public: SimSlidesGz(); /// \brief Destructor - public: virtual ~SimSlidesIgn(); + public: virtual ~SimSlidesGz(); // Documentation inherited public: void LoadConfig(const tinyxml2::XMLElement *_pluginElem) override; @@ -60,11 +61,11 @@ class SimSlidesIgn : public ignition::gui::Plugin /// \brief Callback when user presses a key. /// \param[in] _msg Message containing key. - private: void OnKeyPress(const ignition::msgs::Int32 &_msg); + private: void OnKeyPress(const gz::msgs::Int32 &_msg); /// \brief Callback to move camera. /// \param[in] _pose Pose to move to. - private: void OnMoveCamera(const ignition::math::Pose3d &_pose); + private: void OnMoveCamera(const gz::math::Pose3d &_pose); /// \brief Callback to show / hide a visual /// \param[in] _name Visual's scoped name @@ -81,7 +82,7 @@ class SimSlidesIgn : public ignition::gui::Plugin /// \brief Callback to get a visual's pose /// \param[in] _name Visual's scoped name /// \return Visual's pose in world frame - private: ignition::math::Pose3d OnVisualPose(const std::string &_name); + private: gz::math::Pose3d OnVisualPose(const std::string &_name); /// \brief Callback to set the text on the dialog. /// \param[in] _text Text to set. @@ -91,16 +92,16 @@ class SimSlidesIgn : public ignition::gui::Plugin private: bool pendingCommand; /// \brief Node used for communication. - private: ignition::transport::Node node; + private: gz::transport::Node node; /// \brief Keep pointer to camera so we can move it. - private: ignition::rendering::CameraPtr camera; + private: gz::rendering::CameraPtr camera; /// \brief Keep pointer to scene so we can get visuals. - private: ignition::rendering::ScenePtr scene; + private: gz::rendering::ScenePtr scene; // /// \brief Used to start, stop, and step simulation. -// private: ignition::transport::Publisher logPlaybackControlPub; +// private: gz::transport::Publisher logPlaybackControlPub; }; } diff --git a/ignition/SimSlidesIgn.qml b/gazebo/SimSlidesGz.qml similarity index 93% rename from ignition/SimSlidesIgn.qml rename to gazebo/SimSlidesGz.qml index 7fd46fd..242ce58 100644 --- a/ignition/SimSlidesIgn.qml +++ b/gazebo/SimSlidesGz.qml @@ -27,7 +27,7 @@ RowLayout { property int lastKeyframe: 10; Connections { - target: SimSlidesIgn + target: SimSlidesGz onUpdateGUI: { keyframeSpin.value = _currentKeyframe; simSlides.lastKeyframe = _keyframeCount; @@ -43,7 +43,7 @@ RowLayout { ToolTip.visible: hovered ToolTip.delay: Qt.styleHints.mousePressAndHoldInterval onValueModified: { - SimSlidesIgn.OnKeyframeChanged(keyframeSpin.value); + SimSlidesGz.OnKeyframeChanged(keyframeSpin.value); } } } diff --git a/ignition/SimSlidesIgn.qmlc b/gazebo/SimSlidesGz.qmlc similarity index 100% rename from ignition/SimSlidesIgn.qmlc rename to gazebo/SimSlidesGz.qmlc diff --git a/gazebo/SimSlidesGz.qrc b/gazebo/SimSlidesGz.qrc new file mode 100644 index 0000000..5b55448 --- /dev/null +++ b/gazebo/SimSlidesGz.qrc @@ -0,0 +1,5 @@ + + + SimSlidesGz.qml + + diff --git a/ignition/simslides_ignition.sh.in b/gazebo/simslides_gazebo.sh.in similarity index 78% rename from ignition/simslides_ignition.sh.in rename to gazebo/simslides_gazebo.sh.in index 15b912e..f51a3ce 100644 --- a/ignition/simslides_ignition.sh.in +++ b/gazebo/simslides_gazebo.sh.in @@ -5,9 +5,9 @@ source @CMAKE_INSTALL_PREFIX@/share/@PROJECT_NAME@/setup.sh ARGS=$@ if [ -z "$ARGS" ]; then - ARGS=simslides_ignition.sdf + ARGS=simslides_gazebo.sdf fi echo -e "\e[34mSimSlides loading world [$ARGS]\e[0m" -ign gazebo $ARGS +gz sim $ARGS diff --git a/ignition/CMakeLists.txt b/ignition/CMakeLists.txt deleted file mode 100644 index ef67092..0000000 --- a/ignition/CMakeLists.txt +++ /dev/null @@ -1,53 +0,0 @@ -set(library_name SimSlidesIgn) - -set(client_src - ${library_name}.cc -) - -set (qt_headers - ${library_name}.hh -) - -find_package(Qt5 - COMPONENTS - Core - Quick - QuickControls2 - REQUIRED -) - -set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${IGNITION-GUI_CXX_FLAGS} -std=c++17 -lstdc++fs") - -QT5_ADD_RESOURCES(resources_RCC ${library_name}.qrc) -QT5_WRAP_CPP(headers_MOC ${qt_headers}) - -add_library(${library_name} SHARED - ${client_src} - ${headers_MOC} - ${resources_RCC} -) - -target_link_libraries(${library_name} - stdc++fs - SimSlidesCommon - ignition-common${IGN_COMMON_VER}::ignition-common${IGN_COMMON_VER} - ignition-gazebo${IGN_GAZEBO_VER}::ignition-gazebo${IGN_GAZEBO_VER} - ignition-gui${IGN_GUI_VER}::ignition-gui${IGN_GUI_VER} - ignition-rendering${IGN_RENDERING_VER}::ignition-rendering${IGN_RENDERING_VER} -) - -include(GNUInstallDirs) -install(TARGETS ${library_name} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}/ign-gui/ -) - -configure_file( - "simslides_ignition.sh.in" - "${CMAKE_CURRENT_BINARY_DIR}/share/simslides_ignition" @ONLY -) - -install(PROGRAMS - ${CMAKE_CURRENT_BINARY_DIR}/share/simslides_ignition - DESTINATION bin -) - diff --git a/ignition/SimSlidesIgn.qrc b/ignition/SimSlidesIgn.qrc deleted file mode 100644 index 412568d..0000000 --- a/ignition/SimSlidesIgn.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - SimSlidesIgn.qml - - diff --git a/images/SimSlides_Ignition.gif b/images/SimSlides_Gazebo.gif similarity index 100% rename from images/SimSlides_Ignition.gif rename to images/SimSlides_Gazebo.gif diff --git a/setup.sh.in b/setup.sh.in index 93f9507..7f07cca 100644 --- a/setup.sh.in +++ b/setup.sh.in @@ -1,7 +1,7 @@ # generated from simslides/setup.sh.in -export GAZEBO_MODEL_PATH=@CMAKE_INSTALL_PREFIX@/share/@PROJECT_NAME@/models:$GAZEBO_MODEL_PATH -export GAZEBO_RESOURCE_PATH=@CMAKE_INSTALL_PREFIX@/share/@PROJECT_NAME@/worlds:$GAZEBO_RESOURCE_PATH +# export GAZEBO_MODEL_PATH=@CMAKE_INSTALL_PREFIX@/share/@PROJECT_NAME@/models:$GAZEBO_MODEL_PATH +# export GAZEBO_RESOURCE_PATH=@CMAKE_INSTALL_PREFIX@/share/@PROJECT_NAME@/worlds:$GAZEBO_RESOURCE_PATH -export IGN_GUI_PLUGIN_PATH=@CMAKE_INSTALL_PREFIX@/lib/@PROJECT_NAME@/ign-gui/:$IGN_GUI_PLUGIN_PATH -export IGN_GAZEBO_RESOURCE_PATH=@CMAKE_INSTALL_PREFIX@/share/@PROJECT_NAME@/worlds:@CMAKE_INSTALL_PREFIX@/share/@PROJECT_NAME@/models:$IGN_GAZEBO_RESOURCE_PATH +export GZ_GUI_PLUGIN_PATH=@CMAKE_INSTALL_PREFIX@/lib/@PROJECT_NAME@/gz-gui/:$GZ_GUI_PLUGIN_PATH +export GZ_GAZEBO_RESOURCE_PATH=@CMAKE_INSTALL_PREFIX@/share/@PROJECT_NAME@/worlds:@CMAKE_INSTALL_PREFIX@/share/@PROJECT_NAME@/models:$GZ_GAZEBO_RESOURCE_PATH diff --git a/worlds/simslides_gazebo.sdf b/worlds/simslides_gazebo.sdf new file mode 100644 index 0000000..addca45 --- /dev/null +++ b/worlds/simslides_gazebo.sdf @@ -0,0 +1,218 @@ + + + + + + + + + + + + + + + + 3D View + false + docked + + + ogre2 + scene + 1.0 1.0 1.0 + 0.8 0.8 0.8 + -6 0 6 0 0.5 0 + + 0.25 + 25000 + + + + + + + floating + 5 + 5 + false + + + + + false + 5 + 5 + floating + false + + + + + false + 5 + 5 + floating + false + + + + + false + 5 + 5 + floating + false + + + + + false + 5 + 5 + floating + false + + + + + + + + + false + 5 + 5 + floating + false + + + + + false + 5 + 5 + floating + false + + + + + + + + + + false + 5 + 5 + floating + false + + + + + + + + World control + false + false + 72 + 121 + 1 + + floating + + + + + + + true + true + true + /world/shapes/control + /world/shapes/stats + + + + + + + World stats + false + false + 110 + 290 + 1 + + floating + + + + + + + true + true + true + true + /world/shapes/stats + + + + + + SimSlides + + + + + + true + 0 0 10 0 0 0 + 0.8 0.8 0.8 1 + 0.8 0.8 0.8 1 + + 1000 + 0.9 + 0.01 + 0.001 + + -0.5 0.1 -0.9 + + + + true + + + + + 0 0 1 + + + + + + + 0 0 1 + 100 100 + + + + 0.8 0.8 0.8 1 + 0.8 0.8 0.8 1 + 0.8 0.8 0.8 1 + + + + + + diff --git a/worlds/simslides_ignition.sdf b/worlds/simslides_ignition.sdf deleted file mode 100644 index 183ee50..0000000 --- a/worlds/simslides_ignition.sdf +++ /dev/null @@ -1,131 +0,0 @@ - - - - - - - - - - - - - - - - 3D View - false - docked - - - ogre2 - scene - 1.0 1.0 1.0 - 0.8 0.8 0.8 - -6 0 6 0 0.5 0 - - - - - - World control - false - false - 72 - 121 - 1 - - floating - - - - - - - true - true - true - /world/shapes/control - /world/shapes/stats - - - - - - - World stats - false - false - 110 - 290 - 1 - - floating - - - - - - - true - true - true - true - /world/shapes/stats - - - - - - SimSlides - - - - - - true - 0 0 10 0 0 0 - 0.8 0.8 0.8 1 - 0.8 0.8 0.8 1 - - 1000 - 0.9 - 0.01 - 0.001 - - -0.5 0.1 -0.9 - - - - true - - - - - 0 0 1 - - - - - - - 0 0 1 - 100 100 - - - - 0.8 0.8 0.8 1 - 0.8 0.8 0.8 1 - 0.8 0.8 0.8 1 - - - - - -