Random header image... Refresh for more!

Um… No.

March 1, 2010   No Comments

Well, That Could Have Something To Do With It…

public CvPoint GetAverageVelocity()
{
    double avgX = BombPositions.Average(bomb => bomb.X);
    double avgY = BombPositions.Average(bomb => bomb.Y);

    return new CvPoint((int)avgX, (int)avgY);
}

And that’s why I don’t work for NASA.

March 1, 2010   No Comments

Bug Tracking

That ain’t right.

And I only have five hours left.

March 1, 2010   No Comments

That Could Be A Problem

Can you spot the bug here?

public void ButtonDown()
{
    Rotate(NxcMotorPort.OUT_B, -50, 45);
}
public void ButtonUp()
{
    Rotate(NxcMotorPort.OUT_B, -50, 45);
}

February 28, 2010   No Comments

Needs a bit of adjustment.

The button pressing motor just hit the button so hard that it knocked the paddle out of the cage AND knocked the entire motor assembly off the base.

I think I need to tune the power levels a bit…

February 28, 2010   No Comments

Twisty Little Passages

I don’t think that was supposed to happen.

February 26, 2010   No Comments

And right into the next bug…

So, I fix the bug with the waiting and I realize there’s another bug close behind.  It’s now properly waiting for the action to complete, the trouble is that the action is the last action I told it to do.  In other words, I start it up and tell it to rotate 10 degrees and it does nothing.  Then I tell it to rotate 360 degrees and it goes 10.  Then I tell it to go 180 and it goes 360.

The NXT program is supposed to wait for a “Go!” signal, then read two packets from the same mailbox for values to pass to the motor.  The mailbox is a queue, so if it’s reading the Go! signal, then racing to the motor command before the other two messages arrive, then the mailbox should be out of sync for the next Go! signal.

But that’s the scenario that makes the most sense here.  It gets a “Go!” then goes straight to the motor before the next two packets arrive.  So it reads zero and does nothing.  Then the next Go! code comes in.  By then, the values have been written from the first request, so they’re what gets sent to the motor.  But that would make it out of sync.  The second Go! code would be reading a boolean, then there’d be a number where a bool should be, and finally, the bit that should have a number will get the string “Go!”.

So…  WTF?

February 25, 2010   No Comments

Achievement Unlocked: Wild Goose Chase

So, I found out why it wasn’t waiting…

It was waiting and I’m just a moron.

I had my program set up to send a Bluetooth message to the NXT to retrieve the contents of Mailbox 10.  One the NXT, I was writing true to Mailbox 10 when I started an action and false when the action completed, so that Mailbox 10 could be used as a “Busy” signal.  My program would poll until Mailbox 10 reported false, then continue.

Thing is, I was sending the “Clear Mailbox” flag to the NXT.  So the NXT gave me the contents of Mailbox 10, then cleared Mailbox 10.  The first read returned true, because the motor was busy.  The second read returned false, not because the action had completed, but beacuse the “Clear Mailbox” flag caused Mailbox 10 to be filled with a bunch of zeroes.

February 25, 2010   No Comments

This Code Doesn’t Work

The following is a snippet of code that reproduces a bug I came across today.

string[] strings = new string[] { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine" };

foreach (string str in strings)
{
    ThreadPool.QueueUserWorkItem( delegate { Console.WriteLine(str); } );
}

It should print out the numbers “zero” through “nine”.  It doesn’t work.  Why not?

I’ll write up the answer tomorrow, but I want to see if anyone else can get it first.

January 22, 2010   No Comments