Search  
Sunday, November 23, 2008 ..:: Forum ::.. Register  Login
 HomePage Minimize

 Print   

 Products Minimize

 Print   

 MSRS Minimize

 Print   

      
 RoboticsConnection Forum Minimize
SearchForum Home
  Discussions  Robot Sensors  Sensors on a Tu...
 Sensors on a Turret...
 
 8/31/2007 6:57:23 PM
Joe
4 posts


Sensors on a Turret...

Hello all,

I have just incorporated the Cam 2,3 turret on my robot. - Over the past few days, I've been experimenting with gathering data using sensors on the turret. So far, I'm not satisfied with what I have coded. I was wondering if anyone had a pattern for gathering data, moving the turret gathering more data, etc...I am using the Serializer and C# (not MSRS).

My problem has been delaying the main thread (for the turret to actually get to its spot (let's say 5 or 10 ticks), then taking an accurate measurement. I have tried to block other threads to no avail and manually triggering "pumpEvents()" directly after the turret moves. I'm sure I'm missing something very simple.

As I mentioned above, if anyone has a successful pattern to do this, I would really appreciate it.

Thank you in advance,

Joe

 

Take a look this snippet for a general feel for what I am doing:

for (int i = -99; i < 101; i = i + step)

{

pan(i);

Thread.Sleep(50);

MotherBoard.PumpEvents();

rawReadings.Add(Front_IR_Sensor);

//Thread.Sleep(50);

Console.WriteLine(i + " " + Front_IR_Sensor);

}

 

 9/24/2007 2:06:01 PM
jason
158 posts
5th


Re: Sensors on a Turret...

Joe,

Since you want to pan to a desired position, take a reading, record it, and continue on, I think I would suggest using the Update() method on your IR sensors, then read the distance property, instead of relying on the periodic polling, and event firing built into the .NET lib.   You could try something like this:

int panPos = 0;

bool panningRight = true;

while (true)

{

   Pan(panPos);

   FrontIR.Update();    // Request reading, and block until the Distance property has been updated w/ latest reading

   RawReadings.Add(panPos, FrontIR.Distance);    // Store latest reading, based on

   Thread.Sleep(40);    // The IR Sensors aren't faster than about 40msec, so sleep at least that long

   if (panningRight)

   {

       if (panPos < 100)

           panPos++;

       else

           panningRight = false; 

   }

   else

   {

       if (panPos > -99)

           panPos--;

       else

           panningRight = true; 

   }

}


Jason Summerour
President,
Summerour Robotics Corp
Microsoft MVP
www.roboticsconnection.com
 10/30/2007 10:00:20 AM
rpg
35 posts


Re: Sensors on a Turret...
Hi Joe,

I am also using a panning turret to collect data from a Sonar and IR sensor.  I didn't like the way the servo stopped and started at each reading, so what I do now is simply pan the servo through its entire arc in one motion, then collect the data using a 100ms timer that executes an Update() on each sensor and gets the sensor's distance value at that point.  I also increment a sample counter for each reading and store the counter/distance pair in an array or list.  Once the sweep is complete, I convert the sample counter indices to the angular positions that the servo was at the time of the reading by simply dividing the angular range of the servo by the number of samples.  This method results in a smooth motion of the servo and does not require you to sleep the main thread at all.  On the reverse sweep, you have to remember to reverse the data arrays before assigning angular coordinates to each reading.

--patrick


  Discussions  Robot Sensors  Sensors on a Tu...

SearchSearch  Forum HomeForum Home    Print   

Copyright 2004-2007 Summerour Robotics Corp   Terms Of Use  Privacy Statement
DotNetNuke® is copyright 2002-2008 by DotNetNuke Corporation