How to remotelly control the motors using C++ code?

software

#1

I am interesting in remotelly control the OpenROV v2.7 using a c++ code. I am thinking in use the Socket.io interface though some library, e.g https://github.com/ebshimizu/socket.io-clientpp/. By chance, was someone tried it? Or someone can point me the commands to do it (at least in socket.io).

Regards, Paulo.


Trying to hack ROV pilot controls, NOT WORKING
[Plugin] CurlAPI
#2

Cool. Let me know if I can help. The ROV is running on Socket.io 1.0+, a lot of libraries have been slow to upgrade so keep an eye out!

To see the messages that are being sent to the ROV you can directly inspect them in this file. I will highlight some of them. All of the parameters should be floats between either -1,1 or 0,1.

I am including a link to a GIST we used to drive the lights and read telemetry value on a pebble smart watch using a pre 1.0 socket IO client.


#3

Great hint! Now, my main issue is a library that allow me to connect with socket.io 1.0+ in C/C++. I have found many libraries but all of them deal with version 0.9 or older. Do you know any library?

Regards, Paulo.


#4

I have tried to connect to a simple socket.io server with what seem to be the only two C++ socket.io libraries on the net, socket.io-clientpp (the one you originally mentioned) and socket.io-poco. Neither is able to connect to a server using socket.io 1.0 and development for both seems to have ended long ago. As it stands, the nearest alternatives (in terms of interfacing with OpenROV’s existing code without modifying it) are to try and implement socket.io communication on your own using a C++ websocket library or write a proxy application in a language that has support for socket.io 1.0, such as Java. The first solution requires a decent bit of effort (evidenced by the fact that it doesn’t already exist) and the second is just a lackluster solution in general, since you’ll either have to reinvent the functionality that socket.io provides in the interface between your C++ program and your proxy or forego having it. You could also create a proxy on the OpenROV side using a websocket library that is more straightforward to interface with on the C++ side, however this has some of the same drawbacks as creating the proxy on your client-side.

While websockets and socket.io are great for enabling simple, event-driven communication in the domain of web development, apps, and similar families of technology, there is little to no support for the average C/C++ user. The vast majority of robotics libraries, research algorithms, and sensor interfaces are natively written in C or C++, and you will probably find that the typical users of these software packages are not familiar with web technologies or communication frameworks. With that in mind, I would say that if you want to make the OpenROV more “open” in the existing ecosystem of robotics software, you may want to consider choosing a more interoperable communication framework. For the purpose of trying to integrate an OpenROV vehicle into the research I’m doing at work, the roadblocks and cost/benefit impacts of not being able to easily interface with the OpenROV software with our existing software drive the decision to just use our own software for both communicating with and controlling the vehicle and enabling autonomous operation.

In the meanwhile, I’ll keep my eyes peeled for other methods, libraries, etc to try and bridge this gap.

-Charles


#5

Incidentally, I have found a rather up to date DDS<->NodeJS bridge that was developed by RTI, called “RTIConnector”. It’s an unofficial library, so it remains to be seen how well (if at all) it will work, but they have in one of their readme files:

Available examples

In this directory you can find 3 sets of examples

  • simple: shows how to write samples, how to read/take, and how to use event based reading
  • web_http: shows how an http client can request DDS data using REST
  • web_socket: shows how to push DDS data to a browser through socket.io

That last example in particular looks like a nice way to hook in to the existing software, if it works. Will report my findings.

-Charles


#6

Hey @spiderkeys, totally agree about making selections that let any language easily interop with the ROV. It is disappointing that the socket.io libraries that were native to so many other languages seemed to get lost after the 1.0 release. So this is probably as good a test case as any on accessing the ROV APIs given that reality.

Technically you can connect to a socket.io service with any websocket client. At least at the transport level. And then you have to encode and decode the socket.io protocol wrapper around the json message. This used to be trivial to do as seen in this arduino project https://github.com/billroy/socket.io-arduino-client/blob/master/SocketIOClient.cpp. But none the less it would be a pain if you don’t have something that does the encode/decode for you.

I’ll make a run of using a raw websocket client with the 1.0 release of socket.io and see what the story is and report back.

Worse case it should be trivial to open a raw websocket listener up on the ROV so any standard websocket client can talk to it.

List of recent socket.io libraries that I will test. As I test them I’ll mark them as tested (feel free to help! It wil go faster):

C++

Clearly marked 1.0+ socket.io libraries that I am not testing

Android/Java


#7

Hello guys,

