PDA

View Full Version : Need help with nested routines...



crispy
05-22-2005, 07:57 AM
Hello,
I WAS WANDERING IF YOU CAN HELP WITH A SITUATION THAT I AM HAVING.
I HAVE A CLAW THAT USES A SERVO BUT I NEED THE SERVO TO CLOSE CONSTANTLY WHILE WE INPUT COMMANDS FOR THE MOTION OF THE BOE BOT. THE BOE BOT HAS BEEN MODIFIED INTO A DIFFERENT CHASIS THAT DOESNT HAVE THE SENSORS MOUNTED. WHAT I HAVE IS THE WIRELESS ROBOT EYE. WHAT I INITIALLY WANTED IT TO DO WAS TRACK AN OBJECT (A BALL) PICK IT UP AND RETURN WHERE IT LEFT. WHAT I AM NOW GOING TO DO IS MANUALLY CONTROL IT WITH THE COMMANDS FROM THE LAPTOP. BUT WHEN WE USE A COMMAND TO CLOSE THE CLAW IT HAS TO LOOP TO HOLD THE OBJECT. IF IT DONT LOOP IT WILL DROP THE BALL.
WHAT IS HAPPENING IS IT LOOPS TO KEEP THE CLAW CLOSED BUT STAYS IN THAT ROUTINE AND WILL NOT ALLOW FOR AN ADDITIONAL INPUT.
SO.....
I NEED TO LOOP THE CLAW SERVO CLOSED IN A NESTED ROUTINE WHILE I CAN CONTROL THE BOE BOT DIRECTION ONCE IT REACHES ITS DESTINATION I WANT TO STOP THE LOOP AND CONTINUE TO CONTROL THE ROBOT TO REPEAT THE PROCESS.

IF THERE IS ANY WAY YOU CAN HELP IT WOULD BE APPRECIATED.....
THANX
·

kb2hap
05-22-2005, 10:43 AM
Post the code you currently have.
Im sure you could do other things while in that loop...
instead of doing a pause in your routine you could be doing other activities that take
the same amount of time as the pauses in the routine.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
DTQ

crispy
05-23-2005, 04:58 AM
Here is the code that we have for our project. If you loop the Close_claw: routine it will lock into that routine.... and not allow me to return to the control panel.... Well, it is probably my lack of experience that is making this happen....We also made nested routines with the control panel in the loop but it pauses waiting for a input return..... I hope you can give me a pointer on how to make this work....... I want the close claw to loop until broken and to be able to use the other commands for manuevering....

Thanx....

This is the code without any loop's just to get a basic interpretation of what I am trying to achieve...



' -----[ Title ]--------------------------------------------------------------
' Basic Boe-Bot Control with RoboEye - RoboEyeBoeBot.bs2
' Control the Boe-Bot with the RoboEye Terminal while observing incoming
' video feed.

' {$STAMP BS2}······························ ' Stamp directive
' {$PBASIC 2.5}····························· ' PBASIC directive

' -----[ Variables ]----------------------------------------------------------

pulseCount···· VAR···· Byte················· ' FOR...NEXT loop counter
direction····· VAR···· Byte················· ' Direction control
distance······ VAR···· Byte················· ' asdf


' -----[ Initialization ]-----------------------------------------------------

' -----[ Main Routine ]-------------------------------------------------------

controlPanel:
· SEROUT 15, 84, ["Direction?",CR]
· SERIN 15, 84, [direction]
· PAUSE 10
· SEROUT 15, 84, ["Distance?",CR]
· SERIN 15, 84, [DEC3 distance]
· IF direction = "F" THEN Forward_Pulse
· IF direction = "B" THEN Back_Up
· IF direction = "L" THEN Turn_Left
· IF direction = "R" THEN Turn_Right
· IF direction = "C" THEN Close_Claw
· IF direction = "O" THEN Open_Claw
· IF direction = "U" THEN Up_Claw
· IF direction = "D" THEN Down_Claw
· IF direction = "G" THEN Lunge_forward
· GOTO controlPanel

' -----[ Subroutines ]--------------------------------------------------------

Forward_Pulse:······························ ' Send a single forward pulse.
· FOR pulseCount = 0 TO distance
· PULSOUT 12,650
· PULSOUT 13,850
· PAUSE 20
· NEXT
· RETURN

Turn_Left:·································· ' Left turn, about 90-degrees.
· FOR pulseCount = 0 TO distance
··· PULSOUT 12, 650
··· PULSOUT 13, 650
··· PAUSE 20
· NEXT
· RETURN

Turn_Right:
· FOR pulseCount = 0 TO distance············ ' Right turn, about 90-degrees.
··· PULSOUT 12, 850
··· PULSOUT 13, 850
··· PAUSE 20
· NEXT
· RETURN

Back_Up:···································· ' Back up.
· FOR pulseCount = 0 TO distance
··· PULSOUT 12, 850
··· PULSOUT 13, 650
··· PAUSE 20
· NEXT
· RETURN

Close_Claw:

· FOR pulseCount = 0 TO 100
··· PULSOUT 15, 605········· 'Fully closed 605 opened 350
··· PAUSE 20
· NEXT
· RETURN

Open_Claw:

· FOR pulseCount = 0 TO 100
··· PULSOUT 15, 350
··· PAUSE 20
· NEXT
· RETURN

Up_Claw:
· FOR pulseCount = 0 TO 25
··· PULSOUT 14, 940
··· PAUSE 20
·· NEXT
·· RETURN

Down_Claw:
· FOR pulseCount = 0 TO 25
··· PULSOUT 14, 350
··· PAUSE· 20
· NEXT
· RETURN

Lunge_forward:···· 'To move forward in small increments for object grasping
· FOR counter = 1 TO 30
··· PULSOUT 15, 350········· 'Fully closed 605 opened 350
··· PAUSE 20
··· PULSOUT 14, 575············ '575 down, 940 up
··· PAUSE 20
··· PULSOUT 12,650
··· PULSOUT 13,850
··· PAUSE 20
· NEXT
· RETURN


Post Edited (crispy) : 5/23/2005 2:06:28 AM GMT

txducker
05-24-2005, 02:03 AM
In your Lunge_forward:·subroutine, the counter variable was never defined.
Try adding the following·line in your --[ Variables ]-- section
counter······· VAR···· Byte················· ' counter used in for next loopes
I hope that helps.