os32c.h
Go to the documentation of this file.
1 
26 #ifndef OMRON_OS32C_DRIVER_OS32C_H
27 #define OMRON_OS32C_DRIVER_OS32C_H
28 
29 #include <gtest/gtest_prod.h>
30 #include <string>
31 #include <vector>
32 #include <boost/shared_ptr.hpp>
33 #include <sensor_msgs/LaserScan.h>
34 
40 
41 using std::vector;
42 using boost::shared_ptr;
43 using sensor_msgs::LaserScan;
44 using eip::Session;
46 
47 #define DEG2RAD(a) (a * M_PI / 180)
48 #define RAD2DEG(a) (a * 180 / M_PI)
49 
50 namespace omron_os32c_driver {
51 
52 
53 typedef enum
54 {
62 
63 typedef enum
64 {
69 
75 class OS32C : public Session
76 {
77 public:
83  : Session(socket, io_socket)
86  , connection_num_(-1)
88  {
89  }
90 
91  static const double ANGLE_MIN;
92  static const double ANGLE_MAX;
93  static const double ANGLE_INC;
94  static const double DISTANCE_MIN;
95  static const double DISTANCE_MAX;
96 
104 
111  void setRangeFormat(EIP_UINT format);
112 
120 
127  void setReflectivityFormat(EIP_UINT format);
128 
129 
137  void selectBeams(double start_angle, double end_angle);
138 
145 
157  static inline int calcBeamNumber(double angle)
158  {
159  return (ANGLE_MAX - angle + ANGLE_INC / 2) / ANGLE_INC;
160  }
161 
168  static inline double calcBeamCentre(int beam_num)
169  {
170  return ANGLE_MAX - beam_num * ANGLE_INC;
171  }
172 
178  void fillLaserScanStaticConfig(sensor_msgs::LaserScan* ls);
179 
187  static void convertToLaserScan(const RangeAndReflectanceMeasurement& rr, sensor_msgs::LaserScan* ls);
188 
194  static void convertToLaserScan(const MeasurementReport& mr, sensor_msgs::LaserScan* ls);
195 
197 
199 
200  void startUDPIO();
201 
202  void closeActiveConnection();
203 
204 private:
205  // allow unit tests to access the helpers below for direct testing
206  FRIEND_TEST(OS32CTest, test_calc_beam_mask_all);
207  FRIEND_TEST(OS32CTest, test_calc_beam_at_90);
208  FRIEND_TEST(OS32CTest, test_calc_beam_boundaries);
209  FRIEND_TEST(OS32CTest, test_calc_beam_invalid_args);
210  FRIEND_TEST(OS32CTest, test_convert_to_laserscan);
211 
212  double start_angle_;
213  double end_angle_;
214 
215  // data for sending to lidar to keep UDP session alive
219 
226  void calcBeamMask(double start_angle, double end_angle, EIP_BYTE mask[]);
227 };
228 
229 } // namespace omron_os32c_driver
230 
231 #endif // OMRON_OS32C_DRIVER_OS32C_H
omron_os32c_driver::RangeAndReflectanceMeasurement
Definition: range_and_reflectance_measurement.h:50
omron_os32c_driver::OS32C::ANGLE_INC
static const double ANGLE_INC
Definition: os32c.h:93
omron_os32c_driver::RANGE_MEASURE_TOF_4PS
@ RANGE_MEASURE_TOF_4PS
Definition: os32c.h:60
omron_os32c_driver::OS32C::connection_num_
int connection_num_
Definition: os32c.h:216
eip::Session
boost::shared_ptr
EIP_BYTE
uint8_t EIP_BYTE
omron_os32c_driver::OS32C::getReflectivityFormat
EIP_UINT getReflectivityFormat()
Definition: os32c.cpp:73
omron_os32c_driver::OS32CTest
Definition: os32c_test.cpp:45
omron_os32c_driver::NO_TOF_MEASUREMENTS
@ NO_TOF_MEASUREMENTS
Definition: os32c.h:55
EIP_UINT
uint16_t EIP_UINT
omron_os32c_driver::REFLECTIVITY_MEASURE_TOT_4PS
@ REFLECTIVITY_MEASURE_TOT_4PS
Definition: os32c.h:67
omron_os32c_driver::OS32C::mrc_
MeasurementReportConfig mrc_
Definition: os32c.h:217
omron_os32c_driver::OS32C::getRangeFormat
EIP_UINT getRangeFormat()
Definition: os32c.cpp:61
omron_os32c_driver::RANGE_MEASURE_16M_WZ1PZ
@ RANGE_MEASURE_16M_WZ1PZ
Definition: os32c.h:58
omron_os32c_driver::OS32C::FRIEND_TEST
FRIEND_TEST(OS32CTest, test_calc_beam_mask_all)
omron_os32c_driver::OS32C::receiveMeasurementReportUDP
MeasurementReport receiveMeasurementReportUDP()
Definition: os32c.cpp:244
omron_os32c_driver::OS32C::closeActiveConnection
void closeActiveConnection()
Definition: os32c.cpp:275
omron_os32c_driver::OS32C::startUDPIO
void startUDPIO()
Definition: os32c.cpp:261
omron_os32c_driver::OS32C::DISTANCE_MAX
static const double DISTANCE_MAX
Definition: os32c.h:95
omron_os32c_driver::OS32C::mrc_sequence_num_
EIP_UDINT mrc_sequence_num_
Definition: os32c.h:218
omron_os32c_driver::OS32C::convertToLaserScan
static void convertToLaserScan(const RangeAndReflectanceMeasurement &rr, sensor_msgs::LaserScan *ls)
Definition: os32c.cpp:161
omron_os32c_driver::OS32C_REFLECTIVITY_FORMAT
OS32C_REFLECTIVITY_FORMAT
Definition: os32c.h:63
omron_os32c_driver::MeasurementReportConfig
Definition: measurement_report_config.h:47
omron_os32c_driver::OS32C::getSingleRRScan
RangeAndReflectanceMeasurement getSingleRRScan()
Definition: os32c.cpp:145
omron_os32c_driver::OS32C::end_angle_
double end_angle_
Definition: os32c.h:213
omron_os32c_driver
Definition: measurement_report.h:43
omron_os32c_driver::RANGE_MEASURE_8M_WZ2WZ1PZ
@ RANGE_MEASURE_8M_WZ2WZ1PZ
Definition: os32c.h:59
omron_os32c_driver::OS32C::OS32C
OS32C(shared_ptr< Socket > socket, shared_ptr< Socket > io_socket)
Definition: os32c.h:82
omron_os32c_driver::OS32C::calcBeamCentre
static double calcBeamCentre(int beam_num)
Definition: os32c.h:168
omron_os32c_driver::MeasurementReport
Definition: measurement_report.h:50
omron_os32c_driver::OS32C::setReflectivityFormat
void setReflectivityFormat(EIP_UINT format)
Definition: os32c.cpp:79
omron_os32c_driver::OS32C::sendMeasurmentReportConfigUDP
void sendMeasurmentReportConfigUDP()
Definition: os32c.cpp:231
omron_os32c_driver::OS32C::ANGLE_MIN
static const double ANGLE_MIN
Definition: os32c.h:91
omron_os32c_driver::RANGE_MEASURE_50M
@ RANGE_MEASURE_50M
Definition: os32c.h:56
omron_os32c_driver::OS32C::calcBeamNumber
static int calcBeamNumber(double angle)
Definition: os32c.h:157
omron_os32c_driver::OS32C::DISTANCE_MIN
static const double DISTANCE_MIN
Definition: os32c.h:94
session.h
omron_os32c_driver::OS32C
Definition: os32c.h:75
omron_os32c_driver::OS32C::start_angle_
double start_angle_
Definition: os32c.h:212
omron_os32c_driver::OS32C::selectBeams
void selectBeams(double start_angle, double end_angle)
Definition: os32c.cpp:138
omron_os32c_driver::RANGE_MEASURE_32M_PZ
@ RANGE_MEASURE_32M_PZ
Definition: os32c.h:57
omron_os32c_driver::REFLECTIVITY_MEASURE_TOT_ENCODED
@ REFLECTIVITY_MEASURE_TOT_ENCODED
Definition: os32c.h:66
omron_os32c_driver::OS32C::setRangeFormat
void setRangeFormat(EIP_UINT format)
Definition: os32c.cpp:67
omron_os32c_driver::OS32C_RANGE_FORMAT
OS32C_RANGE_FORMAT
Definition: os32c.h:53
omron_os32c_driver::OS32C::calcBeamMask
void calcBeamMask(double start_angle, double end_angle, EIP_BYTE mask[])
Definition: os32c.cpp:85
omron_os32c_driver::NO_TOT_MEASUREMENTS
@ NO_TOT_MEASUREMENTS
Definition: os32c.h:65
omron_os32c_driver::OS32C::ANGLE_MAX
static const double ANGLE_MAX
Definition: os32c.h:92
socket.h
range_and_reflectance_measurement.h
measurement_report_config.h
eip::socket::Socket
EIP_UDINT
uint32_t EIP_UDINT
omron_os32c_driver::OS32C::fillLaserScanStaticConfig
void fillLaserScanStaticConfig(sensor_msgs::LaserScan *ls)
Definition: os32c.cpp:152
measurement_report.h


omron_os32c_driver
Author(s): Kareem Shehata
autogenerated on Wed Mar 2 2022 00:39:14