Rust sketch of BlueESC start-up code

Hello! I was recently working on getting a BlueESC up and running using a PWM output from a Raspberry Pi 4B using the Rust programming language, and figured that other people might be interested in having access to that, similarly to how the start-up sketch for an Arduino is available on the BR site. I do a lot of development in Rust (including some Mavlink code, which can run on either the host computer or directly on the ROV’s Pi), and was interested in seeing if I might be able to use it to directly run a motor or two.

The RPi4B only has two PWM hardware output channels, so it won’t be able to run too many individual motors, but two for steering might be possible. You can compile it directly on the Pi or follow some fairly easy instructions linked in the repository for building the cross-compilation toolchain.

In any case, you can find the code at GitHub - ucsb-coast-lab/rpi_pwm: BlueESC start-up sequence from a Raspberry Pi 4B . I hope other people can find some use from it as well!

2 Likes

Hi @chrism,

I’m personally doing a bunch of development with Rust, thanks for sharing!
If you would like, there is mavlink2rest (mavlink to rest api application) and rust-mavlink (a mavlink library for the rust language).
I really believe that Rust is the language for the next 40 years.

Oh, and your GitHub organization is really cool, I have already checked it some days ago! Awesome work.

Hi Patrick,

That’s really kind of you to say, thanks! Not sure if you saw it in the repository, but I did some experimentation last year with running a compass-based PID controller to move the BlueROV2 in a straight line, all in Rust using the mavlink crate, with the code at GitHub - ucsb-coast-lab/rov_controls: Mavlink controls for ROV. I hadn’t seen the mavlink2rest before, so thanks for linking to that!

Just to note, I know that BR writes a lot of APIs in Python and C++, but if protocol versions or other APIs were available in Rust, I know I’d be positively stoked to use them! The language has been really helpful for me on writing reliable and performant code, and I’m excited to see how things progress, especially in areas like this!

Hi @chrism,

Sadly we don’t have plans to have something like ping-protocol in Rust, but if you want, it’s possible to generate the library from our protocol specification, as you can see each device has a json description file for messages, so it should be possible to generate the library from this files with the Rust build step, like what is being done in rust-mavlink.

1 Like

You can connect a ssc32u servo controller to the Pi via I2C for 32 PWM channels.

Hey Darrell,

The SSC-32U is perfect. I understand the connection and routing from the remote end, but what kind of control/interface is used on the surface? Is there a straight-forward interface that can be added to the computer? Or is another device like a Arduino needed on the surface?

Cheers,

By control/ interface, do you mean hardware or software?

I’m a hardware guy. I can imagine or visualize every facet of an ROV in my head, watch how linkages interact, design simple electronic/ mechanical controls, just as most people need a computer with CAD software. Same for the topside interface. By that i mean joystick, gimbal, hat switches/pots, encoders, magnetic angle sensors to replace glitchy potentiometers, visual gui, etc.

My downfall is with software/ firmware/ coding.

The last time i built an ROV, i talked about it alot first, and found a computer guy (Gary) who was interested in helping. I built everything out of my pocket (after selling a ton of Toyota 4x4 parts) and Gary wrote code to connect my topside PC + 2 Logitech Wingman joysticks to the Raspberry Pi below. We used QGroundControl and Ardusub with a Pixhawk to control the thrusters (for an easy autopilot) and his coding to control all the servos, LED lighting, and 2 6-dof manipulators. I believe he used port-forwarding to send commands below?

We could actually tilt AND pan the camera inside the WTC. Imagine that!!

We used a homemade pontoon boat to lower the ROV into DeGray Lake (clear freshwater reservoir in central Arkansas). (2) day-long trips. Almost lost it the first time because the tether got snagged in a tree (they didn’t bother logging the valley before flooding it). Used the ROV’s manipulators to unsnag. Found a Model T? delivery truck mostly buried in silt on 2nd trip. Fond memories remembered with tear-filled eyes, homesick.

Gary closed his shop and moved without telling me?, and my storage unit was burgled 2 months later. Pretty certain it wasn’t Gary, he had no idea where i stored everything and he wasn’t a thief anyway, (unless you ask Microsoft). They took everything, prolly dumping the ROV somewhere as too unique to pawn. The cops were less than worthless as they had hundreds of other storage theft cases and i couldn’t get them to understand that even though I had several thousand invested in the ROV and peripherals, it wasn’t insured. (Tried but couldn’t find an agency willing).

Pictures or it didn’t happen? All pics and recorded video were on the PC and laptop in storage. At the time i had a crappy flip-phone with sub-mp cam and i ran it over with the truck by accident. So it didn’t really happen.

My new ROV design is bigger, more dof on the manipulators, sample containers, active buoyancy, better user-friendly (hardware) control interface, more cameras, better lighting, etc. Just picking away buying parts one at a time as pennies allow.

Still willing to help anyway i can.
_______________________PS
I did find a guy that wrote software to configure an Arduino to be a multiple PWM joystick & 60+ button USB interface to a PC. Multiple Arduino/ Teensy’s & joysticks can be used. Allows one to build his own custom manipulator/ ROV piloting interface.