Arduino controlled across ethernet via Python

Control Boards, Controllers, Tethers, Ect.
Post Reply
87TurboIroc
Posts: 32
Joined: Jan 11th, 2012, 12:22 am

Arduino controlled across ethernet via Python

Post by 87TurboIroc »

Hi All,

I've been trying to decide on a control system for a long while and have really focused on fiber optic as my tether. I'm really hoping to make on-board batteries work for my first ROV as well. A single pair multi-mode fiber tether is relatively cheap and pretty much neutral bouyant as well.

I started the official project last week by purchasing a pair of Arduinos - an UNO and a MEGA. I was originally hoping to control the Mega from the Uno, and have the Mega also send up telemetry either to the UNO or as a web host. As testing and research revealed, making these two talk across ethernet is a bit more advanced programming wise than I want to learn.

In frustration with the difficulties revealed, I started looking at other methods of controlling the Arduino. I discovered Python and some work done by others that allow for control of the Arduino via a joystick attached to a computer. Since I'm planning on IP camera(s), I was going to be using a laptop anyway to display the video. However the system does not support Ethernet comms as written. I'm sure it could be coded but I don't have time to learn the level of programming needed to get there. I was aware of USB over IP devices on the market (typically in the $50 range) so the issue of converting to Ethernet is not an issue at all. Best of all this gives you a direct USB connection to the Arduino, allowing for editing the program while the ROV is underwater.

So my current plan is to run the following setup:

Laptop + Joystick connected wirelessly to a router.

Wireless Router connected to a Fiber Media Converter, 100 meters of fiber downlink to ROV, on board Fiber media converter to ethernet switch (if all USB devices, could go directly to the USB over IP box), IP cameras plugged in to switch, secondary on-board Arduino with Ethernet shield to serve Telemetry data via web page, and then primary control Arduino connected directly to USB over IP box (or optionally a USB hub, plugged in alongside USB camera(s)).

Because there is no need for a physical connection to the boat, the surface media converter and wireless router could be placed on a float along with another battery. This could be dragged around by the ROV or an Arduino on-board with GPS could hold a position with thrusters. The main idea is to keep the boat from dragging the ROV when it swings around on the anchor. Range of a few hundred feet would not be a problem for the wifi.

I've been keeping a VLOG of this work here: http://www.youtube.com/watch?v=NNJjLolq0Vs
fluxno
Posts: 83
Joined: Nov 24th, 2012, 9:52 am
Location: Norway

Re: Arduino controlled across ethernet via Python

Post by fluxno »

are you familiar with the openrov project(www.openrov.com)? they combine a beaglebone board and a cape/shield that has a arduino based microcontroller.
they use the beaglebone to connect a genius f100 full-hd webcam and ethernet for controll with laptop. the cape with the arduino controls 3 escs, 1 servo for camera tilt and also have a light control circuit.
the laptop control panel also support a gamepad, i think they use a xbox controller.
you should check out their site, all the code is available, but the cape board is not available yet, neither is the schematics, but they are both close for release.

since the beaglebone realy is a small linux computer you can stick on several usb webcams and stream those to a webpage in example. there is also alot of talk about sensors to be implemented on the system further on.
87TurboIroc
Posts: 32
Joined: Jan 11th, 2012, 12:22 am

Re: Arduino controlled across ethernet via Python

Post by 87TurboIroc »

I didn't know about it but read up on the link you provided. Pretty cool stuff there but I don't want to invest in yet another microcontroller system. Already kicking myself for spending $200+ in Arduino stuff and running into various issues.

Right now I'm having a problem with the servos acting up when I modified the multiservo script to do mixing between the elevator and rudder inputs for a two thruster setup. When I push the stick forward I want both thrusters to proportionally give forward thrust. When I make rudder inputs, I want one thruster to slow down (or even reverse if it is moved far enough) and the other to speed up. Pretty standard mixes in RC but coding them in the Arduino with little knowledge of the language is a bit challenging! Later with four thrusters I would modify the code for slewing left, right with aileron input.

The code is essentially working, but at extremes of elevator movement, barely touching the rudder to bring it off center is giving wild 90+ degree movements to the servos. Looking at the output of the MultiServo program in Python, the offcenter position is very close to zero and should not result in the amount of movement it is getting.

