lms400_cola.h
1/*
2 * Player - One Hell of a Robot Server
3 * Copyright (C) 2007
4 * Nico Blodow and Radu Bogdan Rusu
5 *
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22/*
23 Desc: Driver for the SICK LMS400 unit
24 Author: Nico Blodow and Radu Bogdan Rusu
25 Date: 7 Feb 2007
26 CVS: $Id$
27*/
28
29#include "config.h"
30
31#include <netdb.h>
32#include <sys/types.h>
33#include <vector>
34#include <netinet/in.h>
35#include <libplayerinterface/player.h>
36#include <iostream>
37
38#define BUF_SIZE 1024
39
41typedef struct
42{
43 unsigned char* string;
44 int length;
46
48typedef struct
49{
50 uint16_t Format;
51 uint16_t DistanceScaling;
52 int32_t StartingAngle;
53 uint16_t AngularStepWidth;
54 uint16_t NumberMeasuredValues;
55 uint16_t ScanningFrequency;
56 uint16_t RemissionScaling;
57 uint16_t RemissionStartValue;
58 uint16_t RemissionEndValue;
60
61
64{
65 public:
66 lms400_cola (const char* host, int port, int debug_mode);
67
68 // Creates socket, connects
69 int Connect ();
70 int Disconnect ();
71
72 // Configuration parameters
73 int SetAngularResolution (const char* password, float ang_res, float angle_start, float angle_range);
74 int SetScanningFrequency (const char* password, float freq, float angle_start, float angle_range);
75 int SetResolutionAndFrequency (float freq, float ang_res, float angle_start, float angle_range);
76
77 int StartMeasurement (bool intensity = true);
78 player_laser_data ReadMeasurement ();
79 int StopMeasurement ();
80
81 int SetUserLevel (int8_t userlevel, const char* password);
82 int GetMACAddress (char** macadress);
83
84 int SetIP (char* ip);
85 int SetGateway (char* gw);
86 int SetNetmask (char* mask);
87 int SetPort (uint16_t port);
88
89 int ResetDevice ();
90 int TerminateConfiguration ();
91
92 int SendCommand (const char* cmd);
93 int ReadResult ();
94 // for "Variables", Commands that only reply with one Answer message
95 int ReadAnswer ();
96 // for "Procedures", Commands that reply with a Confirmation message and an Answer message
97 int ReadConfirmationAndAnswer ();
98
99 int EnableRIS (int onoff);
100 player_laser_config GetConfiguration ();
101 int SetMeanFilterParameters (int num_scans);
102 int SetRangeFilterParameters (float *ranges);
103 int EnableFilters (int filter_mask);
104
105 // turns a string holding an ip address into long
106 unsigned char* ParseIP (char* ip);
107
108 private:
109 // assembles STX's, length field, message, checksum ready to be sent. Cool.
110 int assemblecommand (unsigned char* command, int len);
111
112 const char* hostname;
113 int sockfd, portno, n;
114 struct sockaddr_in serv_addr;
115#if HAVE_GETADDRINFO
116 struct addrinfo *addr_ptr;
117#else
118 struct hostent *server;
119#endif
120
121 // Internal Parameters:
122 int verbose;
123 int ExtendedRIS;
124 int MeanFilterNumScans;
125 float RangeFilterTopLimit;
126 float RangeFilterBottomLimit;
127 int FilterMask;
128 player_laser_config Configuration;
129
130 // for reading:
131 unsigned char buffer[4096];
132 unsigned int bufferlength;
133
134 // for sending:
135 unsigned char command[BUF_SIZE];
136 int commandlength;
137 std::vector<MeasurementQueueElement_t>* MeasurementQueue;
138};
Definition lms400_cola.h:64
Definition lms400_cola.h:49
Definition lms400_cola.h:42