Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates for Gazebo Garden #22

Open
wants to merge 1 commit into
base: fortress
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
27 changes: 13 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.

---

Expand All @@ -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

Expand All @@ -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)

Expand All @@ -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)

Expand All @@ -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

Expand Down Expand Up @@ -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.

11 changes: 6 additions & 5 deletions common/Common.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/

#include <limits>
#include <gz/math/Matrix4.hh>

#include "include/simslides/common/Common.hh"

Expand Down Expand Up @@ -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());
Expand Down
15 changes: 7 additions & 8 deletions common/Keyframe.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -65,7 +65,7 @@ Keyframe::Keyframe(sdf::ElementPtr _sdf) : dataPtr(new KeyframePrivate)

if (_sdf->HasAttribute("eye_offset"))
{
this->dataPtr->eyeOffset = _sdf->Get<ignition::math::Pose3d>("eye_offset");
this->dataPtr->eyeOffset = _sdf->Get<gz::math::Pose3d>("eye_offset");
}
if (_sdf->HasAttribute("text"))
{
Expand All @@ -91,14 +91,14 @@ Keyframe::Keyframe(sdf::ElementPtr _sdf) : dataPtr(new KeyframePrivate)
}
else if (type == "log_seek")
{
this->dataPtr->camPose = _sdf->Get<ignition::math::Pose3d>("cam_pose");
this->dataPtr->camPose = _sdf->Get<gz::math::Pose3d>("cam_pose");
auto logSeek = _sdf->Get<sdf::Time>("time");
this->dataPtr->logSeek = std::chrono::seconds(logSeek.sec) +
std::chrono::nanoseconds(logSeek.nsec);
}
else if (type == "cam_pose")
{
this->dataPtr->camPose = _sdf->Get<ignition::math::Pose3d>("pose");
this->dataPtr->camPose = _sdf->Get<gz::math::Pose3d>("pose");
}
else
{
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -202,4 +202,3 @@ KeyframeType KeyframePrivate::StrToType(const std::string &_type) const

return KeyframeType::NONE;
}

8 changes: 4 additions & 4 deletions common/include/simslides/common/Common.hh
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ namespace simslides
public: void ChangeKeyframe(int _keyframe);

/// \brief Function called to move camera, containing the target pose.
public: std::function<void(const ignition::math::Pose3d &)> MoveCamera;
public: std::function<void(const gz::math::Pose3d &)> MoveCamera;

/// \brief Function called to move camera, containing the target pose.
public: std::function<void(const std::string &, bool)> SetVisualVisible;
Expand All @@ -68,7 +68,7 @@ namespace simslides

/// \brief Function called to get a visual's pose according to its scoped
/// name.
public: std::function<ignition::math::Pose3d(const std::string &)>
public: std::function<gz::math::Pose3d(const std::string &)>
VisualPose;

/// \brief Function called to set text, containing the the text.
Expand All @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions common/include/simslides/common/Keyframe.hh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include <memory>
#include <string>
#include <sdf/Element.hh>
#include <ignition/math/Pose3.hh>
#include <gz/math/Pose3.hh>

namespace simslides
{
Expand Down Expand Up @@ -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
Expand Down
52 changes: 52 additions & 0 deletions gazebo/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
)
Loading