Great topic for discussion! I am interesting in control the openROV, as researcher on underwater robots/system. Thus, I need to get access to the sensors (including camera) and send commands to thrusters and lights. I have tried to use the “unique” library that “suppose” to work with socket.io 1.0+ using C++ (https://github.com/sourcey/libsourcey). But, I can’t use it, probably by the limited documentation and the short time that I have spent on it.

Now, I have implemented (and running) a C/C++ Code in the BBB using simple libserial + nanomsg (sockets) to communicate with the arduino (read and write data) and send data/receive data to/from the surface via sockets. In the surface computer, I have a C/C++ using OpenCV + libjpeg( to read video stream from mjegstreamer in port 8090) + nanomsg (to communicate with arduino). That is my “quick” solution to my problem. I am implementing a visual obstacle avoidance (I am intent to share the code after publication/testing).

P.S: The main drawback of my approach is the limitation of serial communication, thus cockpit stops to work sometimes due the share in the use of ttyO1.

Regards, Paulo.


#8

So @codewithpassion already did the leg work in Master to abstract the transport from the message protocol. The code basically takes any message eventing system and wires it up to a list of listeners in an event emitter. So technically where the code below loops through the listeners in the event emitter or the connected sockets, we could add any other messaging based protocol right next to the socket code. Thus you could have socket.io messaging right next to a amqp or even raw sockets (sending commands via netcat for example).

https://github.com/OpenROV/openrov-software/blob/master/src/lib/CockpitMessaging.js#L16-L39


#9

This is a quick proof of concept I threw together to get the ROV to expose a new URI for streaming all of the data being sent back to the cockpit.

From your computer you can type curl http://192.168.254.1:8080/curl-api/stream and get an ongoing dump of telemetry data. I’ll expand the example this evening for general command input.

This example shows how to plugin to the CockpitMessaging abstraction mentioned earlier.


#10

@paulofurg, Don’t feel bad about not getting libsourcey to work. I spent the last hour or so checking it out, and it is a complete mess. The build is broken if you try to build samples or tests, the cmake script doesn’t copy the include directories for you, and I got a half a million errors trying to create the simplest example program, once I got the thing built and installed. It seems the socket.io and websocket parts of that library fell behind the rest of the library (look at the sample code for socket.io and you will see they are still using namespaces like Sourcey:: and Net:: when they now use scy:: and net::).


#11

Okay, the gist has been updated with the ability to send commands over http using curl as an example:


#12

It’s here, at long last…!

http://socket.io/blog/socket-io-cpp/#

Jim N and I will be testing this out in a dive here in a couple days with some of our code. Will report results!


#13

Very cool topic, and mainly why I joined the forum…to investigate things like this. My background is much more along the C/C++ lines and embedded development–so the Node.js thing is somewhat new to me. I have worked a bit on my own project (before I knew much about OpenROV) for a robot/ROV design. My plan was to use C++ with the Qt framework, as they have some pretty nice libraries. However now that I have begun to get more familiar with the OpenROV project, I plan to hold on my project a bit–and go ahead and acquire an OpenROV kit, and learn the software. Then I can always circle back to my original idea(s) later.

I’m just curious though–has anyone used the Qt framework to do anything like this? I’ve already got some Arduino PWM code working very nicely, and was in the process of replacing some generic C++ socket example code with that from Qt. I’ve gotten it working in another Beaglebone Black-related project…just not the robot/ROV project I’ve worked on.

Cool forum though–lots of GREAT ideas in the various threads. Should be some great learning!

TB

EDIT: @spiderkeys socket.io C++ efforts look very interesting as well. I’ll definitely want to check that out.


#14

Guys,

I have news. Now, I am able to control the OpenROV and read data (and send commands to the ROV) in a C++ code. My solution is based on get video from port 8090 using libjpeg and curl. Furthermore, I have controlled and read the sensors using a socket connection (in another port like 5454) using nanomsg library. Thus, I have a C++ code running in the Beaglebone side that communicate directly to the Arduino via serial port (using libserial). I am planning to make the code available soon. I send news about it.

Regards, Paulo.


#15

Congratulations on getting it to work Paulo!

I’ve gotten the BBB to send PWM control code to an Arduino as well, over a UART. It’s fairly straightforward, and I simply used a basic C-code example for Linux serial communication that I found in a text book. I had to adjust it somewhat, but it works just fine. I ended up using an Adafruit (i2c-based) PWM controller on the Mega, but the Arduino itself takes control data from the BBB over the UART. I have some videos of it, but they are posted in a Facebook Embedded group, and not on YouTube. But it’s pretty interesting stuff, and I was very interested to read your approach. Strong work!

TB


#16

Hi Paulo,

is it possible to make the code available?

Thanks,
Vai


#17

Hi everybody,

Currently, I am working on making the code available. I and my colleagues have submitted a paper to IEEE ICRA and, if the paper will be accepted, we hope to make it freely available. I hope the topic is interesting of the community.

Video demo of the work: https://www.youtube.com/watch?v=YPQ0cADwiH0

Regards, Paulo.
http://paulo.c3.furg.br


#18

Fantastic work Paulo really great work
@badevguru is this the first real autonomous OpenROV (yes still with a tether but)?


#19

Thank you very much for providing this information, I tried “curl http://192.168.254.1:8080/curl-api/stream” in puTTY but I got nothing. I am a little bit new in this area, would you please tell me what should I send to rotate a motor? I want access to all motors outside the cockpit.