motor_serial.h
Go to the documentation of this file.
1 
31 #ifndef MOTORSERIAL_H
32 #define MOTORSERIAL_H
33 
34 #include <ros/ros.h>
35 #include <serial/serial.h>
38 #include <boost/thread.hpp>
39 #include <queue>
40 
41 #include <gtest/gtest_prod.h>
42 
43 class MotorSerial {
44 public:
45  MotorSerial(const std::string& port = "/dev/ttyUSB0",
46  uint32_t baud_rate = 9600);
47  ~MotorSerial();
48 
50  int transmitCommands(const std::vector<MotorMessage>& commands);
51 
53  int commandAvailable();
54 
55  MotorSerial(MotorSerial const&) = delete;
56  MotorSerial& operator=(MotorSerial const&) = delete;
57 
58 private:
59  serial::Serial motors;
60 
62 
63  boost::thread serial_thread;
64 
65  void appendOutput(MotorMessage command);
66 
69 
70  // Thread that has manages serial reads
71  void SerialThread();
72 
73  FRIEND_TEST(MotorSerialTests, serialClosedOnInterupt);
74 };
75 
76 #endif
FRIEND_TEST(MotorSerialTests, serialClosedOnInterupt)
int transmitCommand(MotorMessage command)
Definition: motor_serial.cc:47
MotorSerial & operator=(MotorSerial const &)=delete
int transmitCommands(const std::vector< MotorMessage > &commands)
Definition: motor_serial.cc:55
serial::Serial motors
Definition: motor_serial.h:59
int commandAvailable()
Definition: motor_serial.cc:74
int error_threshold
Definition: motor_serial.h:68
ROSLIB_DECL std::string command(const std::string &cmd)
MotorSerial(const std::string &port="/dev/ttyUSB0", uint32_t baud_rate=9600)
Definition: motor_serial.cc:35
boost::thread serial_thread
Definition: motor_serial.h:63
shared_queue< MotorMessage > output
Definition: motor_serial.h:61
MotorMessage receiveCommand()
Definition: motor_serial.cc:66
void appendOutput(MotorMessage command)
Definition: motor_serial.cc:76
int serial_errors
Definition: motor_serial.h:67
void SerialThread()
Definition: motor_serial.cc:78


ubiquity_motor
Author(s):
autogenerated on Mon Feb 28 2022 23:57:06