PicoBorg Revers, DC Motors and Servos
Forums:
Hi again!
I was wondering if it's possible to connect 4 DC Motors (2 per channel), AND one (hopefully two?) servo on a PicoBorg Reverse, and control them separately via a GUI or PS3 joystick?
The DC motors would take care of the robot's movement and the servos are intended for on-board operations, like moving a hand or a camera.
Could this be done with only one PicoBorg? Can I make use of an Arduino here?
Kind Regards!
piborg
Wed, 02/08/2017 - 11:23
Permalink
Multiple motors and servos
It is possible to connect two or more motors to each output of the PicoBorg Reverse providing:
We do this with three motors per channel in our DiddyBorg robot.
Unfortunately you cannot really control any servo motors from the PicoBorg Reverse at the same time.
What you could do is:
csgoskinhunt
Mon, 02/13/2017 - 14:03
Permalink
Is only one BattBorg
Is only one BattBorg sufficient for both UltraBorg and PicoBorg, as in, can I connect them both on one BattBorg?
If I use a UltraBorg, is it possible to control the DC Motors and servos independently?
piborg
Mon, 02/13/2017 - 16:47
Permalink
BattBorg with PicoBorg Reverse and UltraBorg
It will probably depend on your servos, but there is a good chance one BattBorg would be enough.
If not what you can do is use a separate 5V supply for the servos, then the one BattBorg will be fine.
The servos and DC motors can all be independently controlled from the Raspberry Pi.
csgoskinhunt
Thu, 03/16/2017 - 08:16
Permalink
If I were to use only
If I were to use only PicoBorg Reverse and Battborg (for the 4DC motors), and then adding an Arduino (for the servos) by connecting it from one USB on RPi, to the USB port on Arduino (thus creating a serial COM), would I be able to incorporate the servo control into, let's say, buttons or sliders on the example GUI? Would I be able to run them at the same time as the DC motors?
Is there a way to put the example GUI online, on a local server (like with Flask perhaps), so everyone who knows the RPi's current IP adress can access the GUI/control panel for controling the robot?
Thanks!
piborg
Thu, 03/16/2017 - 11:07
Permalink
Adding to the example GUI
The PicoBorg Reverse example GUI is written using Python with the following libraries:
It should be possible to add the Arduino into the mix by using the Serial library. You could then add more sliders and/or buttons to the example GUI and have them work in a similar way to the current ones.
Converting the example GUI for online use is a little more involved. Basically you would need to replace the code using Tkinter with something like Flask to make the web display. This might be a good tutorial to have a look at: https://stormpath.com/blog/build-a-flask-app-in-30-minutes
csgoskinhunt
Thu, 03/16/2017 - 11:30
Permalink
Thanks for the reply!
Thanks for the reply!
After already posting the question I found the diddyweb.py. How could I go about modifying this webGUI? Like adding additional buttons to turn on the PicoBorg Reverse LED for starters?
piborg
Thu, 03/16/2017 - 15:57
Permalink
Altering the web UI
Changing the Web UI is a little more complicated because it is creating the HTML code directly. Each new bit of functionality would have to be added in two places.
1. Doing the action
At the top of the
WebServer
class is a function calledhandle
. This is called each time a button is pushed or a page is refreshed. What the function does is take the URL used and convert it into an action.For example this section:
gets run when the off button is pressed.
You would need to add a new section with a new URL ending, for example
/ledoff
, which does the required task. ThehttpText
value sent back is the text displayed under the camera image after the button press.2. Adding the button
The buttons are also in the
handle
function, in the section starting with:Each button is on its own line, for example the off button is:
What you would want to do is add another button line, but swap
Stop
for the new name andOff()
with a new function name, such asLedOff()
.Finally a bit further up look for the
Off()
function itself:Copy these lines and change
Off()
for your new function name and/off
for the URL ending from part 1.If it all works you should have a new button which when pressed runs new code on the DiddyBorg :)
csgoskinhunt
Fri, 03/17/2017 - 14:51
Permalink
Really indepth! Thanks, that
Really indepth! Thanks, that should do it for starters.
Do you think it's possible to incorporate ServoBlaster to control servos instead? For example, instead of a LED button, I'd have a button 'servo left', which when pressed, would rotate servo to one side for the duration of the press.
Since the library makes use of shell commands to turn a servo to a certain point, would I be able to make a button, which would in turn send commands to the Terminal? Or would I have to make use of a CGI script?
The library I'm aiming at is this one: https://github.com/richardghirst/PiBits/tree/master/ServoBlaster
piborg
Fri, 03/17/2017 - 21:19
Permalink
Absolutely :)
Running shell commands from within python is actually quite simple, so yes :)
First you will need to add the
os
module to the import list at the top:Now you can call the
os.system
function with your shell command. For example if this is your ServoBlaster command:the python version would be
csgoskinhunt
Fri, 03/24/2017 - 10:57
Permalink
It really is that easy!
It really is that easy!
For anyone trying the same thing, I recommend using "subprocess" module instead of "os" module. Read this for reference:
http://stackoverflow.com/questions/89228/calling-an-external-command-in-...
So instead of doing:
You do:
Ofcourse, don't forget the import.
Regards!
csgoskinhunt
Wed, 03/22/2017 - 10:41
Permalink
One more thing, regarding
One more thing, regarding these lines:
Is it really enough to just change Off() to Led(), and "/off" to "/led", for example? Or do I also need to change the "setDrive" ID inside var iframe in the lines above?
I'm not sure, why inside every Java function (line 2 in the above code) the getElementById is set to setDrive ID.
In my case, do I just leave the ID at "setDrive" even though I'm changing LEDs?
Hope I explaind my question well,
Kind Regards
piborg
Wed, 03/22/2017 - 12:40
Permalink
That is right
It does sound odd, but it is correct that you are getting the "setDrive" part of the page each time.
The "setDrive" element is actually the section of the page just below the camera image. This is where the values returned back from the robot are shown, which are normally speed values. Originally the name made more sense, but even the
Photo
function uses the same named section to take the photo. I probably should have called it something like status instead, but never mind :)You are right though, you should be using the "setDrive" ID even for changing your LEDs or servos.