Header
Let's go ahead and define the structure for our tutorial class.
We'll start with our imports: these are pretty straightforward, with a bunch of STL headers, OpenCV headers, ROS headers, and finally, Smart Capture headers.
Next, we'll define our SmartCaptureROS1Lidar class inside the SmartCapture namespace. Along with the using statements for handling the std and std::chrono namespaces, these are just a bunch of quality of life improvements.
We have five subscribers with public callbacks:
sensor_msgs/PointCloud2sensor_msgs/Imudarknet_msgs/BoundingBoxesstd_msgs/Float64MultiArraysensor_msgs/Image<- this is handled by the ImageTransport ROS class.
Finally, we define the SmartCapture::Client.
So little Smart Capture!If it feels like there's a lot of non-Smart Capture content in this Tutorial, you're not wrong.
In order to really show Smart Capture, we need a bunch of different output, object detections and sensor data, in order to trigger against.
This sample takes care of generating and aggregating it in a Smart Capture ROS node to evaluate triggers.
The header in its entirety below.
#include <string>
#include <cmath>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <ros/ros.h>
#include <image_transport/image_transport.h>
#include <cv_bridge/cv_bridge.h>
#include <sensor_msgs/image_encodings.h>
#include <sensor_msgs/Image.h>
#include <sensor_msgs/PointCloud2.h>
#include <sensor_msgs/Imu.h>
#include <sensor_msgs/point_cloud2_iterator.h>
#include <darknet_ros_msgs/BoundingBoxes.h>
#include <darknet_ros_msgs/BoundingBox.h>
#include <std_msgs/Float64MultiArray.h>
#include <client/client.hpp>
namespace SmartCapture {
class SmartCaptureROS1Lidar {
private:
ros::NodeHandle nh_;
image_transport::ImageTransport it_;
image_transport::Subscriber image_sub_;
ros::Subscriber pcl_sub_;
ros::Subscriber imu_sub_;
ros::Subscriber bbox_sub_;
ros::Subscriber emb_sub_;
std::shared_ptr<Client> client;
public:
SmartCaptureROS1Lidar();
~SmartCaptureROS1Lidar();
void image_callback(const sensor_msgs::ImageConstPtr &msg);
void pointcloud_callback(const sensor_msgs::PointCloud2ConstPtr &msg);
void imu_callback(const sensor_msgs::Imu &msg);
void bbox_callback(const darknet_ros_msgs::BoundingBoxes &msg);
void emb_callback(const std_msgs::Float64MultiArray &msg);
};
}
Updated 10 months ago