RoboRealm MCU Examples / Help Needed
SteveWoodrough
Posts: 190
Well Ive gotten this far with my Robo Magellan project:
https://www.youtube.com/watch?v=8eACDNHX7Lw
and now Ive decided to add some vision.
Does anybody have experience they can share on using the Propeller_Communicator.Spin object and the RoboRealm MCU module?
Robo Realm (RR) seems like a pretty low cost, powerful enough tool, and Ive spent a few hours messing with it and I can now drive my Magellan Bot around the basement with BT and a mouse using the RR Serial module. The Serial module passes serial data to and from RR, but you cannot really associate data to a variable within RR.
What I want to do next is to get data from the Prop into RR using the MCU module. From what I can tell looking at the code below the key is the mailboxes, but Im not real sure exactly how this is supposed to work. RR did not have any examples and I could not come up with much on Google or Forum searches.
Below is the spin code for the communicator from the RR website:
I just need a nudge in the right direction.
Best Regards,
Steve
https://www.youtube.com/watch?v=8eACDNHX7Lw
and now Ive decided to add some vision.
Does anybody have experience they can share on using the Propeller_Communicator.Spin object and the RoboRealm MCU module?
Robo Realm (RR) seems like a pretty low cost, powerful enough tool, and Ive spent a few hours messing with it and I can now drive my Magellan Bot around the basement with BT and a mouse using the RR Serial module. The Serial module passes serial data to and from RR, but you cannot really associate data to a variable within RR.
What I want to do next is to get data from the Prop into RR using the MCU module. From what I can tell looking at the code below the key is the mailboxes, but Im not real sure exactly how this is supposed to work. RR did not have any examples and I could not come up with much on Google or Forum searches.
Below is the spin code for the communicator from the RR website:
I just need a nudge in the right direction.
Best Regards,
Steve
CON _clkmode = xtal1 + pll16x _xinfreq = 5_000_000 rxpin = 31 ' Receive on I/O pin 1 <- black from master black txpin p1 txpin = 30 ' Transmit on I/O pin 0 -> red to master red rxpin p0 ServoCh1 = 0 'Steering servo ServoCh2 = 4 MCU_GET_ID = 1 MCU_END_FRAME = 2 MCU_SET_NUMBER_MAILBOX = 3 MCU_SET_TEXT_MAILBOX = 4 MCU_SET_LOGIC_MAILBOX = 5 MCU_GET_NUMBER_MAILBOX = 6 MCU_GET_TEXT_MAILBOX = 7 MCU_GET_LOGIC_MAILBOX = 8 VAR BYTE mailboxToSend[20] BYTE mailboxSendFlag[20] LONG intValue[20] BYTE logicValue[20] LONG textValue[20] BYTE textStore[1024] LONG textStoreTop BYTE buffer[8] BYTE command BYTE crc BYTE mailbox LONG hold LONG i,j LONG lvalue LONG tvalue OBJ serial : "FullDuplexSerial" ' "Extended_FDSerial" '' f : "Float32Full" SERVO : "Servo32v7.spin" PUB Main | DutyCycle ' new stuff DutyCycle dira[16]~~ serial.start(rxpin,txpin,%0000, 115200) '- rxpin,txpin,mode,Baud textStoreTop := 0 repeat repeat command := serial.rx while command & 128 == 0 crc := command command := command ^ 128 case command MCU_GET_ID: serial.Str(String("MCUC")) MCU_SET_NUMBER_MAILBOX: if ((buffer[0] := serial.rx)&128) next crc ^= buffer[0] if ((buffer[1] := serial.rx)&128) next crc ^= buffer[1] if ((buffer[2] := serial.rx)&128) next crc ^= buffer[2] if ((buffer[3] := serial.rx)&128) next crc ^= buffer[3] if ((buffer[4] := serial.rx)&128) next crc ^= buffer[4] if ((buffer[5] := serial.rx)&128) next crc ^= buffer[5] if ((buffer[6] := serial.rx)&128) next if ((crc&127)<>buffer[6]) next intValue[buffer[0]] := buffer[1]|(buffer[2]<<7)|(buffer[3]<<14)|(buffer[4]<<21)|(buffer[5]<<28) mailboxToSend[buffer[0]] := 0 MCU_SET_LOGIC_MAILBOX: if ((buffer[0] := serial.rx)&128) next crc ^= buffer[0] if ((buffer[1] := serial.rx)&128) next crc ^= buffer[1] if ((buffer[2] := serial.rx)&128) next if ((crc&127) <> buffer[2]) next logicValue[buffer[0]] := buffer[1] mailboxToSend[buffer[0]] := 0 MCU_SET_TEXT_MAILBOX: if ((mailbox := serial.rx)&128) next crc ^= mailbox hold := textStoreTop textStoreTop-- repeat textStoreTop++ textStore[textStoreTop] := serial.rx crc^=textStore[textStoreTop] while (textStoreTop<1024)&(textStore[textStoreTop]<>0) textStoreTop++ if ((crc&127)<>serial.rx) textStoreTop := hold next textValue[mailbox] := @textStore[hold] mailboxToSend[mailbox] := 0 { stream values to mailbox } MCU_GET_NUMBER_MAILBOX: mailbox := serial.rx if (((crc^mailbox)&127)<>serial.rx) next mailboxToSend[mailbox] := MCU_GET_NUMBER_MAILBOX MCU_GET_LOGIC_MAILBOX: mailbox := serial.rx if (((crc^mailbox)&127) <> serial.rx) next mailboxToSend[mailbox] := MCU_GET_LOGIC_MAILBOX MCU_GET_TEXT_MAILBOX: mailbox := serial.rx if (((crc^mailbox)&127) <> serial.rx) next mailboxToSend[mailbox] := MCU_GET_TEXT_MAILBOX MCU_END_FRAME: processMailboxes { note that Text values are lost after being processed as we } { will reuse the buffer for the next frame } textStoreTop:=0 repeat i from 0 to 19 if (mailboxToSend[i]<>0)&(mailboxSendFlag[i]<>0) case (mailboxToSend[i]) MCU_GET_NUMBER_MAILBOX: lvalue := intValue[i] serial.tx(buffer[0]:=MCU_GET_NUMBER_MAILBOX|128) serial.tx(buffer[1]:=i) serial.tx(buffer[2]:=lvalue&127) serial.tx(buffer[3]:=(lvalue>>7)&127) serial.tx(buffer[4]:=(lvalue>>14)&127) serial.tx(buffer[5]:=(lvalue>>21)&127) serial.tx(buffer[6]:=(lvalue>>28)&127) serial.tx((buffer[0]^buffer[1]^buffer[2]^buffer[3]^buffer[4]^buffer[5]^buffer[6])&127) MCU_GET_LOGIC_MAILBOX: serial.tx(buffer[0]:=MCU_GET_LOGIC_MAILBOX|128) serial.tx(buffer[1]:=i) serial.tx(buffer[2]:=logicValue[i]&127) serial.tx((buffer[0]^buffer[1]^buffer[2])&127) MCU_GET_TEXT_MAILBOX: tvalue := textValue[i] serial.tx(buffer[0]:=MCU_GET_TEXT_MAILBOX|128) serial.tx(buffer[1]:=i) crc := buffer[0]^buffer[1] j := 0 repeat while (byte[tvalue[j]] <> 0)&(j<254) byte[tvalue[j]] &= 127 crc ^= byte[tvalue[j]] j++ j++ buffer[2] := crc&127 serial.tx(buffer[0]) serial.tx(buffer[1]) serial.str(tvalue) serial.tx(buffer[2]) mailboxSendFlag[i] := 0 PUB processMailboxes { Assumes values for servos are in mailbox 0 and 1 } SERVO.Set(ServoCh1,intValue[0]) SERVO.Set(ServoCh2,intValue[1]) if (intValue[2]<>0) outa[16]~~ else outa[16]~ intValue[3] := ina[17] mailboxSendFlag[3] := 1
Comments
I have some links to Propeller based machine vision techniques in post #4 of my index. The CMUcam4 can detect color blobs.
Cone finding would be a logical use, but my hope is to circumnavigate my house and stay on the grass and out of the gardens! Essentially Im looking for path planning and obstacle avoidance tools. Ping sensors are good, but there are limitations, etc.
Ive always found vision processing to be an amazing feat and to my untrained eye, RoboRealm seems to have some pretty diverse and powerful vision processing filters, and capabilities. I dont think RR is strong enough to guide a car down a highway, but for a gear head hobbyist, its awful easy to use. I just need to get past this hurdle.
Regards,
Steve