
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...
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?
Hmm, it's real annoying to parse text, which is generally always an issue in situations like this.
I have to say, that r2d2 dome is stunning - like, really really stunning! I'm so glad you shared the video because it made my day
As for the suggestion of turning these kangaroo instances into servos... If you're using encoders, and the kangaroo is also giving position feedback... sounds like you're one step away from becoming a servo. I believe letting the kangaroo handle the positioning will be great.
I do not recommend configuring as a continuous rotation servo, as a continuous rotation servo doesn't have positioning accuracy.
My recommendation is to rewatch that live hack and configure one of your kangaroo instances as a servo. I really do think it'll do what you're looking for and add that extra sense of security nothing buggers up. Then, you will be able to move the components with simple servo commands, or use any servo control
It'll be neat because with the camera, you can have the dome track people or colors and objects, etc... All because it'll use the servo control
I've always wanted to try to try the servo option on the Kangaroo and give it a go with ARC's servo commands. I did try it once a long time ago and couldn't get it to work properly. I think it was back when the V3 EZB was out. I didn't have the patients at the time to keep working on the issue. I need to give it a go again.
Dave - have a look at the live hack. Here's two useful links..
Tevans did this older tutorial: https://synthiam.com/Community/Tutorials/Sabertooth-Kagaroo-DC-motors-as-Servos-16229
and I did this live hack: https://synthiam.com/Community/HackEvents/Dimension-Engineering-Sabertooth-Kangaroo-19484
Thanks DJ. I did see those links in your post earlier in this post. I do intend to check them out.
Thank you for the compliment DJ! R2 has been an 8 year project and runs on two (soon to be three) EZBv4/2s. I've never parsed a text. What's the trick?
I've thought about the servo control route but I don't think I could get it to do this with regular servo commands. That's why I asked about the continuous servo.
Dave, I'll try your code suggestion too. Thank you!
I think you still could a regular servo - because with the kangaroo utility, specify that 180 degree position has actually rotated two or three times around.
It's kind of like using one of those 1000 degree winch servos. The output shaft rotates many more times between the 1-180 degree position command. You see, the command of what position to be in (i.e. 165 or 135, etc) is really not a degree. It sort of works out to a degree with a regular PWM servo, but it doesn't need to be. Take Robotis Dynamixel servos for instance. they go from 1-1023, which can be 180 degrees... where 1 is 1 degree and 1023 is 180 degrees.
So in your case, ARC's 180 degree would really have been 1000 degrees or something on the output. Does that make sense?
I know it's a different way to do it - but once you accomplish it and it clicks. Then suddenly it'll open up doors to many more servo-like motor configurations you can do with the kangaroo+sabertooth. It means less code (well, practically no code)
The disco mode is awesome! I love it. It blows my mind.
Thank you DJ! I'll save this DEScribe profile and create a new one to try it out. First out, I can see and advantage to simp serial because I can use the home command to essentially reset the encoder output which keeps me from having to basically unravel the animation to get the rotary back to the home position. Unless, of course, there is a way to reset from the home position within a servo command. Right now I have the rotary going to position 6000 and homing (which wipes out the 6000) then it goes -6000 and homes before it drops. Doing it by servo would be simple because I can just sleep and then have it reverse to the starting point for this animation. Now, if I want it to go to position 6000 and drop without traveling back to origin, that's where I would need to reset the servo position so I could start another animation without having to unravel the first. Does that make sense and is it possible?
Dave, thank you for the compliment!