Macros | Functions | Variables
ros_sub_pub.hpp File Reference

Header file for different ROS message type. More...

#include <ros/ros.h>
#include <sensor_msgs/Imu.h>
#include <geometry_msgs/Twist.h>
#include <std_msgs/String.h>
Include dependency graph for ros_sub_pub.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define MSG_CLASS1   sensor_msgs::Imu
 
#define MSG_CLASS2   geometry_msgs::Twist
 
#define MSG_CLASS3   std_msgs::String
 
#define MSG_TYPE1   "sensor_msgs/Imu"
 
#define MSG_TYPE2   "geometry_msgs/Twist"
 
#define MSG_TYPE3   "std_msgs/String"
 
#define SUB_MAX   50
 

Functions

template<typename T >
void deserialize_pub (uint8_t *buffer_ptr, size_t msg_size, int i)
 
void deserialize_publish (uint8_t *buffer_ptr, size_t msg_size, std::string msg_type, int i)
 
template<typename T >
ros::Subscriber nh_sub (std::string topic_name, ros::NodeHandle nh, int i)
 
template<typename T , int i>
void sub_cb (const T &msg)
 
ros::Publisher topic_publisher (std::string topic_name, std::string msg_type, ros::NodeHandle nh)
 
ros::Subscriber topic_subscriber (std::string topic_name, std::string msg_type, ros::NodeHandle nh, int i)
 

Variables

template<typename T >
void(* sub_callbacks [])(const T &)
 

Detailed Description

Header file for different ROS message type.

Author
Peixuan Shu (shupe.nosp@m.ixua.nosp@m.n@qq..nosp@m.com) Core Idea: modify the macros about MSG_TYPEx and MSG_CLASSx, it will generate template functions for different ros message types. Remember to add the dependent package in find_package() of ../CMakeLists.txt

Note: the sub_cb() and deserialize_pub() are only declared here, you should define them in you .cpp file according to your need.

Version
1.0
Date
2023-01-01

BSD 3-Clause License

Definition in file ros_sub_pub.hpp.

Macro Definition Documentation

◆ MSG_CLASS1

#define MSG_CLASS1   sensor_msgs::Imu

Definition at line 28 of file ros_sub_pub.hpp.

◆ MSG_CLASS2

#define MSG_CLASS2   geometry_msgs::Twist

Definition at line 32 of file ros_sub_pub.hpp.

◆ MSG_CLASS3

#define MSG_CLASS3   std_msgs::String

Definition at line 36 of file ros_sub_pub.hpp.

◆ MSG_TYPE1

#define MSG_TYPE1   "sensor_msgs/Imu"

Definition at line 27 of file ros_sub_pub.hpp.

◆ MSG_TYPE2

#define MSG_TYPE2   "geometry_msgs/Twist"

Definition at line 31 of file ros_sub_pub.hpp.

◆ MSG_TYPE3

#define MSG_TYPE3   "std_msgs/String"

Definition at line 35 of file ros_sub_pub.hpp.

◆ SUB_MAX

#define SUB_MAX   50

Definition at line 48 of file ros_sub_pub.hpp.

Function Documentation

◆ deserialize_pub()

template<typename T >
void deserialize_pub ( uint8_t *  buffer_ptr,
size_t  msg_size,
int  i 
)

Definition at line 100 of file bridge_node.cpp.

◆ deserialize_publish()

void deserialize_publish ( uint8_t *  buffer_ptr,
size_t  msg_size,
std::string  msg_type,
int  i 
)

Definition at line 182 of file ros_sub_pub.hpp.

◆ nh_sub()

template<typename T >
ros::Subscriber nh_sub ( std::string  topic_name,
ros::NodeHandle  nh,
int  i 
)

Definition at line 85 of file ros_sub_pub.hpp.

◆ sub_cb()

template<typename T , int i>
void sub_cb ( const T &  msg)

Definition at line 65 of file bridge_node.cpp.

◆ topic_publisher()

ros::Publisher topic_publisher ( std::string  topic_name,
std::string  msg_type,
ros::NodeHandle  nh 
)

Definition at line 136 of file ros_sub_pub.hpp.

◆ topic_subscriber()

ros::Subscriber topic_subscriber ( std::string  topic_name,
std::string  msg_type,
ros::NodeHandle  nh,
int  i 
)

Definition at line 90 of file ros_sub_pub.hpp.

Variable Documentation

◆ sub_callbacks

template<typename T >
void(* sub_callbacks[])(const T &)
Initial value:
=
{
sub_cb<T,0>, sub_cb<T,1>, sub_cb<T,2>, sub_cb<T,3>, sub_cb<T,4>,
sub_cb<T,5>, sub_cb<T,6>, sub_cb<T,7>, sub_cb<T,8>, sub_cb<T,9>,
sub_cb<T,10>, sub_cb<T,11>, sub_cb<T,12>, sub_cb<T,13>, sub_cb<T,14>,
sub_cb<T,15>, sub_cb<T,16>, sub_cb<T,17>, sub_cb<T,18>, sub_cb<T,19>,
sub_cb<T,20>, sub_cb<T,21>, sub_cb<T,22>, sub_cb<T,23>, sub_cb<T,24>,
sub_cb<T,25>, sub_cb<T,26>, sub_cb<T,27>, sub_cb<T,28>, sub_cb<T,29>,
sub_cb<T,30>, sub_cb<T,31>, sub_cb<T,32>, sub_cb<T,33>, sub_cb<T,34>,
sub_cb<T,35>, sub_cb<T,36>, sub_cb<T,37>, sub_cb<T,38>, sub_cb<T,39>,
sub_cb<T,40>, sub_cb<T,41>, sub_cb<T,42>, sub_cb<T,43>, sub_cb<T,44>,
sub_cb<T,45>, sub_cb<T,46>, sub_cb<T,47>, sub_cb<T,48>, sub_cb<T,49>
}

Definition at line 54 of file ros_sub_pub.hpp.



swarm_ros_bridge
Author(s):
autogenerated on Tue Feb 21 2023 03:43:52