Distance Sensing and Control Scripts


Hello, I am trying to write code which takes input from various distance sensors mounted on the outside of the openRoV and uses the data to adjust the thrust in the motors to keep a constant distance from an object.
The first question I had was which sensors would be good to measure distance underwater as accurately as possible. I have tried using waterproof car backup sensors, however when used underwater they only read the minimum distance allowed on the sensor. I would like to try some type of laser distance sensing but I know IR is only going to be good for short distances and I’d like a range of at least 1-2.5m. So far the best thought I had was some type of sonar, so I was wondering what types of sensors would be good for this
Additionally, once I have the sensors I was wondering if I could connect them to the free I/O pins on the arduino, and once connected where do I look to control these sensors. I’d like to know which modules are used and which parts of the modules to change to use extra sensors
Finally, I was wondering which modules would I need to edit to add a control algorithm with these sensors and the thrusters without affecting the code already on the openROV

Also, if anyone knows where I can look for some type of document which describes each module and its function that would be amazing


There are several extension points for adding sensors. The primary means if by using the I2c bus which extends outside the e-chassis. That is what the IMU uses. The Arduino currently serves as Master on the I2c bus. That said, the beaglebone also has I2c capabilities and can be wired up to interface with sensors directly as well. The other option is to use the space external wires and connect them to either the SPI pins or A/D pins.

We lead with interfacing the sensors with the Arduino as it tends to have a rich community of existing driver code for interfacing with devices.

The Arduino code has been broken out to seperate “plugin” modules. You can start by cloning on of those modules. The version of Cockpit currently in master on github has been extended to make the plugins self registering and you can see what it takes to add a module by looking at this pull request for external lights. You can see what the existing modules are by taking a look at this: