cola_transmitter.h
Go to the documentation of this file.
1 #include "sick_scan/sick_scan_base.h" /* Base definitions included in all header files, added by add_sick_scan_base_header.py. Do not edit this line. */
2 /*
3  * @brief sim_loc_cola_transmitter connects to the localization controller, sends cola command requests,
4  * and waits for the response with timeout.
5  *
6  * Copyright (C) 2019 Ing.-Buero Dr. Michael Lehning, Hildesheim
7  * Copyright (C) 2019 SICK AG, Waldkirch
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  * http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  *
21  * All rights reserved.
22  *
23  * Redistribution and use in source and binary forms, with or without
24  * modification, are permitted provided that the following conditions are met:
25  *
26  * * Redistributions of source code must retain the above copyright
27  * notice, this list of conditions and the following disclaimer.
28  * * Redistributions in binary form must reproduce the above copyright
29  * notice, this list of conditions and the following disclaimer in the
30  * documentation and/or other materials provided with the distribution.
31  * * Neither the name of SICK AG nor the names of its
32  * contributors may be used to endorse or promote products derived from
33  * this software without specific prior written permission
34  * * Neither the name of Ing.-Buero Dr. Michael Lehning nor the names of its
35  * contributors may be used to endorse or promote products derived from
36  * this software without specific prior written permission
37  *
38  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
39  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
41  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
42  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
43  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
44  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
45  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
46  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
47  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
48  * POSSIBILITY OF SUCH DAMAGE.
49  *
50  * Authors:
51  * Michael Lehning <michael.lehning@lehning.de>
52  *
53  * Copyright 2019 SICK AG
54  * Copyright 2019 Ing.-Buero Dr. Michael Lehning
55  *
56  */
57 #ifndef __SIM_LOC_COLA_TRANSMITTER_H_INCLUDED
58 #define __SIM_LOC_COLA_TRANSMITTER_H_INCLUDED
59 
61 #include "sick_scan/fifo_buffer.h"
63 
64 namespace sick_scan_xd
65 {
71  {
72  public:
73 
80  ColaTransmitter(const std::string & server_address = "192.168.0.1", int tcp_port = 2111, double default_receive_timeout = 1);
81 
85  virtual ~ColaTransmitter();
86 
91  virtual bool connect(void);
92 
97  virtual bool close(void);
98 
105  virtual bool send(const std::vector<uint8_t> & data, ROS::Time & send_timestamp);
106 
114  static bool send(socket_t & socket, const std::vector<uint8_t> & data, ROS::Time & send_timestamp);
115 
123  virtual bool receive(std::vector<uint8_t> & telegram, double timeout, ROS::Time & receive_timestamp);
124 
133  static bool receive(socket_t & socket, std::vector<uint8_t> & telegram, double timeout,ROS::Time & receive_timestamp);
134 
140  virtual bool startReceiverThread(void);
141 
146  virtual bool stopReceiverThread(void);
147 
158  virtual bool waitPopResponse(std::vector<uint8_t> & telegram, double timeout, ROS::Time & receive_timestamp);
159 
160  protected:
161 
167  {
168  public:
169  ColaResponseContainer(const std::vector<uint8_t> & data = std::vector<uint8_t>(),const ROS::Time & timestamp = ROS::now())
171  std::vector<uint8_t> telegram_data;
173  };
174 
181  static bool dataEndWithETX(const std::vector<uint8_t> & data, const std::vector<uint8_t> & etx);
182 
186  void runReceiverThreadCb(void);
187 
188  /*
189  * member data
190  */
191 
192  std::string m_server_address;
197  std::thread* m_receiver_thread;
199 
200  }; // class ColaTransmitter
201 
202 } // namespace sick_scan_xd
203 #endif // __SIM_LOC_COLA_TRANSMITTER_H_INCLUDED
sick_scan_xd::ColaTransmitter::m_receiver_thread
std::thread * m_receiver_thread
thread to receive responses from localization server
Definition: cola_transmitter.h:197
sick_scan_xd::ClientSocket
Definition: client_socket.h:68
socket_t
int32_t socket_t
Definition: server_socket.h:70
sick_scan_xd::ColaTransmitter::runReceiverThreadCb
void runReceiverThreadCb(void)
Definition: cola_transmitter.cpp:317
sick_scan_xd
Definition: abstract_parser.cpp:65
data
data
sick_scan_xd::ColaTransmitter::ColaResponseContainer::receive_timestamp
ROS::Time receive_timestamp
receive timestamp in seconds (ros timestamp immediately after first response byte received)
Definition: cola_transmitter.h:172
sick_scan_xd::FifoBuffer
Definition: fifo_buffer.h:67
ROS::now
ROS::Time now(void)
Definition: ros_wrapper.cpp:116
client_socket.h
imu_delay_tester.timestamp
timestamp
Definition: imu_delay_tester.py:142
server_socket.h
sick_scan_xd::ColaTransmitter::m_receive_timeout
double m_receive_timeout
default timeout in seconds for receive functions
Definition: cola_transmitter.h:195
sick_scan_xd::ColaTransmitter::connect
virtual bool connect(void)
Definition: cola_transmitter.cpp:95
sick_scan_xd::ColaTransmitter::ColaTransmitter
ColaTransmitter(const std::string &server_address="192.168.0.1", int tcp_port=2111, double default_receive_timeout=1)
Definition: cola_transmitter.cpp:74
sick_scan_xd::ColaTransmitter::dataEndWithETX
static bool dataEndWithETX(const std::vector< uint8_t > &data, const std::vector< uint8_t > &etx)
Definition: cola_transmitter.cpp:243
sick_scan_xd::ColaTransmitter::m_tcp_socket
sick_scan_xd::ClientSocket m_tcp_socket
tcp socket connected to the localization controller
Definition: cola_transmitter.h:194
test_server.tcp_port
int tcp_port
Definition: test_server.py:204
multiscan_pcap_player.send_timestamp
int send_timestamp
Definition: multiscan_pcap_player.py:201
fifo_buffer.h
std_msgs::Time
::std_msgs::Time_< std::allocator< void > > Time
Definition: Time.h:48
sick_scan_xd::ColaTransmitter::m_receiver_thread_running
bool m_receiver_thread_running
true: m_receiver_thread is running, otherwise false
Definition: cola_transmitter.h:196
sick_scan_xd::ColaTransmitter::m_tcp_port
int m_tcp_port
tcp port of the localization controller, default: 2111 for command requests and 2112 for command resp...
Definition: cola_transmitter.h:193
sick_scan_xd::ColaTransmitter::m_server_address
std::string m_server_address
ip address of the localization controller, default: 192.168.0.1
Definition: cola_transmitter.h:192
sick_scan_xd::ColaTransmitter::stopReceiverThread
virtual bool stopReceiverThread(void)
Definition: cola_transmitter.cpp:272
sick_scan_xd::ColaTransmitter::send
virtual bool send(const std::vector< uint8_t > &data, ROS::Time &send_timestamp)
Definition: cola_transmitter.cpp:124
sick_scan_xd::ColaTransmitter::~ColaTransmitter
virtual ~ColaTransmitter()
Definition: cola_transmitter.cpp:84
sick_scan_xd::ColaTransmitter::waitPopResponse
virtual bool waitPopResponse(std::vector< uint8_t > &telegram, double timeout, ROS::Time &receive_timestamp)
Definition: cola_transmitter.cpp:294
sick_scan_xd::ColaTransmitter
Definition: cola_transmitter.h:70
sick_scan_base.h
sick_generic_device_finder.timeout
timeout
Definition: sick_generic_device_finder.py:113
sick_scan_xd::ColaTransmitter::receive
virtual bool receive(std::vector< uint8_t > &telegram, double timeout, ROS::Time &receive_timestamp)
Definition: cola_transmitter.cpp:164
sick_scan_xd::ColaTransmitter::m_response_fifo
sick_scan_xd::FifoBuffer< ColaResponseContainer, std::mutex > m_response_fifo
fifo buffer for receiver thread for responses from localization server
Definition: cola_transmitter.h:198
sick_scan_xd::ColaTransmitter::startReceiverThread
virtual bool startReceiverThread(void)
Definition: cola_transmitter.cpp:260
sick_scan_xd::ColaTransmitter::ColaResponseContainer::telegram_data
std::vector< uint8_t > telegram_data
received telegram_data (Cola-Ascii or Cola-Binary)
Definition: cola_transmitter.h:171
sick_scan_xd::ColaTransmitter::ColaResponseContainer
Definition: cola_transmitter.h:166
sick_scan_xd::ColaTransmitter::close
virtual bool close(void)
Definition: cola_transmitter.cpp:104


sick_scan_xd
Author(s): Michael Lehning , Jochen Sprickerhof , Martin Günther
autogenerated on Fri Oct 25 2024 02:47:07