I can see why people are just running copper tethers and a simple DSC control to a real Rx in the ROV. I just get the feeling the Arduino is going to be glitchy and unreliable with $1000+ worth of hardware below. Hopefully I will change my mind about that in the near future though!
amarillo_rocket
Posts: 25
Joined: Sep 4th, 2012, 11:06 am
Location: Amarillo Texas

Re: Arduino controlled across ethernet via Python

Post by amarillo_rocket »

I am working on a similiar project with an Arduino using the standard Arduino script. I will be running copper from Arduino to Arduino instead of fiber. I find the Arduino to be very stable. The biggest initial problem was getting acquainted with the programming language and it's little nuances. The more I worked the code to solve glitches like you are experiencing the easier it has become so it just takes some time. It sounds like the Python code is not mapping the joystick inputs correctly so your servos can get to the right position. I have not looked at the Pyton code but I assume there is a mapping function converting the joystick inputs to a range of 0-180 for the servos to understand. One of my plans in the future is to write a VB .Net program to capture sensor data and display the data in a GUI interface along with joystick control. I may end up using Python since there are a few scripts I can build upon still a little undecided. So much to learn so little time but it sure is fun!!!!!!!
rovdude
Posts: 83
Joined: Sep 17th, 2012, 10:28 pm
Location: Baltimore, USA

Re: Arduino controlled across ethernet via Python

Post by rovdude »

Well there is one problem: GPS does not work under water. I am working on an idea for a GPS, but it must remain on a buoy on the surface, connected down 100 feet to my rov. I don't know how you could have your ROV to hold a position, but I thoughtI would give you a heads up on that. Maybe try an accelerometer to make adjustments? They sell them at adafruit.com, but I would imagine it would take several tests to get the numbers worked out correctly for the adjustments.
87TurboIroc
Posts: 32
Joined: Jan 11th, 2012, 12:22 am

Re: Arduino controlled across ethernet via Python

Post by 87TurboIroc »

Actually I'm talking about exactly what you are... a float with GPS and thrusters of its own. The main idea would be for it to hold a postion over the ROV's general working area. That way the boat would be free to drift around on its anchor line and I wouldn't need to have an extra 100+ feet of tether in the water for some other boater to run across. It could be remotely commanded to change positions via the wifi connection. It is amazing how much the boat drifts around when it is anchored.. especially in our area with constantly changing wind directions in the warmer months.

I've also thought about the hold position of the ROV thing and I'm sure accelerometers could do it quite readily, but the constant thruster corrections would certainly eat up more power.. and I agree there would be some work into the coding for that one!
Seawolf
Posts: 33
Joined: Oct 15th, 2011, 10:22 pm

Re: Arduino controlled across ethernet via Python

Post by Seawolf »

For the record, you can get get a wireless router to act as a serial to network gateway using third party firmware. http://todbot.com/blog/2010/12/16/wifi- ... -wl-520gu/

This is nice because you don't need an ethernet shield for the arduino (although it sounds like you already have one). It just works over USB.

On the ground station side of things, there are programs that can make an ethernet connection look like a USB port. This is handy because you can make it look like the arduino is just plugged into your computer, and not have to worry about networking stuff. I never found a good one for windows, but on linux you should just be able to do:

socat -d -d pty,raw,echo=0 TCP:192.168.1.1:3001 (or whatever IP and port the arduino is connected to)
sudo ln -s /dev/pts/12 /dev/ttyS4 (The values that go in this line are determined by the output of the first command, so be sure to read it).

Not sure if any of that is particularly helpful to you.
perfo
Posts: 151
Joined: Jan 27th, 2015, 12:05 am

Re: Arduino controlled across ethernet via Python

Post by perfo »

Any progress on this project? It is similar to my plans and like most on here I don't want to reinvent the wheel if I don't need too. One advantage of keeping things standard Ethernet over fiber is you can put a router in the rov and connect as many independent IP cameras as you need (especially if using gigabyte gear) . Having the cameras do all streaming and control by themselves takes a lot of complexity and processing pressure off the controllers. The other reason I want to go up this route is the IP cameras will be independently accessible from anyone with network access so the team can view whatever camera they are interested in maybe in their office the other side of the world..Most IP cameras allow different levels of access so if its a PTZ type you can assign control or view only rights to any user which is a gain another huge benefit for networked cameras..

