Skip to content

Commit

Permalink
feat: add builtin plugin package
Browse files Browse the repository at this point in the history
Signed-off-by: ktro2828 <[email protected]>
  • Loading branch information
ktro2828 committed Aug 14, 2024
1 parent 8f85042 commit 57dfcd5
Show file tree
Hide file tree
Showing 23 changed files with 1,010 additions and 358 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,8 @@ source install/setup.bash
# run awviz
ros2 run awviz awviz
```

## Plugin Customization

Some ROS messages are already covered by built-in plugins defined in `awviz_plugin`.
For the detail of supported ROS messages and plugin customization, please refer to [`awviz_plugin/README.md`](./awviz_plugin/README.md).
202 changes: 0 additions & 202 deletions awviz/LICENSE

This file was deleted.

89 changes: 22 additions & 67 deletions awviz_common/include/awviz_common/display.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@
#ifndef AWVIZ_COMMON__DISPLAY_HPP_
#define AWVIZ_COMMON__DISPLAY_HPP_

#include "awviz_common/property.hpp"

#include <rclcpp/qos.hpp>
#include <rclcpp/rclcpp.hpp>
#include <rerun.hpp>
#include <rosidl_runtime_cpp/traits.hpp>

#include <memory>
#include <string>
Expand Down Expand Up @@ -53,6 +57,11 @@ class Display
*/
virtual void start() = 0;

/**
* @brief End to display
*/
virtual void end() = 0;

/**
* @brief Return true if the initialization is completed.
* @return bool Return the value of the private member named `is_initialized_`.
Expand All @@ -66,68 +75,7 @@ class Display
};

/**
* @brief Struct representing a property of ROS msg display instance.
*/
class RosTopicProperty
{
public:
RosTopicProperty() {}

/**
* @brief Construct instance.
* @param type ROS msg type.
* @param topic Name of topic.
* @param entity Entity path to log.
*/
RosTopicProperty(const std::string & type, const std::string & topic, const std::string & entity)
: type_(type), topic_(topic), entity_(entity)
{
}

/**
* @brief Set ROS message type name.
* @param type Name of ROS message type.
*/
void setType(const std::string & type) { type_ = type; }

/**
* @brief Set ROS topic name.
* @param topic Name of topic.
*/
void setTopic(const std::string & topic) { topic_ = topic; }

/**
* @brief Set entity path of record.
* @param entity Entity path of record.
*/
void setEntity(const std::string & entity) { entity_ = entity; }

/**
* @brief Get ROS message type.
* @return ROS message type name.
*/
const std::string & type() const noexcept { return type_; }

/**
* @brief Get ROS topic name.
* @return Name of topic.
*/
const std::string & topic() const noexcept { return topic_; }

/**
* @brief Get entity path of record.
* @return Entity path of record.
*/
const std::string & entity() const noexcept { return entity_; }

private:
std::string type_;
std::string topic_;
std::string entity_;
};

/**
* @brief
* @brief Inherited plugin class to display ROS topics.
*/
template <typename MsgType>
class RosTopicDisplay : public Display
Expand All @@ -138,7 +86,7 @@ class RosTopicDisplay : public Display
*/
RosTopicDisplay()
{
auto msg_type = rosidl_generator_traits::name<MsgType>();
const auto msg_type = rosidl_generator_traits::name<MsgType>();
property_.setType(msg_type);
}

Expand Down Expand Up @@ -176,7 +124,14 @@ class RosTopicDisplay : public Display
*/
void start() override { subscribe(); }

private:
/**
* @brief End to display.
*/
void end() override { unsubscribe(); }

protected:
static constexpr const char * TIMELINE_NAME = "timestamp"; //!< Entity name of timeline record.

/**
* @brief Start to subscribing the specified topic.
*/
Expand All @@ -203,9 +158,9 @@ class RosTopicDisplay : public Display
*/
virtual void logToStream(typename MsgType::ConstSharedPtr msg) = 0;

private:
typename rclcpp::Subscription<MsgType>::SharedPtr subscription_;
RosTopicProperty property_;
protected:
typename rclcpp::Subscription<MsgType>::SharedPtr subscription_; //!< Subscription of the topic.
RosTopicProperty property_; //!< Topic property.
};
} // namespace awviz_common
#endif // AWVIZ_COMMON__DISPLAY_HPP_
Loading

0 comments on commit 57dfcd5

Please sign in to comment.