send pcl point cloud over tcp in c++ - c++

I am new to data serialization in c++, I searched for examples but I was not really successful.
My goal is to be able to send and receive a pcl point cloud over tcp in c++. I am familiar with ROS, but now I cannot use it in the server. I have to send point cloud through ethernet to a client machine, where I am free to use ROS.
I tried Python with ZeroMQ configured to send the point cloud in numpy array. The message contained a json markdown with the array shape and then another message contained the array.
If i am correct, in c++ I should serialize my pcl::PointCloud<pcl::PointXYZ> cloud object to be able to send it somehow. In case of c++ I cannot find it possible to send array shape as markdown.
Is it possible in c++ to send this cloud object similar as in zmq? Or is there a more handy approach to this problem?
update:
In cpp, I read the point cloud from camera, into pcl::PointCloud<pcl::PointXYZ> object. My goal is to send somehow this data through tcp and be able to reconstruct into a similar point cloud object preferably in cpp.

C++ does not provide a standard method to serialize and deserialize data.
You can implement this yourself for simple cases.
For more complex cases you can use a library, such as protocol buffers or Boost serialization.
You can also use a text-based format "on the wire", such as XML or JSON.

Related

Reading, Creating, and Manipulating full Frame in TCP/IP network communication via C++ coded client and server

I would like to code my own client and server in C++ (which I have found plenty of tutorials on) and access to all information about the headers and all the fields in a frame that is going to be sent across a network.
I need it to be able to edit and/or manipulate information in all the header fields before sending the frame across the network. What's more, it needs to be able to receive a frame and read/manipulate all the header fields from layer 2 to up layer.
I just want to know what library in C++ I need to use or is there any information on how I can code something to accomplish this via C++ that I can be directed to?
If you want to construct a client/server, it's easy. But if you want to build a packet from MAC to Transport Layer, then you need to use the Linux kernel. You need to have some knowledge about how the packets are sent and received. What's more, we always use C to realise it.

Connecting a SFML client to a C server

I'm wondering whether (and how) I'm able to connect a client created with the C++ SFML to a basic C server.
I know transfering data is normally done using SFML's sf::Packet objects using the send and receive functions from the sockets.
Please note that this is a school project. The connexion isn't restricted to SFML, but the receiving server must be written in C.
The server is already functionnal, and it uses dprintf() to write on the C clients, so ideally I'd be able to do the same with the C++ client.
EDIT_1: sf::Socket.send() doesn't only support sending sf::Packet objects, but also void*. In my case, I need to send and receive strings so that's a first hypothetical solution.
SFML is only for C++. you need to use CSFML its official binding for C

Why can't I learn how to Implement the ONVIF standard?

I've bougth an IP camera. I then, discovered that it uses a standard called ONVIF. I searched about it and saw that it's a good way to put all the cameras in the world to be implemented in the same way.
Of course I've read the ONVIF specification PDFs. What I understand about how it works, is the following:
There is a WSDL file that describes how the camera (or another thing) can be accessed. Like, which settings can be modified, which methods are accepted, and so. When I read this WSDL file, I'll choose a method and send a type of message called SOAP, which will be a XML containing the response to some method on the WSDL file. SOAP is a XML that can go over HTTP (so it can go through firewalls), but also can be sent over other protocols.
So, as I understood, if I want to tell my camera to start streaming video, I just need to find the WSDL method that describes how to initiate a stream, and then send a SOAP message to tell it that I need to start a video stream over some protocol, at some port. Then, I can read and decode the stream.
By knowing this simple example I gave, I could do other things, like, control the camera and so. I don't know the public for which the PDFs at ONVIF are directed for, but I couldn't understand it enough so I could explore my camera. For example: I don't know how to receive this WSDL file. I've read somewhere that I should access http://ip_of_camera/onvif/device_service to get the file, and then I should send a SOAP message to it and watch the response.
I even tried to analyse the packets via wireshark, but they've seem nonsense to me. It was difficult because I couldn't even make my camera work with iSpy software. It only works perfectly (but with no audio or talk) in my android app, so I've set up a proxy at my raspberry pi and then analyzed the packets.
Could somebody give me a basic example of how to receive the WSDL file, and then how to call one method of it? I wanted to see how it works in a network level, but I can only find how to call libraries in C# that are ready to deal with it.
For example: I wanted to know what I need to send through TCP or over TCP/HTTP to the camera, and how to initate a stream. All of this in network level, no code needed at all.
I'm just trying to learn here, but this doesn't seem like a real "open" standard. It's very hard to understand if you never programmed anything like it. So I guess those PDFs are for people who work with it. I know how TCP and UDP works and how to send raw messages by them, so it's all a question of finding a good resource with examples, so I can understand what ONVIF is really about.
Couldn't the internet unite to make it more clear? Why there are no posts about it?
Thanks, amazing community <3

C++: Cloud computing library: is there such a library where I don't need to write much network stuff?

I want my server app to be able to send data to be processed by a bunch of various clients, and then have the processed data returned to the server.
Ideally, I'd have some call like some_process = send_to_client_for_calculating(connection, data)
I just need to be able to send a bunch of data to a client, tell the client what to do (preferably in the same message, which can be done with an array [command, data]), and then return the data...
I'm breaking up pieces of a neural network (tis very large), and then assembling them all later.
If I need to be clearer, let me know how.
I'm shocked no one has thrown it out there... how about boost::asio.
Why don't you have a look at using Apache ActiveMQ? It's a Java JMS server, but it has C++ bindings, and does what you want with a minimum of writing networking code. You basically just subscribe to messages, and send responses back. The MQ server takes care of dispatch and message persistence for you.
You could try using beanstalkd, a fast working queue. I don't know if it fits your purposes. There is a client library written in C, which you should be able to use from C++.
I'd suggest looking at gSOAP, which implements SOAP in C++, including networking.

How to enable Matlab to listen real time data through C++ application

I need to create a C++ add-in to Matlab where add-in will listen to packet coming from network and notify Matlab to draw an packet analysis graph. I understood that using a MEX file I can easily call c functions inside Matlab, but I could not find a way to notify Matlab when data is available at C++ end. Is there any way we can pass a user-defined Matlab function pointer into my C++ add-in?
BTW, I found this thread: real-time-data-in-matlab
Unfortunately suggestion is to use ActiveX control, but in my case, I need to create add-in in pure C++.
Have a look at Gurobi. It 'just' prints status information to the command window. Using a mex command like mexCallMATLAB you may access 'any' matlab function.
Would it make your life easier if you could listen for the network data directly from Matlab? I've never tried it, but there are a few submissions on MathWorks' File Exchange site that allow you to create sockets within Matlab. Here's a TCP/IP example that creates both a client and a server, and here's a similar UDP example.