Since you're using visual studio, it's pretty easy to setup
communications. Create a new SerialPort object on whatever COM port
the 'bot is connected to, call that object's Open function and you're
good to go. You don't need to specify baud rate, parity bit, data
bits, etc. as the class already defaults to the settings the Create
uses. Then you can call it's Read (or ReadByte if you prefer) and
Write commands to communicate with it. Be sure to call its Close
function when you close your program or you may have trouble with that
port showing up as closed or otherwise inaccessible.
I just set up a namespace full of constants for all the open interface
OpCodes with <summary> tags on them, so it's quite easy to work with
in Visual Studio. You'll find an incomplete file that does something
similar among the thirty billion documents in that CreateOI C#
framework. I'd be happy to send it your way if you like. Add a
reference to that namespace and you can type out
"SerialPortName.Write(OpCodes." and get a nice drop down box of all
the OpCodes and what kind of data bytes they expect.
(If you think you'll be using the Create's music player, I have the A0
through D5 notes defined as well in another file.)
Sincerely,
Delvan Neville
> --
> You received this message because you are subscribed to the Google Groups
> "iRobot Create Forum" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/irobot-create-forum/-/9WsRa4HfqOAJ.
> To post to this group, send email to irobot-cr...@googlegroups.com.
> To unsubscribe from this group, send email to
> irobot-create-f...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/irobot-create-forum?hl=en.
The MSDN site is pretty useful when you're working with a .NET language.
Sincerely,
Delvan Neville
Yes, in safe mode it'll stop if the cliff sensors trip or if one of
the wheels drop. If you think you'll be using it around stairs, keep
in mind the cliff sensors are on the front and sides of the Create, so
be careful about driving in reverse.
Sensor packet ID 7 covers the bumper and wheel-drop states. There are
no drop-offs at my facility, so I only care about the bumper status.
Here's an edited version of my C# code for handling the bumper packet
once it's ready to be read.
byte wheelAndBump = (byte)yourSerialPortObjectHere.ReadByte();
if ((wheelAndBump & 0x01) == 1)
bumperRight = true;
else
bumperRight = false;
if ((wheelAndBump & 0x02) == 2)
bumperLeft = true; //If the first or second bits are
1, the bumper is pressed.
else
bumperLeft = false;
If you query for the distance or angle packets, they're two byte
values with the high byte sent first, so you can read them with
something like this:
int newDistance = (short)((yourSerialPortObjectHere.ReadByte() << 8) |
(yourSerialPortObjectHere.ReadByte() & 0xFF));
Sincerely,
Delvan Neville
> --
> You received this message because you are subscribed to the Google Groups "iRobot Create Forum" group.
When you start up, make a new serial port object. Call Open() then
send OpCode.Mode Passive, wait a moment, then OpCode.Mode Safe
I have mine run a new set of packets every 100ms (stream by default is
every 15ms). You can make a Timer object to send & read your sensor
packets regularly.
If that's really all you want it to do, we're talking 10 or 20 lines
of code for that. A timer (you can use the visual studio component
toolbox to add it if you want) and have it send OpCode.Query 7 (the
bumper sensor packet ID), then reads a byte and updates your bumper
status variables like the code I posted and/or trigger whatever you
want to happen when it bumps into a wall.
Your drive, turn in place and stop functions are just one line each:
OpCode.DriveDirect [two bytes for one wheel] [two bytes for the other
wheel].
When you close your program, call the Close() routine on your serial port.
Sincerely,
Delvan Neville
Sincerely,
Delvan Neville
...
It's a shame iRobot didn't put out just a barebones project that just
includes, for example, a drive forward and stop if bumper is hit. Then
the stream and objects would already be there, and developers can add
their actual movement.
Sincerely,
Delvan Neville
> --
> You received this message because you are subscribed to the Google Groups
> "iRobot Create Forum" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/irobot-create-forum/-/WtEl5AEs6pAJ.
Ah, gotcha, I handle the forums via email too, didn't realize that message wasn't there :D
On Feb 26, 2012 10:27 AM, "Roy" <royal...@gmail.com> wrote:
Exactly - the Kinect is why we need the laptop.
But I didn't post that we're using a Kinect on the forum, it was in a
private email to you, so JoeCreate wouldn't have known.
On Feb 26, 8:54 am, dnevill <dnev...@gmail.com> wrote:
> I'm sure the laptop is on the robot mainly...
> On Sun, Feb 26, 2012 at 7:47 AM, JoeCreate <2joes...@gmail.com> wrote:
> > At Laptop on a Robot th...