
Hello everyone,
I am trying to create a simple condition using a Kangaroox2 and two motors with independent control. I found a really great forum dialogue from a few years ago that helped me get started but I am now currently stuck and my EZB is disconnecting at the same point in the code. I am finishing up code for a working periscope and lifter in my R2 unit.
Here is the original link...
https://synthiam.com/Community/Questions/Help-Using-A-Returned-Position-Value-From-Kangaroo-In-Ez-script-4618
Thanks to help from Dave, I was able to get my setup working fairly well but there are times when the periscope is out of alignment and crashes into the dome when I try to lower it. So, I managed to tweak the code from Dave and DJ in the article to get position values from the kangaroo but have hit a wall.
Here's my attempted code for monitoring the position of the rotary motor so the periscope can lower without crashing. I have notated where the code crashes and the EZB disconnects. I believe it is related with the $Roo_position = Split ($GetP.....) command along with the following If/Endif condition.
Thank you for any help!
Douglas
____________________________________________________________________________________________________
$Rotary_Position = 43 #Rotary Home position Kangaroo is shooting for
$GetP = "Getp" # Command to get position from Roo
uartWrite(2, 0, "2, Getp", 0x0d)
:waitForData
$x = UartAvailable(2, 2)
print("Bytes in buffer: " + $x)
if ($x < 4)
# Go back and wait for data again because we did not receive the least number of expected bytes
goto(waitForData)
endif
$GetP = UARTRead(2, 0, $x)
print("Received: " + $GetP)
Sleep( 1000 )
# Getting stuck below this line and EZB gets goobered and disconnects from the wifi
$Roo_position = Split($GetP, "P",1) #2,pXXXX is returned. Get everything after the P as P is case senceitive
# Send script to proper subscript depending on if position is above or below center
if($Roo_position = $Rotary_Position)
goto(CenterDown)
ELSE
goto(Centerup)
endif
:CenterDown #If Rotary is at correct position than lifter will lower
uartWrite(2, 0, "1, P798 s600", 0x0d)
Sleep(4000)
uartWrite(2, 0, "1, Powerdown", 0x0d)
Halt()
:Centerup #If Rotry is in the wrong position then lifter will rise
uartWrite(2, 0, "1, P1 s600", 0x0d)
Sleep(4000)
uartWrite(2, 0, "1, Powerdown", 0x0d)
Halt()
___________________________________________
Anyone have a solution?
I'm just tossing this around in my head; my concern (like you) is getting the motor back to "Home" or a certain exact spot. We need the arm (or in your case, a periscope) to safely retracted into the body of the robot. With the Roo in "Position and Speed mode" it uses the encoder to first Home to know exactly where the motor is positioned. We then can park the appendage in the exactly position once the animation is completed. With servo control, theoretically, once set up in the proper position, we can return the servo back exactly to that spot. When we again restart the animation and the servo hasn't settled or moved, ARC will assume it knows it's position on the next start up and all will be well. The problem is "what if" the servo has moved when powered down? How do you get it back to the exact parked position before sending it out on it animation adventure? The servo will park where it started out and may not now be in alignment with the hole it needs to enter. Disaster and destruction will ensue as everything gets sucked in. One thing I tried was to install a limit switch to let ARC know the arm is centered. If not it would not retract. However then I had a arm sticking out that I needed to manually retract.
I'm very interested in how you overcome this. I really want to start using ARC's servo commands instead of Simple Serial. So much simpler.
You hit the nail on the head. The animation mounting system that I created is modular and allows the user to mount hardware magnetically onto a plate that is also the seat for R2’s dome. The periscope you see is magnetically seated on the plate and can be literally pulled off for maintenance and traveling to philanthropic venues and conventions. So this module’s motor system is absolutely going to shift during transport.
Unless ARC can use a limit switch to reassign home servo position, I don’t know how else it can be accomplished outside of simp serial.
Heres a link to my YouTube channel so you can see the Warp Core Base Plate I created for the Warp Core Dome System.
https://youtube.com/user/Warpcell
from: https://www.dimensionengineering.com/datasheets/KangarooManual.pdf
The rotary motor has a single limit switch that I use to register the home position when sought out by the home command. Are you saying there is a way to use servo commands to seek out and find the home switch? For example, when I send a movement command in serial (2, p3000 s2000) to the Roo, it takes a few revolutions to get there and the Roo ignores the limit switch every time it hits it. Yet, if I send the home command (2, Home) the rotary moves until it hits the switch and at that point Home is re-established and the p3000 is cleared as the home is now P0 no matter how many revolutions it took to get there.
Presently, if I tune the Roo with the limit switch in servo mode, the switch will register as position 180. This effectively limits the rotary to a single rotation. A mechanical stop tune may be better but I would need to literally grab the periscope at certain points during the tune to establish the end points of the rotation because currently there are none. A Teach Tune is not possible due to the gear ratios within the rotary mech.
That would be super awesome if a servo command can take the place of the serial commands. However, the Roo does not currently calibrate at setup. It only calibrates during the initial Tune. Currently, I have launch commands upon connection that start the baud rate, start the motors, raise the lifter, home the rotary, all before lowering the periscope into the dome; all done in simple serial.
Does that make sense?
Thank you,
Doug
If so, we'll have to not call it a limit switch. If that's the case, then yeah we can't use it at all.
So I'm not sure how the "servo mode" works with the kangaroo when using an encoder and the shaft is moved without power on. How does it recalibrate itself. I did read that it can recognize rubber stoppers because the current is monitored.
You are working on the same problems I was when I built my B9 robot arm. If the arm retracted into the torso without being completely centered then it would hit the arm hole and stall. Thank God the Kangaroo detects the stall (or runaway) and stops. However I found damage can still happen to the structure or motors.
The only solution I could come up with was to add a center switch that was monitored by an ADC port on the EZB. I had the main animation script wait and check that switch ADC voltage first before the arm was allowed to retract. If after sending the command to center and retract and that switch was not closed it would not retract.
A few things I didn't like about that solution;
*One, I had to come up with a second animation script that would start up automatically (using If/Else If commands) upon failure that trys to re-center the arm and close that switch.
*Two, there was a pause while the script checked that script.
*Three, the animation took longer then wanted if centering failed.
*Four, If the arm couldn't ultimately find center I had to park the arm manually with ARC movement controls.
I wish I was in the position and had time to work on this here on my robot along with you. However I'm currently neck deep in another project I can't stop. However finding a solution to this issue or better way to command a Roo may help make my current project more elegant. I'll stay tuned. Please keep us up to date. I'll help if I can and learn from you along the way.
Have you loaded the kangaroo software and read the manual? Let me ask questions because i think there's a lot of information in this thread that I'm missing. I'll ask more questions per each response.
1) When you power-on the robot and query GetP, what does GetP return? Is it a 0? I'm not asking about your initialization script or anything. Just when you apply power to the kangaroo, what does GetP return
2,E1\r\n
If requested after initializing baud rate but before homing
2,P43\r\n
if requested after initialization of baud rate and after homing
And here’s what the manual says it is....
Get position. (Getp) : Returns the channel number, followed by a comma, followed by a capital P if the move is completed or a lowercase p if the move is still going on, followed by the position in units (plain text) followed by a return and a newline
2) Does "homing" use a limit switch or something? How do you know what physical position "home" is? Is that simply using the encoder or is there a switch of some sort that you use?
3) Can you send a command that moves the rotation into a specific degree? If it starts at 0, and home is 43, can you say "Go to 519"? Or do you tell it to move, keep monitoring the position yourself, and then tell it to stop?
Dave, this could easily be adapted for your application! Once we emptied the UART we could consistently cut out the data we needed from the returned Getp data. It kept building up in the system. Also, the "/r/n" at the end of the data (2,P43/r/n) is only considered 2 characters.
The following code reads the rotary motor position for authorization to lower the periscope. It has a tolerance of 1 line in either direction otherwise it will raise the periscope to prevent it from crashing into R2's dome.
DJ, thank you for starting the trouble shoot.
Code:
Thanks for all your work and sharing this!
Do you have any thoughts on how to proceed if the periscope does not lower because it didn't line up? Perhaps you could have the script check it the periscope successfully lowered or stopped? If not try the parking sequence again? Of course you don't want the thing to be spinning around if it has only partially retracted into the body.
Have fun and thanks again!!
The fun is just beginning!
Are you on astromech.net? Would like to exchange emails for future collaboration if you like. I don’t see a way on this site to send you a private message. If you want to see some robotic hobbyists strung out on Star Wars, astromech is a free community working directly with Disney through our 501c3. We supply the droids for a great many of their events and projects. You are welcome to join. I am Warpcell on the site.
Yes I am on astromech.net but I haven't signed on for many years. I cant even remember my ID. I think it's simply "dschulpius". Lots of other stuff has captured my interests. Back then I was dreaming what my next robot build would be. Turns out the B9 robot building universe was and still is capitalizing my time and money. LOL. I'd love to one day build a full sized R2 or even a Robby the Robot from Forbidden Planet.
It would be great to swap ideas with you ay any time. My email that I share freely is dschulpius@gmail.com. Looking forward to hooking up.
When I get my next free moment that is not in demand I'll look you up on astromech.net.
Thanks again!