Roborealm can't connect with boe-bot (serial port)
Good morning, I am following the "Why track colors?" tutorial to do a school project with my boe-bot. In the Roborealm I have added The RGBFilter, the Center of Gravity, the mean filter,the VBScript Program, the serial communications and parallax_boebot.
Now, I am lost because I do not know how does roborealm communicate with boe-bot. Could anybody tell me?
I have inserted in the boe-bot this code with basic Stamp :
' {$STAMP BS2}
' {$PBASIC 2.5}
' {$PORT COM1}
x VAR Word
y VAR Word
main:
SERIN 0,84,[noparse][[/noparse]WAIT ("!"),DEC4 x,DEC4 y]
PULSOUT··14, x
PULSOUT··15, y
PAUSE 5
GOTO main
..............................................
After that, I have added the VBScript Program in the Roborealm program with the next code:
··' initialize our start motor values to neutral
··left_base = 750
··right_base = 750
··' get current image size
··width = GetVariable("IMAGE_WIDTH")
··center = width / 2
··' get the size (width or height) of the current
··' bounding box
··size = GetVariable("COG_BOX_SIZE")
··' if it is equal to "" then no object was detected
··if size <> "" then
····' get the horizontal center of gravity found by the COG
····' module
····cogX = GetVariable("COG_X")
····' if it is less than 75 the blob is on the left side
····' of the screen so move that way
····if cogX < center-5 then
······left_base = 750-(center-cogX)/2
······right_base = 750
····' otherwise move to the right if above 85 pixels (and no
····' movement if 75 < cogX < 85 )
····elseif cogX > center+5 then
······left_base = 750
······right_base = 750-(cogX-center)/2
····end if
····' if the ball is too close then we have to move backwards
····if (size>90) then
left_motor = left_base-((40-size)*2)
······right_motor = right_base+((40-size)*2)
' otherwise move forward
····else
······left_motor = left_base-((size-40)*2)
······right_motor = right_base+((size-40)*2)
··
····
····end if
····' set the final motor values to be picked up by
········SetVariable "LEFT_MOTOR", CInt(left_motor)
····SetVariable "RIGHT_MOTOR", CInt(right_motor)
····
end if
serial send sequence for Roborealm:
! [noparse][[/noparse]Left_motor] <lf> [noparse][[/noparse]Right_motor] <lf>
........................................................
Next, I have inserted serial communications and finally I have added parallax_boebot. After doing these things the boebot doesn't move, it might be some error of configuration.
can anybody help me, please?
Thank you very much
Now, I am lost because I do not know how does roborealm communicate with boe-bot. Could anybody tell me?
I have inserted in the boe-bot this code with basic Stamp :
' {$STAMP BS2}
' {$PBASIC 2.5}
' {$PORT COM1}
x VAR Word
y VAR Word
main:
SERIN 0,84,[noparse][[/noparse]WAIT ("!"),DEC4 x,DEC4 y]
PULSOUT··14, x
PULSOUT··15, y
PAUSE 5
GOTO main
..............................................
After that, I have added the VBScript Program in the Roborealm program with the next code:
··' initialize our start motor values to neutral
··left_base = 750
··right_base = 750
··' get current image size
··width = GetVariable("IMAGE_WIDTH")
··center = width / 2
··' get the size (width or height) of the current
··' bounding box
··size = GetVariable("COG_BOX_SIZE")
··' if it is equal to "" then no object was detected
··if size <> "" then
····' get the horizontal center of gravity found by the COG
····' module
····cogX = GetVariable("COG_X")
····' if it is less than 75 the blob is on the left side
····' of the screen so move that way
····if cogX < center-5 then
······left_base = 750-(center-cogX)/2
······right_base = 750
····' otherwise move to the right if above 85 pixels (and no
····' movement if 75 < cogX < 85 )
····elseif cogX > center+5 then
······left_base = 750
······right_base = 750-(cogX-center)/2
····end if
····' if the ball is too close then we have to move backwards
····if (size>90) then
left_motor = left_base-((40-size)*2)
······right_motor = right_base+((40-size)*2)
' otherwise move forward
····else
······left_motor = left_base-((size-40)*2)
······right_motor = right_base+((size-40)*2)
··
····
····end if
····' set the final motor values to be picked up by
········SetVariable "LEFT_MOTOR", CInt(left_motor)
····SetVariable "RIGHT_MOTOR", CInt(right_motor)
····
end if
serial send sequence for Roborealm:
! [noparse][[/noparse]Left_motor] <lf> [noparse][[/noparse]Right_motor] <lf>
........................................................
Next, I have inserted serial communications and finally I have added parallax_boebot. After doing these things the boebot doesn't move, it might be some error of configuration.
can anybody help me, please?
Thank you very much
Comments
I'm not sure if you have done this or not but the last line of the VB script you listed (! [noparse][[/noparse]Left_motor] <lf> [noparse][[/noparse]Right_motor] <lf>) is the code to place in the serial control not the VB script, I believe the spaces are an important part of the format too.
Jeff T.
I don't know where is my mistake.
Thank you
I have upload my project in this server: http://www.megaupload.com/es/?d=4W247RJR
Could you review if there is some mistake, please?
I am very grateful with your help.
Thank you
Jeff T
Thank you -Edward-
the problem in Bs2 code
fix the Pin to 12,13 for boebot.