#include <test_server_thread.h>
Classes | |
class | ServerColaRequest |
Public Member Functions | |
void | messageCbResultPortTelegrams (const sick_scan::SickLocResultPortTelegramMsg &msg) |
virtual void | messageCbResultPortTelegramsROS2 (const std::shared_ptr< sick_scan::SickLocResultPortTelegramMsg > msg) |
virtual bool | start (void) |
virtual bool | stop (void) |
TestServerThread (ROS::NodePtr nh=0, int ip_port_results=2201, int ip_port_cola=2111) | |
virtual | ~TestServerThread () |
Protected Types | |
enum | ERROR_SIMULATION_ENUM { NO_ERROR = 0, DONT_LISTEN, DONT_ACCECPT, DONT_SEND, SEND_RANDOM_TCP, SEND_INVALID_TELEGRAMS } |
< enumerates testcases for simulation of communication errors More... | |
typedef enum sick_scan::TestServerThread::ERROR_SIMULATION_ENUM | ERROR_SIMULATION_FLAG |
< enumerates testcases for simulation of communication errors More... | |
typedef boost::asio::ip::tcp::socket * | socket_ptr |
shortcut for pointer to boost::asio::ip::tcp::socket More... | |
typedef boost::thread * | thread_ptr |
shortcut for pointer to boost::thread More... | |
Protected Member Functions | |
void | closeScandataThread (void) |
void | closeSocket (socket_ptr &p_socket) |
virtual void | closeTcpConnections (bool force_shutdown=false) |
void | closeWorkerThreads (void) |
void | errorSimulationWait (double seconds) |
bool | errorSimulationWaitForTelegramReceived (double timeout_seconds, sick_scan::SickLocResultPortTelegramMsg &telegram_msg) |
virtual void | runConnectionThreadColaCb (void) |
template<typename Callable > | |
void | runConnectionThreadGenericCb (boost::asio::ip::tcp::acceptor &tcp_acceptor_results, int ip_port_results, Callable thread_function_cb) |
virtual void | runConnectionThreadResultCb (void) |
virtual void | runErrorSimulationThreadCb (void) |
virtual void | runWorkerThreadColaCb (boost::asio::ip::tcp::socket *p_socket) |
virtual void | runWorkerThreadResultCb (boost::asio::ip::tcp::socket *p_socket) |
virtual void | runWorkerThreadScandataCb (boost::asio::ip::tcp::socket *p_socket) |
Protected Attributes | |
bool | m_demo_move_in_circles |
true: simulate a sensor moving in circles, false (default): create random based result port telegrams More... | |
bool | m_error_simulation_enabled |
default: false (no error simulation), if true, test server simulates errors and communication failures of type ERROR_SIMULATION_FLAG More... | |
sick_scan::SetGet< ERROR_SIMULATION_FLAG > | m_error_simulation_flag |
current error simulation flag, default: NO_ERROR More... | |
thread_ptr | m_error_simulation_thread |
thread to run error simulation, switches m_error_simulation_flag through the error test cases More... | |
bool | m_error_simulation_thread_running |
true: m_error_simulation_thread is running, otherwise false More... | |
boost::asio::io_service | m_ioservice |
boost io service for tcp connections More... | |
int | m_ip_port_cola |
ip port for for command requests and responses, default: The localization controller uses IP port number 2111 and 2112 to send telegrams and to request data More... | |
int | m_ip_port_results |
ip port for result telegrams, default: The localization controller uses IP port number 2201 to send localization results More... | |
sick_scan::SetGet< sick_scan::SickLocResultPortTelegramMsg > | m_last_telegram_received |
last telegram message received from sick_scan driver More... | |
double | m_result_telegram_rate |
frequency to generate and send result port telegrams, default: 10 Hz More... | |
std::string | m_result_testcases_frame_id |
ros frame id of testcase messages (type SickLocResultPortTestcaseMsg), default: "result_testcases" More... | |
sick_scan::SickLocResultPortTestcaseMsgPublisher | m_result_testcases_publisher |
ros publisher for testcases with result port telegrams (type SickLocResultPortTestcaseMsg) More... | |
std::string | m_scandatafiles |
comma separated list of jsonfiles to emulate scandata messages, f.e. "tim781s_scandata.pcapng.json,tim781s_sopas.pcapng.json" More... | |
std::string | m_scandatatypes |
comma separated list of scandata message types, f.e. "sSN LMDscandata,sSN LMDscandatamon" More... | |
std::string | m_scanner_type |
currently supported: "sick_lms_5xx", "sick_tim_7xx" More... | |
double | m_start_scandata_delay |
delay between scandata activation ("LMCstartmeas" request) and first scandata message, default: 1 second More... | |
boost::asio::ip::tcp::acceptor | m_tcp_acceptor_cola |
boost acceptor for tcp clients for command requests and responses More... | |
boost::asio::ip::tcp::acceptor | m_tcp_acceptor_results |
boost acceptor for tcp clients for result telegrams More... | |
thread_ptr | m_tcp_connection_thread_cola |
thread to accept tcp clients for command requests and responses More... | |
thread_ptr | m_tcp_connection_thread_results |
thread to accept tcp clients for result port telegrams More... | |
bool | m_tcp_connection_thread_running |
true: m_tcp_connection_thread is running, otherwise false More... | |
thread_ptr | m_tcp_send_scandata_thread |
thread to send scandata and scandatamon tcp messages More... | |
bool | m_tcp_send_scandata_thread_running |
true: m_tcp_send_scandata_thread is running, otherwise false More... | |
std::list< boost::asio::ip::tcp::socket * > | m_tcp_sockets |
list of tcp sockets (one socket for each tcp client) More... | |
std::list< thread_ptr > | m_tcp_worker_threads |
list of tcp worker thread (one thread for each tcp client, generating telegrams) More... | |
boost::mutex | m_tcp_worker_threads_mutex |
mutex to protect m_tcp_worker_threads More... | |
bool | m_worker_thread_running |
true: worker threads started, otherwise false More... | |
class TestServerThread runs a thread to listen and accept tcp connections from clients and generates telegrams to test the ros driver for sim localization.
Definition at line 80 of file test_server_thread.h.
|
protected |
< enumerates testcases for simulation of communication errors
|
protected |
shortcut for pointer to boost::asio::ip::tcp::socket
Definition at line 132 of file test_server_thread.h.
|
protected |
shortcut for pointer to boost::thread
Definition at line 131 of file test_server_thread.h.
|
protected |
< enumerates testcases for simulation of communication errors
Definition at line 247 of file test_server_thread.h.
sick_scan::TestServerThread::TestServerThread | ( | ROS::NodePtr | nh = 0 , |
int | ip_port_results = 2201 , |
||
int | ip_port_cola = 2111 |
||
) |
Constructor. The server thread does not start automatically, call start() and stop() to start and stop the server.
[in] | nh | ros node handle |
[in] | ip_port_results | ip port for result telegrams, default: 2201 |
[in] | ip_port_cola | ip port for command requests and responses, default: 2111 |
Definition at line 74 of file test_server_thread.cpp.
|
virtual |
Destructor. Stops the server thread and closes all tcp connections.
Definition at line 113 of file test_server_thread.cpp.
|
protected |
Closes the send scandata thread
Definition at line 197 of file test_server_thread.cpp.
|
protected |
Closes a socket.
[in,out] | p_socket | socket to be closed |
Definition at line 238 of file test_server_thread.cpp.
|
protectedvirtual |
Closes all tcp connections
[in] | force_shutdown | if true, sockets are immediately forced to shutdown |
Definition at line 212 of file test_server_thread.cpp.
|
protected |
Stops all worker threads
Definition at line 269 of file test_server_thread.cpp.
|
protected |
Waits for a given time in seconds, as long as ROS::ok() and m_error_simulation_thread_running == true.
[in] | seconds | delay in seconds |
Definition at line 618 of file test_server_thread.cpp.
|
protected |
Waits for and returns the next telegram message from sick_scan driver.
[in] | timeout_seconds | wait timeout in seconds |
[out] | telegram_msg | last telegram message received |
Definition at line 633 of file test_server_thread.cpp.
void sick_scan::TestServerThread::messageCbResultPortTelegrams | ( | const sick_scan::SickLocResultPortTelegramMsg & | msg | ) |
Callback for result telegram messages (SickLocResultPortTelegramMsg) from sim_loc_driver. Buffers the last telegram to monitor sim_loc_driver messages in error simulation mode.
[in] | msg | result telegram message (SickLocResultPortTelegramMsg) |
Definition at line 287 of file test_server_thread.cpp.
|
inlinevirtual |
ROS2 version of function messageCbResultPortTelegrams
Definition at line 116 of file test_server_thread.h.
|
protectedvirtual |
Thread callback, listens and accept tcp connections from clients for cola telegrams. Starts a new worker thread to receive command requests for each tcp client.
Definition at line 305 of file test_server_thread.cpp.
|
protected |
Generic thread callback, listens and accept tcp connections from clients. Starts a worker thread running thread_function_cb for each tcp client.
Thread callback, listens and accept tcp connections from clients. Starts a worker thread for each tcp client.
Definition at line 314 of file test_server_thread.cpp.
|
protectedvirtual |
Thread callback, listens and accept tcp connections from clients for result telegrams. Starts a new worker thread to generate result port telegrams for each tcp client.
Definition at line 296 of file test_server_thread.cpp.
|
protectedvirtual |
Thread callback, runs an error simulation and switches m_error_simulation_flag through the error test cases.
Definition at line 651 of file test_server_thread.cpp.
|
protectedvirtual |
Worker thread callback, receives command requests from a tcp client and sends a synthetical command response. There's one request worker thread for each tcp client.
[in] | p_socket | socket to receive command requests from the tcp client |
Definition at line 441 of file test_server_thread.cpp.
|
protectedvirtual |
Worker thread callback, generates and sends result telegrams to a tcp client. There's one result worker thread for each tcp client.
[in] | p_socket | socket to send result telegrams to the tcp client |
Definition at line 366 of file test_server_thread.cpp.
|
protectedvirtual |
Worker thread callback, sends scandata and scandatamon messages to the tcp client. Reads scandata and scandatamon messages from jsonfile and sends the messages in a loop while m_tcp_send_scandata_thread_running is true.
[in] | p_socket | socket to sends scandata and scandatamon messages the tcp client |
Definition at line 535 of file test_server_thread.cpp.
|
virtual |
Starts the server thread, starts to listen and accept tcp connections from clients.
Definition at line 122 of file test_server_thread.cpp.
|
virtual |
Stops the server thread and closes all tcp connections.
Definition at line 151 of file test_server_thread.cpp.
|
protected |
true: simulate a sensor moving in circles, false (default): create random based result port telegrams
Definition at line 238 of file test_server_thread.h.
|
protected |
default: false (no error simulation), if true, test server simulates errors and communication failures of type ERROR_SIMULATION_FLAG
Definition at line 258 of file test_server_thread.h.
|
protected |
current error simulation flag, default: NO_ERROR
Definition at line 257 of file test_server_thread.h.
|
protected |
thread to run error simulation, switches m_error_simulation_flag through the error test cases
Definition at line 259 of file test_server_thread.h.
|
protected |
true: m_error_simulation_thread is running, otherwise false
Definition at line 260 of file test_server_thread.h.
|
protected |
boost io service for tcp connections
Definition at line 229 of file test_server_thread.h.
|
protected |
ip port for for command requests and responses, default: The localization controller uses IP port number 2111 and 2112 to send telegrams and to request data
Definition at line 221 of file test_server_thread.h.
|
protected |
ip port for result telegrams, default: The localization controller uses IP port number 2201 to send localization results
Definition at line 220 of file test_server_thread.h.
|
protected |
last telegram message received from sick_scan driver
Definition at line 261 of file test_server_thread.h.
|
protected |
frequency to generate and send result port telegrams, default: 10 Hz
Definition at line 222 of file test_server_thread.h.
|
protected |
ros frame id of testcase messages (type SickLocResultPortTestcaseMsg), default: "result_testcases"
Definition at line 237 of file test_server_thread.h.
|
protected |
ros publisher for testcases with result port telegrams (type SickLocResultPortTestcaseMsg)
Definition at line 236 of file test_server_thread.h.
|
protected |
comma separated list of jsonfiles to emulate scandata messages, f.e. "tim781s_scandata.pcapng.json,tim781s_sopas.pcapng.json"
Definition at line 239 of file test_server_thread.h.
|
protected |
comma separated list of scandata message types, f.e. "sSN LMDscandata,sSN LMDscandatamon"
Definition at line 240 of file test_server_thread.h.
|
protected |
currently supported: "sick_lms_5xx", "sick_tim_7xx"
Definition at line 241 of file test_server_thread.h.
|
protected |
delay between scandata activation ("LMCstartmeas" request) and first scandata message, default: 1 second
Definition at line 227 of file test_server_thread.h.
|
protected |
boost acceptor for tcp clients for command requests and responses
Definition at line 231 of file test_server_thread.h.
|
protected |
boost acceptor for tcp clients for result telegrams
Definition at line 230 of file test_server_thread.h.
|
protected |
thread to accept tcp clients for command requests and responses
Definition at line 224 of file test_server_thread.h.
|
protected |
thread to accept tcp clients for result port telegrams
Definition at line 223 of file test_server_thread.h.
|
protected |
true: m_tcp_connection_thread is running, otherwise false
Definition at line 228 of file test_server_thread.h.
|
protected |
thread to send scandata and scandatamon tcp messages
Definition at line 225 of file test_server_thread.h.
|
protected |
true: m_tcp_send_scandata_thread is running, otherwise false
Definition at line 226 of file test_server_thread.h.
|
protected |
list of tcp sockets (one socket for each tcp client)
Definition at line 232 of file test_server_thread.h.
|
protected |
list of tcp worker thread (one thread for each tcp client, generating telegrams)
Definition at line 233 of file test_server_thread.h.
|
protected |
mutex to protect m_tcp_worker_threads
Definition at line 234 of file test_server_thread.h.
|
protected |
true: worker threads started, otherwise false
Definition at line 235 of file test_server_thread.h.