Asked
Resolved Resolved by Dave Schulpius!

Getp Command For Kangaroox2 For Use With If/Endif??

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?


Related Hardware EZ-B v4

ARC Pro

Upgrade to ARC Pro

Unleash your robot's full potential with the cutting-edge features and intuitive programming offered by Synthiam ARC Pro.

#33  

Outstanding. I agree, loads of fun. It's amazing how a small script like this if done right can help you throughout your whole project.Please keep us up to date on what's happening. I love this stuff.

#34  

Dave,

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.

#35  

Hay @dbickert, somehow I missed your last post.

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 [email protected]. 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.

#36  

Yes.  You are correct with your astromech ID.  I was able to find that call sign on a member search.  I'll send you an email.

Thanks again!