3#ifndef MOTION_CAPTURE_HPP_
4#define MOTION_CAPTURE_HPP_
6#include <pcl/point_cloud.h>
7#include <pcl/point_types.h>
8#include <pcl/common/centroid.h>
9#include <pcl_conversions/pcl_conversions.h>
15#include <rclcpp/rclcpp.hpp>
16#include <sensor_msgs/msg/point_cloud2.hpp>
17#include <geometry_msgs/msg/point.hpp>
18#include <geometry_msgs/msg/vector3.hpp>
225 Eigen::Vector3f
publishVelocity(
const Eigen::Vector4f & current_position);
255 rclcpp::Subscription<sensor_msgs::msg::PointCloud2>::SharedPtr
subscription_;
rclcpp::Publisher< geometry_msgs::msg::Vector3 >::SharedPtr acceleration_publisher_
ROS2 publisher to send the calculated object acceleration.
CentroidIndex
Enumeration representing indices for the centroid coordinates.
@ kCentroidY
Index for the Y-coordinate of the centroid.
@ kCentroidX
Index for the X-coordinate of the centroid.
@ kCentroidZ
Index for the Z-coordinate of the centroid.
void publishData()
Publishes the calculated position, velocity, and acceleration.
double kDefaultPublishRate
Default publish rate in Hz for publishing position, velocity, and acceleration.
int kDefaultQueueSize
Default queue size for ROS publishers and subscriptions.
Eigen::Vector4f getFilteredPosition()
Retrieves the filtered position of the object.
VectorIndex
Enumeration representing indices for the velocity vector.
@ kVectorZ
Index for the Z-component of the velocity vector.
@ kVectorY
Index for the Y-component of the velocity vector.
@ kVectorX
Index for the X-component of the velocity vector.
std::string kDefaultPointCloudTopicFiltered
Default topic name for subscribing to the filtered point cloud data.
Eigen::Vector4f previous_position_
The previous position of the object in 3D space.
void updatePositionSamples(const Eigen::Vector4f ¢roid)
Updates the position samples queue with a new centroid value.
std::string acceleration_publish_topic_
Topic name for publishing the calculated acceleration of an object.
void loadParameters()
Loads parameters from the ROS2 parameter server.
rclcpp::Time previous_time_
The timestamp of the previous position sample.
std::queue< Eigen::Vector4f > position_queue_
Queue to store recent position samples for calculating position.
int kDefaultPositionSamples
Default number of position samples used for calculations.
Eigen::Vector3f publishVelocity(const Eigen::Vector4f ¤t_position)
Publishes the object's velocity to a ROS topic.
std::string kDefaultAccelerationPublishTopic
Default topic name for publishing the calculated object acceleration.
std::queue< Eigen::Vector3f > velocity_queue_
Queue to store recent velocity samples for calculating velocity.
int kDefaultVelocitySamples
Default number of velocity samples used for calculations.
Eigen::Vector3f getFilteredVelocity()
Retrieves the filtered velocity of the object.
int velocity_samples_
Number of velocity samples used for calculations.
std::string kDefaultPositionPublishTopic
Default topic name for publishing the calculated object position.
int position_samples_
Number of position samples used for calculations.
rclcpp::Publisher< geometry_msgs::msg::Vector3 >::SharedPtr velocity_publisher_
ROS2 publisher to send the calculated object velocity.
std::string point_cloud_topic_filtered_
Topic name for subscribing to filtered point cloud data.
double kMillisecondsPerSecond
Conversion factor from seconds to milliseconds.
std::string kDefaultVelocityPublishTopic
Default topic name for publishing the calculated object velocity.
MotionCapture()
Constructor for the MotionCapture class.
int queue_size_
Queue size for message publishers and subscriptions.
rclcpp::TimerBase::SharedPtr timer_
Timer used for scheduling the publication of data.
Eigen::Vector3f previous_velocity_
The previous velocity of the object in 3D space.
rclcpp::Subscription< sensor_msgs::msg::PointCloud2 >::SharedPtr subscription_
ROS2 subscription to receive PointCloud2 messages.
void pointCloudCallback(const sensor_msgs::msg::PointCloud2::SharedPtr msg)
Callback function for processing incoming PointCloud2 messages.
void publishPosition(const Eigen::Vector4f ¢roid)
Publishes the object's position to a ROS topic.
void updateVelocitySamples(const Eigen::Vector3f &velocity)
Updates the velocity samples queue with a new velocity value.
void publishAcceleration(const Eigen::Vector3f ¤t_velocity)
Publishes the object's acceleration to a ROS topic.
std::string velocity_publish_topic_
Topic name for publishing the calculated velocity of an object.
rclcpp::Publisher< geometry_msgs::msg::Point >::SharedPtr position_publisher_
ROS2 publisher to send the calculated object position.
rclcpp::Time previous_velocity_time_
The timestamp of the previous velocity sample.
std::string position_publish_topic_
Topic name for publishing the calculated position of an object.
double publish_rate_
Publish rate for sending position, velocity, and acceleration data.