Sending a Script to the Create?

27 replies [Last post]
Jeremy Rand
Jeremy Rand's picture
Title: Botball Youth Advisory Council
Joined: 04/03/2009
Posts:
BotPoints: 1168
User offline. Last seen 7 years 20 weeks ago.

Try the flash drive (WiFi should work too, if you know how to do that). The KISS-IDE simulator probably doesn't have an implementation of create_write_byte().

-Jeremy Rand
Senior Programmer, Team SNARC (2012-2013), Norman Advanced (2010-2011), Norman HS (2008-2009), Norman North (2005-2007), Whittier MS (2003-2004)
2012-2013 VP of Tech, 2011 President, Botball YAC (2009-2013)
Mentor, Alcott and Whittier MS

Aaron Mutchler
Title: NooBot
Joined: 02/17/2013
Posts:
BotPoints: 29
User offline. Last seen 8 years 9 weeks ago.

I tried that and it compiled on the CBC fine but didn't seem to work. I believe it was an error on my part in writing the code incorrectly, so I should be able to figure it out. I also looked at Garrett's code and I got that to work. I don't understand though how it actually sends the script. Everything else about the code makes sense, but I don't understand where the line of code is that says send a script.

Marty Rand
Marty Rand's picture
Title: Botball Youth Advisory Council
Joined: 07/04/2009
Posts:
BotPoints: 253
User offline. Last seen 8 years 8 weeks ago.

In Garrett's library, the script is sent in every function. serial_write_byte()/create_write_byte() send bytes to the create. The "script" is just a collection of those bytes. With Garrett's library, a program might look like this:

  1. int main()
  2. {
  3. create_connect();
  4. create_drive_segment(500,1000);//drive forward at full speed for 1 meter (1000mm)
  5. create_stop();//stop the create
  6. //The scripts don't automatically stop movement. This lets the movements become smooth when strung together
  7. }

*****I have not tested this code on a CBC, so compile errors are possible*****

We are using Garrett's library for our bots this year and I've been the one in charge of making it Link friendly. Garrett's library required a bunch of modifications to run on the Link. My team will release these changes after GCER for sure, but I cannot promise anything before that (perhaps after the OK regional though). Also, know that the code on GitHub has been reworked since GCER 2012 and has some bugs in the uploaded code that are not Link specific. For example, I know servos and create_sync() don't work out of the box.

-Marty Rand
{
Senior programmer at Norman Advanced Robotics

Former senior programmer at Whittier Middle School

Youth Advisory Council

All around nerd
}

Aaron Mutchler
Title: NooBot
Joined: 02/17/2013
Posts:
BotPoints: 29
User offline. Last seen 8 years 9 weeks ago.

How can I find what the function is to send a byte to the LINK?

Marty Rand
Marty Rand's picture
Title: Botball Youth Advisory Council
Joined: 07/04/2009
Posts:
BotPoints: 253
User offline. Last seen 8 years 8 weeks ago.

For the CBC and Link it is create_write_byte() . You'll notice a #define at the top of Garrett's library changing all the serial_write_byte()'s to create_write_byte()'s. To find which byte to send, you will need to look at the Create manual from iRobot ( http://www.irobot.com/filelibrary/pdfs/hrd/create/Create%20Open%20Interf... ). Garrett's library uses create_write_byte() for all the create functions. You can use Garrett's library for the tournament (assuming you can get it to compile) if you want, or make your own. Garrett's isn't very well documented, so if you have questions on how various parts of the code work, I can point you in the right direction.

-Marty Rand
{
Senior programmer at Norman Advanced Robotics

Former senior programmer at Whittier Middle School

Youth Advisory Council

All around nerd
}

Aaron Mutchler
Title: NooBot
Joined: 02/17/2013
Posts:
BotPoints: 29
User offline. Last seen 8 years 9 weeks ago.

I got the create_write_byte() to work and I've done some amount of work with that to get good move function (I am at this point using the input buffer rather than scripts). I have several questions about the input buffer on the Create.
1) Are there any downsides or dangers of using the input buffer rather than scripting?
2) What happens if you send it more than 255 bytes?
3) What constitutes as "in quick succession" (referring to your paper on Advanced Create OI scripting)?
4) How do you know when the input buffer has a slot open/ is empty?

dgoree
Title: NooBot
Joined: 02/13/2012
Posts:
BotPoints: 130
User offline. Last seen 5 years 48 weeks ago.

I can't answer those questions, but I thought I would let you know that we have updated the libraries. http://normanadvanced.com/development/software/

-Daniel Goree
Former...
Senior Project Manager
President
Norman Advanced Robotics (13-0113)

Aaron Mutchler
Title: NooBot
Joined: 02/17/2013
Posts:
BotPoints: 29
User offline. Last seen 8 years 9 weeks ago.

I appreciate this, however I would like to build my own library

Jeremy Rand
Jeremy Rand's picture
Title: Botball Youth Advisory Council
Joined: 04/03/2009
Posts:
BotPoints: 1168
User offline. Last seen 7 years 20 weeks ago.

@Aaron, sorry for the delayed reply, my main laptop died on me and it only recently got fixed.

1) Input Buffer Scripts can't loop, while Conventional Scripts can. I never use Conventional Scripts anymore; there aren't really any major drawbacks.
2) If you overflow the input buffer, some of the bytes may be dropped. This would make your Create do weird things depending on which bytes are dropped. You don't want this to happen.
3) I'm not certain what you're referring to, can you quote the section so that I know what context you mean?
4) I wrote a function called create_sync(), which I think is in Garrett's library. The idea is, you send an Input Buffer Script, and then ask the Create to reply with a sensor packet (the script and the sensor request must sum to under 256 bytes). The Create will only send the packet once it finishes the script. When your CBC receives the packet, you know that the script commands you sent have finished, and you can send more data.

Hope this info helps.

-Jeremy Rand
Senior Programmer, Team SNARC (2012-2013), Norman Advanced (2010-2011), Norman HS (2008-2009), Norman North (2005-2007), Whittier MS (2003-2004)
2012-2013 VP of Tech, 2011 President, Botball YAC (2009-2013)
Mentor, Alcott and Whittier MS

Aaron Mutchler
Title: NooBot
Joined: 02/17/2013
Posts:
BotPoints: 29
User offline. Last seen 8 years 9 weeks ago.

I can't find any documentation for the serial_read() function or the source code for it so I can tell when the LINK has received the data packages. Do you have any knowledge of this function?