Thus if you've cracked this one I would be very interested in seeing your webpage being served from the ROV and how you convert Joystick (gamepad) controls in to motor instructions...
a_shorething
Posts: 289
Joined: Sep 10th, 2013, 5:26 pm
Location: New Jersey Shore

Re: Arduino controlled across ethernet via Python

Post by a_shorething »

perfo wrote:Any progress on this project? It is similar to my plans and like most on here I don't want to reinvent the wheel if I don't need too. One advantage of keeping things standard Ethernet over fiber is you can put a router in the rov and connect as many independent IP cameras as you need (especially if using gigabyte gear) . Having the cameras do all streaming and control by themselves takes a lot of complexity and processing pressure off the controllers. The other reason I want to go up this route is the IP cameras will be independently accessible from anyone with network access so the team can view whatever camera they are interested in maybe in their office the other side of the world..Most IP cameras allow different levels of access so if its a PTZ type you can assign control or view only rights to any user which is a gain another huge benefit for networked cameras..

Thus if you've cracked this one I would be very interested in seeing your webpage being served from the ROV and how you convert Joystick (gamepad) controls in to motor instructions...
Hey Perfo,

I had that same idea about pulling ethernet video out and possibly broadcasting it to the web. I don't know anything about webhosting, but I do know that a webcam can be set up using Rasbberry pi (or just an IP camera) and that signal could (theoretically) be served out to the web. The logistics of doing this from a laptop on a boat out on the water may be a bit challenging, but I think it could be done in real time or at least near-real time.

I have a program that I'm still working on that I need beta testers for if you're interested. It's a C#.NET based windows application that basically uses UDP (Ethernet) commands over the Ethernet wire to whatever IP address you put into the interface and the user inputs are either keyboard commands (for testing or non-XBOX codes) or an XBOX controller (default).

The concept is this: It's not just built for ROVs. It allows you to load the program and then set up the IP address (or com port if you're using serial comm) and then your job is to program just the other end. The program comes with a list of codes and a map and ranges you should expect in your control board based on Xbox input (up to four different controllers!). I have sample Arduino code for the serial communication and Netduino code for the UDP Ethernet com, but don't have any Arduino Ethernet sample code yet (though there are examples on the web) since this requires an Ethernet shield and I haven't hooked one of those up yet.

Using this, you could have four different people on board your boat controlling different functions on your ROV (and theoretically each watching a different camera view if you have that set up) and the only part you need to worry about coding is the part in the control board. This way the same program would work for an RC car, boat, ROV, combination vehicle, whatever. The program just passes through the XBOX commands from a laptop (or PC) so you only have to worry about coding what happens when those codes are received.


Features not included: Web cam window on the interface. I kept the video and data stream separate from this tool because I want it to be generic enough for general use. Start adding video and HUD functions and it gets very specific. For this reason a separate web feed would be required for video. The XBOX Pass-Thru interface doesn't need to be monitored so it can be minimized while you run it and view video stream (and data signals from your web viewer.

Specific status or graphics about the ROV: For the same reason I'm not including web cam window, I'm also not accepting or displaying data from the XBOX (except feedback for the controller, which is working in the serial version, not yet for the Ethernet). The purpose of this is JUST TO PASS THRU the XBOX commands seamlessly down the wire. It's very thin (each command is only 3 bytes) and I wanted to keep it simple and focused on the task at hand.

Let me know if you'd like to be a beta tester and if so, what version of Windows you are running (sorry, windows only).
perfo
Posts: 151
Joined: Jan 27th, 2015, 12:05 am

Re: Arduino controlled across ethernet via Python

Post by perfo »

Sounds like you are making good progress. I'm not sure how much help I'd be as a tester. I'm using a RPI now and doing all controls via the RPI with separate Cam stream on it's own IP. I've sorta got my system set up and working except for crappy performance on my video view. I've started another thread on trying to get some help in VBA or VB.
I've got an adafruit servo controller and the nine axis gyro board... They turned up today. So once I get the hardware set up if you want me to test some code for you then I'll give it a go but I have decided on a different route my self (for now).
Post Reply