Need help with nested routines...
crispy
Posts: 2
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
·
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
·
Comments
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
Thanx....
This is the code without any loop's just to get a basic interpretation of what I am trying to achieve...
'
[noparse][[/noparse] 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
'
[noparse][[/noparse] Variables ]
pulseCount···· VAR···· Byte················· ' FOR...NEXT loop counter
direction····· VAR···· Byte················· ' Direction control
distance······ VAR···· Byte················· ' asdf
'
[noparse][[/noparse] Initialization ]
'
[noparse][[/noparse] Main Routine ]
controlPanel:
· SEROUT 15, 84, [noparse][[/noparse]"Direction?",CR]
· SERIN 15, 84, [noparse][[/noparse]direction]
· PAUSE 10
· SEROUT 15, 84, [noparse][[/noparse]"Distance?",CR]
· SERIN 15, 84, [noparse][[/noparse]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
'
[noparse][[/noparse] 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
Try adding the following·line in your --[noparse][[/noparse] Variables ]-- section
counter······· VAR···· Byte················· ' counter used in for next loopes
I hope that helps.