-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrosserialInterface.h
47 lines (39 loc) · 1.02 KB
/
rosserialInterface.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/**************************************
* Title : rosserialInterface.h
* Author : Ian Gagnon
* Created : 2021-05-05
*************************************/
#ifndef ROSSERIAL_INTERFACE_H
#define ROSSERIAL_INTERFACE_H
#include <ros.h>
#include <std_msgs/Float32MultiArray.h>
#define N_DATA_TO_PUBLISH 6
#define N_DATA_TO_RECEIVE 6
class ROSserialInterface
/**
* @brief Serial interface to communicate with ROS
* Creates 1 publisher and 1 subscriber
*/
{
public:
// CTOR & DTOR
ROSserialInterface();
~ROSserialInterface();
// Methods
void setup();
void callback(const std_msgs::Float32MultiArray& msg);
bool newCommandReceived();
float* getCommand();
void publish(float* arrayToPublish);
void main();
private:
// ROS objects
ros::NodeHandle nh_;
ros::Subscriber<std_msgs::Float32MultiArray, ROSserialInterface> sub_;
ros::Publisher pub_;
// Attributes
std_msgs::Float32MultiArray msg_;
float steps_[N_DATA_TO_RECEIVE]= {0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
bool newCommandReceived_ = false;
};
#endif