トピックなし
AxesやGridのようにトピックの購読なしで動作するプラグイン
display_template.hpp
#ifndef SAMPLE_RVIZ_PLUGINS_DISPLAY_TEMPLATE_HPP
#define SAMPLE_RVIZ_PLUGINS_DISPLAY_TEMPLATE_HPP
#include <rviz_common/display.hpp>
namespace sample_rviz_plugins
{
class DisplayTemplate : public rviz_common::Display
{
Q_OBJECT
public:
DisplayTemplate();
~DisplayTemplate() override;
void onInitialize() override;
void update(float dt, float ros_dt) override;
protected:
void onEnable() override;
void onDisable() override;
private Q_SLOTS:
// void updateShape();
private:
};
}
#endif // SAMPLE_RVIZ_PLUGINS_DISPLAY_TEMPLATE_HPP
display_template.cpp
#include "display_template.hpp"
#include <rviz_common/display_context.hpp>
namespace rviz_default_plugins
{
DisplayTemplate::DisplayTemplate()
: Display()
{
}
DisplayTemplate::~DisplayTemplate() = default;
void DisplayTemplate::onInitialize()
{
}
void DisplayTemplate::onEnable()
{
}
void DisplayTemplate::onDisable()
{
}
void DisplayTemplate::update(float dt, float ros_dt)
{
(void)dt;
(void)ros_dt;
}
}
#include <pluginlib/class_list_macros.hpp>
PLUGINLIB_EXPORT_CLASS(sample_rviz_plugins::DisplayTemplate, rviz_common::Display)
トピックあり
Odometry,Pose,Pathのようにトピックを購読して動作するプラグイン
topic_display_template.hpp
#ifndef SAMPLE_RVIZ_PLUGINS_TOPIC_DISPLAY_TEMPLATE_HPP
#define SAMPLE_RVIZ_PLUGINS_TOPIC_DISPLAY_TEMPLATE_HPP
#include <std_msgs/msg/float32.hpp>
#include <rviz_common/ros_topic_display.hpp>
#include <mutex>
namespace sample_rviz_plugins
{
class TopicDisplayTemplate
: public rviz_common::RosTopicDisplay<std_msgs::msg::Float32>
{
Q_OBJECT
public:
TopicDisplayTemplate();
~TopicDisplayTemplate() override;
protected:
void onEnable() override;
void onDisable() override;
void onInitialize() override;
void processMessage(std_msgs::msg::Float32::ConstSharedPtr msg) override;
void update(float wall_dt, float ros_dt) override;
void reset() override;
std::mutex mutex_;
private:
};
}
#endif // SAMPLE_RVIZ_PLUGINS_TOPIC_DISPLAY_TEMPLATE_HPP
topic_display_template.cpp
#include "topic_display_template.hpp"
#include <rviz_common/display_context.hpp>
namespace sample_rviz_plugins
{
TopicDisplayTemplate::TopicDisplayTemplate()
{
}
TopicDisplayTemplate::~TopicDisplayTemplate()
{
}
void TopicDisplayTemplate::onInitialize()
{
RTDClass::onInitialize();
}
void TopicDisplayTemplate::update(float wall_dt, float ros_dt)
{
(void)dt;
(void)ros_dt;
}
void TopicDisplayTemplate::processMessage(std_msgs::msg::Float32::ConstSharedPtr msg)
{
std::lock_guard<std::mutex> lock(mutex_);
}
void TopicDisplayTemplate::reset()
{
RTDClass::reset();
}
void TopicDisplayTemplate::onEnable()
{
subscribe();
}
void TopicDisplayTemplate::onDisable()
{
unsubscribe();
}
}
#include <pluginlib/class_list_macros.hpp>
PLUGINLIB_EXPORT_CLASS( sample_rviz_plugins::TopicDisplayTemplate, rviz_common::Display )