Code for the Servos

software

#1

Hey again. New to the whole coding and OpenROV thing so some help would great. I am trying to get a servo working on pin D10 from the cockpit. I would prefer to map the input for it to an Xbox Controller. I want to make a servo open and close for a manipulator. I was wondering what I have to do in for the coding or if someone could make me a small guide to walk me through it. Thanks.


#2

I put together a very brief description of what would be involved to get an additional servo running here.

If you are keen to give it a go yourself, the first step is geting familiar with Cloud9 (accessible through the dashboard), this is the simplest way to make code changes. Changes to the cockpit code will require the cockpit to be reloaded (stop and restart the cockpit through the dashboard) and any changes to the arduino code will need to be loaded into the controller board to take effect (via ‘Upload firmware’ in the cockpit).

I suggest taking a look at the bits of the code outlined above and seeing if you can make any sense of it, if so have a crack at making some changes and see how you go. Shout out if you get stuck or if none of this makes any sense.


#3

After writing the above it dawned on me that you may not already be using the pre-configured spare servo that is available in v30.0.3, if this is the case, D9 is alreay setup for controlling an additional servo using ‘ALT+Q’ and ‘ALT+Z’ keys.

To change the controls over to use the Xbox controller you only need modify:

  • /openrov/cockpit/src/plugins/altservo/public/js/altservo.js

and change:

  • Line 103 - defaults: {keyboard: ‘alt+q’},
  • Line 113 - defaults: {keyboard: ‘alt+z’},

to something like:

  • Line 103 - defaults: {keyboard: ‘alt+q’, gamepad: ‘LB’},
  • Line 113 - defaults: {keyboard: ‘alt+z’, gamepad: ‘RB’},

To use the right and left bumpers to control the servo


#4

Thanks a lot for the info. I will give it a try tonight and get back to you if I need any help! Thanks again.


#5

Well, I suppose that changes to arduino can not only be achieved by ‘Upload firmware’,because it is time wasting and inconvenient. As IDE is available for debugging, there may be someway to change the code of controller board for arduino. @badevguru do you have any suggestions ?


#6

Not sure I understand the question @Trinh. Both the code for the Arduino and the code for the BBB browser html/javascript can be modified using the Cloud9 IDE. When changing the Arduino code, you have to then upload the changed using the 'Upload firmware" option.


#7

Do you mean change the code of ROV via IDE ?


#8

Every time I changing the Arduino code via the 'Upload firmware" would cost several minutes,I guest there may be a efficient way to upload code to Arduino. Just like Arduino IDE burn.


#9

Ah. Most of the time is the beaglebone doing the compile. That can be sped up if you stop the openrov cockpit process and free up some more CPU cycles for the compiler.

If you doings lots of iterations in the Arduino code, you can use your desktop computer to compile everything. When I was doing a lot of back and forth I would have a development kit with the controllerboard setup without a beaglebone installed and I would directly flash the firmware images to the Arduino using the ICSP interface.


#10

Um…I used to burn my Arduino UNO via The USB TTL Serial cables .Is it possible to burn the controllerboard?


#11

I am new to ICSP.Is it burn code via AVR Studio?

Ops.I have understand. It could also use ISP via Arduino IDE.Thank you very much:grinning: