Skip to content

Commit

Permalink
Merge pull request #50 from analogdevicesinc/dev/refactoring
Browse files Browse the repository at this point in the history
Refactor ROS2 repository: documentation and functionality
  • Loading branch information
rbolboac authored Aug 22, 2023
2 parents f63374d + 65d3d22 commit c22e238
Show file tree
Hide file tree
Showing 56 changed files with 1,250 additions and 2,844 deletions.
4 changes: 2 additions & 2 deletions Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ DOXYFILE_ENCODING = UTF-8
# title of most generated pages and in a few other places.
# The default value is: My Project.

PROJECT_NAME = "My Project"
PROJECT_NAME = "imu-ros2"

# The PROJECT_NUMBER tag can be used to enter a project or revision number. This
# could be handy for archiving the generated documentation or if some version
Expand Down Expand Up @@ -864,7 +864,7 @@ WARN_LOGFILE =
# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING
# Note: If this tag is empty the current directory is searched.

INPUT =
INPUT = include/ src/ test/src

# This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# imu-ros2
A C++ ROS2 node that read sensor data from ADI IMU and publishes message to topic.
A C++ ROS2 node that reads sensor data from ADI IMU devices and publishes
messages on topics. The node is also able to configure ADI IMU devices.
The ROS2 driver uses LibIIO to retrieve information from IMU Kernel Driver.
35 changes: 9 additions & 26 deletions include/imu_ros2/accelgyrotemp_data_provider.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,49 +26,32 @@
#include "imu_ros2/iio_wrapper.h"

/**
* \brief Class implementation for accel gyro temp data provider.
*
* This class implements AccelGyroTempDataProviderInterface interface.
* This class provides data for the publisher.
* The type of data is AccelGyroTempData.
* @brief Class for acceleration, angular velocity and temperature
* buffered data provider.
*/
class AccelGyroTempDataProvider : public AccelGyroTempDataProviderInterface
{
public:
/**
* \brief Constructor for AccelGyroTempDataProvider.
*
* This is the default constructor for class
* AccelGyroTempDataProvider.
*
* @brief Constructor for AccelGyroTempDataProvider.
*/
AccelGyroTempDataProvider();

/**
* \brief Destructor for AccelGyroTempDataProvider.
*
* This is the destructor for AccelGyroTempDataProvider.
*
* @brief Destructor for AccelGyroTempDataProvider.
*/
~AccelGyroTempDataProvider();

/**
* @brief Populate message variable with data.
*
* This function return by parameter a message variable
* with data from the sensor like acceleration, gyroscope
* and temperature. The reading from the libiio is with buffer.
*
* @return Return true if the message variable is populated with
* values and false if the message is not populated.
* @param message Populate message variable
* with data like acceleration, gyroscope and temperature from
* the sensor.
* @brief Populate AccelGyroTempData message with measured data.
* @param message Message containing the measured data.
* @return Return true if the message parameter is successfully populated with
* measured data and false otherwise.
*/
bool getData(imu_ros2::msg::AccelGyroTempData & message) override;

private:
/*! This data member access information from libiio */
/*! This data member is used to access sensor information via libiio. */
IIOWrapper m_iio_wrapper;
};

Expand Down
32 changes: 8 additions & 24 deletions include/imu_ros2/accelgyrotemp_data_provider_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,43 +25,27 @@
#include "imu_ros2/msg/accel_gyro_temp_data.hpp"

/**
* \brief Interface for accel gyro temp data provider.
*
* This interface provides data for the publisher.
* The type of data is AccelGyroTempData.
* @brief Interface for acceleration, angular velocity and temperature
* buffered data provider.
*/
class AccelGyroTempDataProviderInterface
{
public:
/**
* \brief Constructor for AccelGyroTempDataProviderInterface.
*
* This is the default constructor for interface
* AccelGyroTempDataProviderInterface.
*
* @brief Constructor for AccelGyroTempDataProviderInterface.
*/
AccelGyroTempDataProviderInterface() {}

/**
* \brief Destructor for AccelGyroTempDataProviderInterface.
*
* This is a virtual destructor for AccelGyroTempDataProviderInterface.
*
* @brief Destructor for AccelGyroTempDataProviderInterface.
*/
virtual ~AccelGyroTempDataProviderInterface() {}

/**
* @brief Populate message variable with data.
*
* This function return by parameter a message variable
* with data from the sensor like acceleration, gyroscope
* and temperature. The reading from the libiio is with buffer.
*
* @return Return true if the message variable is populated with
* values and false if the message is not populated.
* @param message Populate message variable
* with data like acceleration, gyroscope and temperature from
* the sensor.
* @brief Populate AccelGyroTempData message with measured data.
* @param message Message containing the measured data.
* @return Return true if the message parameter is successfully populated with
* measured data and false otherwise.
*/
virtual bool getData(imu_ros2::msg::AccelGyroTempData & message) = 0;
};
Expand Down
51 changes: 10 additions & 41 deletions include/imu_ros2/accelgyrotemp_ros_publisher.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,72 +27,41 @@
#include "imu_ros2/accelgyrotemp_ros_publisher_interface.h"

/**
* \brief Class for accel gyro temp ros publisher.
*
* This class initializes the ros Node class.
* It set message provider with a variable that is
* a type of AccelGyroTempDataProviderInterface.
* It also run on thread reading from data provider and
* write on a ros2 publisher.
* @brief Class for acceleration, angular velocity and temperature publisher.
*/
class AccelGyroTempRosPublisher : public AccelGyroTempRosPublisherInterface
{
public:
/**
* \brief Constructor for AccelGyroTempRosPublisher.
*
* This is the default constructor for class
* AccelGyroTempRosPublisher.
*
* @brief Constructor for AccelGyroTempRosPublisher.
* @param node The ros2 Node instance.
*/
AccelGyroTempRosPublisher(std::shared_ptr<rclcpp::Node> & node);

/**
* \brief Destructor for AccelGyroTempRosPublisher.
*
* This is a destructor for AccelGyroTempRosPublisher.
*
* @brief Destructor for AccelGyroTempRosPublisher.
*/
~AccelGyroTempRosPublisher();

/**
* @brief Initialize class with ros2 Node instance.
*
* This function initialize the class that inherit
* this interface wiht a ros2 Node instance.
*
* @param node The ros2 Node instance.
*/
void init(std::shared_ptr<rclcpp::Node> & node) override;

/**
* @brief Set message provider.
*
* This function set data message provider with a variable that
* inherit AccelGyroTempDataProviderInterface.
*
* @param dataProvider Data message provider.
* @brief Set the message data provider.
* @param dataProvider Data provider.
*/
void setMessageProvider(AccelGyroTempDataProviderInterface * dataProvider) override;

/**
* @brief Read from message provider and write on topic
*
* Run on thread the reading from message provider and write
* on publisher the data.
*
* @brief Publish the AccelGyroTempData message.
*/
void run() override;
void publish() override;

private:
/*! This variable retain a message provider */
/*! This variable retains the data provider instance. */
AccelGyroTempDataProviderInterface * m_data_provider;

/*! This variable retain a publisher instance */
/*! This variable retains the publisher instance. */
rclcpp::Publisher<imu_ros2::msg::AccelGyroTempData>::SharedPtr m_publisher;

/*! This variable retain a message that is published on a topic */
/*! This variable retains the message that is published. */
imu_ros2::msg::AccelGyroTempData m_message;
};

Expand Down
43 changes: 11 additions & 32 deletions include/imu_ros2/accelgyrotemp_ros_publisher_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,59 +24,38 @@
#include <memory>
#include <rclcpp/rclcpp.hpp>

#include "imu_ros2/ros_task.h"

class AccelGyroTempDataProviderInterface;

/**
* \brief Interface for accel gyro temp ros publisher.
*
* This interface initializes the ros Node class.
* Also it set message provider with a variable that is
* a type of AccelGyroTempDataProviderInterface.
* @brief Interface for acceleration, angular velocity and temperature
* publisher.
*/
class AccelGyroTempRosPublisherInterface : public RosTask
class AccelGyroTempRosPublisherInterface
{
public:
/**
* \brief Constructor for AccelGyroTempRosPublisherInterface.
*
* This is the default constructor for interface
* AccelGyroTempRosPublisherInterface.
*
* @brief Constructor for AccelGyroTempRosPublisherInterface.
*/
AccelGyroTempRosPublisherInterface() {}

/**
* \brief Destructor for AccelGyroTempRosPublisherInterface.
*
* This is a virtual destructor for AccelGyroTempRosPublisherInterface.
*
* @brief Destructor for AccelGyroTempRosPublisherInterface.
*/
virtual ~AccelGyroTempRosPublisherInterface() {}

/**
* @brief Initialize class with ros2 Node instance.
*
* This function initialize the class that inherit
* this interface wiht a ros2 Node instance.
*
* @param node The ros2 Node instance
* @brief Set the message data provider.
* @param dataProvider Data provider.
*/
virtual void init(std::shared_ptr<rclcpp::Node> & node) = 0;
virtual void setMessageProvider(AccelGyroTempDataProviderInterface * dataProvider) = 0;

/**
* @brief Set message provider.
*
* This function set data message provider with a variable that
* inherit AccelGyroTempDataProviderInterface.
*
* @param dataProvider Data message provider.
* @brief Publish the AccelGyroTempData message.
*/
virtual void setMessageProvider(AccelGyroTempDataProviderInterface * dataProvider) = 0;
virtual void publish() = 0;

protected:
/*! The ros2 Node data member */
/*! The ros2 Node data member. */
std::shared_ptr<rclcpp::Node> m_node;
};

Expand Down
Loading

0 comments on commit c22e238

Please sign in to comment.