-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TF visualization plugin config (#32)
* Add tf plugin gui config * Use ign-gui plugin instead of pluginlib * Add template tf gui config Signed-off-by: Sarathkrishnan Ramesh <[email protected]> * Add visibility options for frame axis, arrow and names Signed-off-by: Sarathkrishnan Ramesh <[email protected]> * Add more config options * Set axes arrow head visibility * Change marker scale Signed-off-by: Sarathkrishnan Ramesh <[email protected]> * Add tf frames to tree view Signed-off-by: Sarathkrishnan Ramesh <[email protected]> * Add option to set individual frame visibility * Add checkboxes to tree view frame list * Update documentation Signed-off-by: Sarathkrishnan Ramesh <[email protected]> * Add option to set visibility of all frames Signed-off-by: Sarathkrishnan Ramesh <[email protected]>
- Loading branch information
Showing
11 changed files
with
809 additions
and
359 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
180 changes: 180 additions & 0 deletions
180
ign_rviz_plugins/include/ignition/rviz/plugins/TFDisplay.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,180 @@ | ||
// Copyright (c) 2020 Open Source Robotics Foundation, Inc. | ||
// | ||
// 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__RVIZ__PLUGINS__TFDISPLAY_HPP_ | ||
#define IGNITION__RVIZ__PLUGINS__TFDISPLAY_HPP_ | ||
|
||
#include <ignition/rendering.hh> | ||
#include <tf2_msgs/msg/tf_message.hpp> | ||
|
||
#include <QStandardItem> | ||
|
||
#include <map> | ||
#include <memory> | ||
#include <mutex> | ||
#include <string> | ||
#include <vector> | ||
|
||
#include "ignition/rviz/plugins/message_display_base.hpp" | ||
|
||
namespace ignition | ||
{ | ||
namespace rviz | ||
{ | ||
namespace plugins | ||
{ | ||
//////////////////////////////////////////////////////////////////////////////// | ||
class FrameModel : public QStandardItemModel | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
// Roles for tree view frames | ||
enum FrameRoles | ||
{ | ||
NameRole = Qt::UserRole + 1 | ||
}; | ||
|
||
// Constructor | ||
explicit FrameModel(QObject * _parent = 0); | ||
|
||
Q_INVOKABLE void addFrame(const QString & _name, QStandardItem * _parentItem); | ||
Q_INVOKABLE QStandardItem * addParentRow(const QString & _name); | ||
|
||
QVariant data(const QModelIndex & _index, int _role = Qt::DisplayRole) const; | ||
|
||
protected: | ||
QHash<int, QByteArray> roleNames() const; | ||
}; | ||
|
||
//////////////////////////////////////////////////////////////////////////////// | ||
class TFDisplay : public MessageDisplay<tf2_msgs::msg::TFMessage> | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
/** | ||
* Constructor for tf visualization plugin | ||
*/ | ||
TFDisplay(); | ||
|
||
// Destructor | ||
~TFDisplay(); | ||
|
||
// Documentation inherited | ||
void LoadConfig(const tinyxml2::XMLElement * /*_pluginElem*/); | ||
|
||
// Documentation Inherited | ||
void initialize(rclcpp::Node::SharedPtr); | ||
|
||
// Documentation Inherited | ||
void callback(const tf2_msgs::msg::TFMessage::SharedPtr) {} | ||
|
||
// Documentation inherited | ||
void setTopic(std::string) {} | ||
|
||
/** | ||
* @brief Qt eventFilters. Original documentation can be found | ||
* <a href="https://doc.qt.io/qt-5/qobject.html#eventFilter">here</a> | ||
*/ | ||
bool eventFilter(QObject *, QEvent *); | ||
|
||
// Documentation inherited | ||
void setFrameManager(std::shared_ptr<common::FrameManager> _frameManager); | ||
|
||
/** | ||
* @brief Set axis visibility | ||
* @param[in] _visible Axes visibility | ||
*/ | ||
Q_INVOKABLE void showAxes(const bool & _visible); | ||
|
||
/** | ||
* @brief Set arrow visibility | ||
* @param[in] _visible Arrow visibility | ||
*/ | ||
Q_INVOKABLE void showArrows(const bool & _visible); | ||
|
||
/** | ||
* @brief Set frame name visibility | ||
* @param[in] _visible Frame name visibility | ||
*/ | ||
Q_INVOKABLE void showNames(const bool & _visible); | ||
|
||
/** | ||
* @brief Set axes arrow head visibility | ||
* @param[in] _visible Axes arrow head visibility | ||
*/ | ||
Q_INVOKABLE void showAxesHead(const bool & _visible); | ||
|
||
/** | ||
* @brief Set marker scale | ||
* @param _scale TF visual marker scale | ||
*/ | ||
Q_INVOKABLE void setMarkerScale(const float & _scale); | ||
|
||
/** | ||
* @brief Set frame visibility | ||
* @param[in] _frame Frame name | ||
* @param[in] _visible Frame visibility | ||
*/ | ||
Q_INVOKABLE void setFrameVisibility(const QString & _frame, const bool & _visible); | ||
|
||
protected: | ||
/** | ||
* @brief Create custom arrow visual for visualizing tf links | ||
* @return tf arrow visual | ||
*/ | ||
rendering::ArrowVisualPtr createTfArrow(); | ||
|
||
/** | ||
* @brief Update tf visualization | ||
*/ | ||
void updateTF(); | ||
|
||
/** | ||
* @brief Creates a frame visual which includes an axis | ||
* an arrow, and text visual | ||
* @return A frame visual | ||
*/ | ||
rendering::VisualPtr createVisualFrame(); | ||
|
||
/** | ||
* @brief Update tree view and local frame list | ||
*/ | ||
void refresh(); | ||
|
||
public: | ||
// Tree view frame model | ||
FrameModel * model; | ||
|
||
private: | ||
ignition::rendering::AxisVisualPtr axis; | ||
ignition::rendering::RenderEngine * engine; | ||
ignition::rendering::ScenePtr scene; | ||
ignition::rendering::VisualPtr tfRootVisual; | ||
std::mutex lock; | ||
bool axesVisible; | ||
bool arrowsVisible; | ||
bool namesVisible; | ||
bool axesHeadVisible; | ||
float markerScale; | ||
QStandardItem * parentRow; | ||
std::map<std::string, bool> frameInfo; | ||
}; | ||
|
||
} // namespace plugins | ||
} // namespace rviz | ||
} // namespace ignition | ||
|
||
#endif // IGNITION__RVIZ__PLUGINS__TFDISPLAY_HPP_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.