38 int result = inet_pton(AF_INET, ipAddress, &(sa.sin_addr));
54 const uint32_t& host_ip,
55 const uint32_t& host_udp_port,
56 const std::string& password,
59 std::unique_ptr<ScannerCommunicationInterface> communication_interface)
60 : scanner_ip_(scanner_ip)
61 , start_monitoring_frame_(password, host_ip, host_udp_port)
62 , stop_monitoring_frame_(password)
63 , angle_start_(angle_start)
64 , angle_end_(angle_end)
65 , previous_monitoring_frame_({})
73 if (host_udp_port > 65535)
78 if (host_udp_port < 1024)
80 std::cout <<
"Attention: UDP Port is in IANA Standard Port range (below 1024)! " 81 <<
"Please consider using a port number above 1024." << std::endl;
84 if (angle_start >= angle_end)
130 std::size_t bytes_received;
131 auto buf = boost::asio::buffer(&monitoring_frame,
sizeof(
MonitoringFrame));
147 return monitoring_frame;
170 std::string err =
"MonitoringFrame's ScannerID doesn't belong to master! \n";
171 err.append(
"Please contact the maintainer if you need master+slave functionality!");
311 bool firstrun =
true;
315 bool exception_occured =
false;
318 exception_occured =
false;
327 std::cerr << e.what() <<
'\n';
328 exception_occured =
true;
331 }
while (exception_occured);
381 if (begin_position > 0)
387 auto end_position =
static_cast<int>(temp_max_scan_angle -
angle_end_) / static_cast<int>(scan.
resolution_);
388 if (end_position > 0)
DiagnosticInformation diagnostic_information_
Frame containing all necessary fields for a Start Monitoring Command.
std::array< uint16_t, 550 > measures_
MonitoringFrame as coming from Laserscanner.
StopMonitoringFrame stop_monitoring_frame_
LaserScan getCompleteScan()
Reads from UDP Interface until complete laserscan object can be formed.
void start()
Send start signal to Laserscanner.
uint16_t const MAX_NUMBER_OF_SAMPLES
PSENscanInternalAngle const MAX_SCAN_ANGLE(2750)
MonitoringFrame fetchMonitoringFrame(std::chrono::steady_clock::duration timeout)
Gets one MonitoringFrame from Laserscanner.
Class to hold the data for one laserscan without depencies to ROS.
bool isDiagnosticInformationOk(const DiagnosticInformation &diag_info)
Checks if DiagnosticInformation Bitfield contains no errors.
uint32_t const MONITORING_FRAME_OPCODE
MonitoringFrame previous_monitoring_frame_
bool isValidIpAddress(const char *ipAddress)
static std::chrono::steady_clock::duration adjustTimeout(const std::chrono::steady_clock::duration &timeout, const std::chrono::steady_clock::duration timeout_increase=DEFAULT_TIMEOUT_INCREASE, const std::chrono::steady_clock::duration max_timeout=DEFAULT_MAX_TIMEOUT)
Increases the given timeout by the specified timeout increase. If the new timeout exceeds the max tim...
DiagnosticArea diagnostic_area_
constexpr std::chrono::seconds MIN_FETCH_FRAME_TIMEOUT
std::vector< uint16_t > measures_
bool parseFields(const MonitoringFrame &monitoring_frame)
Parses a MonitoringFrame to check whether all fields are as expected.
Frame containing all necessary fields for a Stop Monitoring Command.
PSENscanInternalAngle const MIN_SCAN_ANGLE(0)
PSENscanInternalAngle angle_end_
PSENscanInternalAngle resolution_
PSENscanInternalAngle to_theta() const
Class to model angles in PSENscan internal format (tenth of degrees)
TFSIMD_FORCE_INLINE tfScalar length(const Quaternion &q)
uint16_t number_of_samples_
PSENscanInternalAngle angle_start_
StartMonitoringFrame start_monitoring_frame_
Scanner(const std::string &scanner_ip, const uint32_t &host_ip, const uint32_t &host_udp_port, const std::string &password, const PSENscanInternalAngle &angle_start, const PSENscanInternalAngle &angle_end, std::unique_ptr< ScannerCommunicationInterface > communication_interface)
Construct a new Scanner:: Scanner object.
void stop()
Send stop signal to Laserscanner.
std::unique_ptr< ScannerCommunicationInterface > communication_interface_