MRPT  1.9.9
lib_mrpt_comms.h
Go to the documentation of this file.
1 /* +---------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2018, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +---------------------------------------------------------------------------+
9  */
10 
11 /** \defgroup mrpt_comms_grp [mrpt-comms]
12 
13 Communication utilities: serial ports, networking (TCP, DNS,...), pub/sub
14 nodelets.
15 
16 <small> <a href="index.html#libs">Back to list of all libraries</a> | <a
17 href="modules.html" >See all modules</a> </small> <br>
18 
19 # Library `mrpt-comms`
20 <small> [New in MRPT 2.0.0] </small>
21 
22 This C++ library is part of MRPT and can be installed in Debian-based systems
23 with:
24 
25  sudo apt install libmrpt-comms-dev
26 
27 Find below some examples of use.
28 
29 ## Nodelets-like Pub/Sub mechanism
30 
31 MRPT provides a Publisher/Subscriber (Pub/Sub) pattern implementation for
32 intra-process (multiple threads) zero-copy super fast communication.
33 
34 Thread creation and handling is the responsibility of the user.
35 
36 The main concepts are:
37 - A `topic`: the name of a shared variable. If you are familiar with ROS, you
38 already know what a topic is. Topics are identified by unique strings,
39 e.g. `odometry`, `scan`.
40 - Directory: The central hub that holds all references to existing topics.
41 Usually only one should exist per process, but there is no actual limitation.
42 - Subscriber: An object that binds to a given topic and allows a user-given
43 function to be called whenever new data is published to the topic.
44 - Publish: The operation of publishing a new data piece to a named topic.
45 It's important to note that the call is **blocking**: all subscribers are
46 executed from the thread invoking publish(). Users are encouraged to design
47 subscribers such that their execution time are minimized, delegating heavy
48 computation to other worker threads.
49 
50 All these concepts are illustrated in the example below. Note that different
51 subscribers are created: with a lambda, with a regular function, a std::bind(),
52 etc.
53 
54 See: \ref comms_nodelets_example/NodeletsTest_impl.cpp
55 \snippet comms_nodelets_example/NodeletsTest_impl.cpp example-nodelets
56 
57 ## HTTP request methods
58 
59 mrpt::comms::net::http_get() is an easy way to GET an HTTP resource from any C++
60 program. You can also use mrpt::comms::net::http_request() to access APIs
61 requiring the POST method.
62 
63 See: \ref comms_http_client/test.cpp
64 \snippet comms_http_client/test.cpp example-http-get
65 
66 
67 */



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020