Basic Mid-Level control for the rebuilt MorphGI control unit, using PWM to communicate with the low level controllers.
Dependencies: ros_lib_kinetic
HLComms.h
- Committer:
- dofydoink
- Date:
- 2021-06-24
- Revision:
- 42:5a5ad23a4bb1
- Parent:
- 37:37da606f4466
File content as of revision 42:5a5ad23a4bb1:
// HLComms.h
#ifndef HLCOMMS_H
#define HLCOMMS_H
// STANDARD IMPORTS
#include "math.h"
#include <algorithm>
#include <limits>
// MBED IMPORTS
#include"mbed.h"
#include "mbed_events.h"
// ROS IMPORTS
#include <ros.h>
#include <std_msgs/String.h>
#include <std_msgs/Float32.h>
#include <std_msgs/Int16MultiArray.h>
#include <std_msgs/Float32MultiArray.h>
#include "std_msgs/MultiArrayLayout.h"
#include "std_msgs/MultiArrayDimension.h"
// CUSTOM IMPORTS
#include "MLSettings.h"
struct demands_struct {
double psi_mm[N_CHANNELS];
double speeds_mmps[3];
bool utitilies_bool[4];
};
class HLComms
{
public:
Semaphore newData;
HLComms(unsigned short int freq_hz);
//~HLComms(void);
demands_struct get_demands(void);
void send_text_message(char text[]);
void send_durations_message(double dblTimes[]);
void send_sensor_message(unsigned int positions[], unsigned int pressures[]);
private:
unsigned short int _freq_hz;
struct demands_struct _input;
Thread _threadROS;
Semaphore _rosReady;
Semaphore _semSpin;
ros::NodeHandle _nh;
ros::Publisher* _text_pub;
std_msgs::String _text_msg;
std_msgs::Int16MultiArray _sensor_msg;
ros::Publisher* _sensor_pub;
std_msgs::Float32MultiArray _durations_msg;
ros::Publisher* _durations_pub;
Mutex recv_mutex;
void ros_main(void);
void releaseSemSpin(void);
void receive_demands(const std_msgs::Float32MultiArray &demands_array);
};
#endif