So this is gonna be a long one. As my personal project I’m trying to build a 4WD Robot roughly the size of a A4 paper. I’ve successfuly setup the A-Star 32U4 Robot Controller SV with Raspberry Pi 3 (running Raspbian) and I was able to run 4x 6V 20D motors (also from pololu) via the control panel that comes with it. I’m using external LiPo battery, everything mounted on DIY robot chassis. Everything is updated to v1.0.1, so is the RPi.
Since I want to add other functionalities to the robot and by that I mean 2 additional servos for cameras mounted on top, I’ve tried to analyse the original code. By taking baby steps, I’ve first added another checkbox, which when pressed, activates LED on pin13 through digitalWrite(13, HIGH), instead of just using AStar32U4 Arduino library. It worked.
Now, I’ve tried running a small Tower Pro Micro Servo 9g that usually comes with Arduino starter packs. Again, to the original control panel I’ve added a checkbox (why not a button? It was easier to just take existing lines of code from LEDs and modify them) which when pressed, activates the Servo.h Sweep example sequence and repeats it until I uncheck the radio button.
I’ve used pin11 (PWM), GND and for the power I’ve used an Arduino UNO’s 5V power pin. Also, please note, you have to modify the ServoTimer.h file from Servo.h library (details here).
1.) Needless to say, it worked, but not the way I’ve imagined. It’s impossible to run a servo simultaneously with the DC motors. To move the servo, the robot has to be still. Maybe to someone more adept, this was obvious from the start. Now to my question, is there an option or a workaround to be able to drive the robot and move the camera’s servo at the same time?
2.) Everytime I’ve tried to move on, to controling two servos instead of just one, meaning, I’ve tried to incorporate two checkboxes instead of one (one for each direction of rotation of the one servo), I’ve got a blank and unresponsive control panel - no values displayed. I’m pretty sure I’m doing something wrong in the coresponding a star.py or script.js code.
In trial and error I’ve found out, that everytime I tried to add another, let’s say, def servo_motor() inside a_star.py class, everything went haywire: the analog monitor displayed 5 digit values, so did the battery monitor, LED checkboxes lighted up wrong colors compared to original code, joystick when pressed, just ran a random forward/backward sequence on random—so, everything was mixed up. It was either that or the blank control panel.
To my second question: how can I safely add more functions to the a_star.py, script.js, server.py etc. ? In regard of the attached code, how would I add another checkbox and control steering the servo left and right? The problematic part is inside script.js, a_star.py and server.py. The HTML and Arduino code I think I could manage.
3.) Is the A-Star 32u4 capable of runing this servo. I’d use only PWM outputs. The power would be sourced from elsewhere.
4.) If I use a button instead of checkbox, how do I check if the button is pressed with JQuery? I’ve tried this, but the control panel was simply blank, so no results.
The code that runs the servo’s back and forth sequence through a checkbox is added below. Also, I’ve attached the code where I tried to have two checkboxes, one for steering the servo left, and the other for right.
Hopefully someone can help me, since I’d really like to finish this project. It’s getting frustrating, but it motivates me even more.
Thanks in advance,