Some API related questions: Motor rotation and debugging
Navigates to RoboticsConnection.com Home RoboticsConnection.com HomePage
RoboticsConnection User Forum
Home       Members    Calendar    Who's On
Welcome Guest ( Login | Register )
        


12»»

Some API related questions: Motor rotation... Expand / Collapse
Author
Message
Posted Monday, March 22, 2010 11:19 PM
Forum Member

Forum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum Member

Group: Forum Members
Last Login: Friday, October 19, 2012 1:38 AM
Posts: 46, Visits: 134
Hi,
First i have to say i have been having a blast experimenting with my traxster! it took a while to get going, but now that i am up and running...its a lot of fun. I do have some questions...

1) Motor rotation. Can you explain how this works? If i set the RoationAngle to 90, should the traxster rotate clockwise 90 degrees? I am not seeing this happen..for me it rotates what looks like only 45 degrees. I am wondering if this is because i might be on a rug? If so, is there a way to check that the wheels are spinning the amount they should?

2) debugging: There are times when stepping through the code, after stepping over certain lines of code that are suppose to move the motor or servo, nothing happens. Why does this happen? for example, below is a snippet of code that is executed once i have determined the vehicle needs to rotate:

do
{
...
...
...

if (distanceRight > distanceLeft)
{
_rover.Motors.RotationAngle = 90;
}
else
{
_rover.Motors.RotationAngle = -90;
}

_rover.Motors.Rotate();
_rover.WaitForMotor();

//move servo back to center and get another reading to make sure no
//objects obstructing new facing direction
_rover.Servo1.Position = 0;
distanceForward = GetDistance(IrSensor1);

} while (distanceForward < this.ObjectDistance);


In the above code _rover.Motors is an instance of PIDMotorController and the WaitForMotor() method simply waits for QueryStatus() to return true;

I can step over each line of the code to the next, but at times the motor does not rotate nor does the Servo1 reset to center. When running without stepping through code however, it seems to work fine.
Post #1765
Posted Saturday, March 27, 2010 9:31 PM


Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

Group: Administrators
Last Login: Monday, October 31, 2011 9:18 PM
Posts: 640, Visits: 819
Hey Dizzy,

Glad you're having a blast! Sorry for the delayed reply...I've been working tons of overtime this past week.

1.) I've spent a lot of time trying to get it to spin an exact distance based on physical dimensions, and calculated ticks.  But, it never spins the same, especially on different surfaces due to the skid-steer, and varying friction.

2.) As far as debugging goes...I've never seen instances where code didn't execute when single stepping, but I have a thought.  Are you using XBee?  Maybe cmds aren't getting sent over xbee when in debug mode (due to timeouts, or something).  Also, if you are single stepping, then responses coming back are probably getting dropped.  So, any commands that you're executing, which need responses back, like the PID query status probably won't work.

Best Regards,

Jason Summerour
President,
Summerour Robotics Corporation
www.roboticsconnection.com

Post #1769
Posted Sunday, March 28, 2010 3:11 PM
Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

Group: Forum Members
Last Login: Friday, April 22, 2011 6:18 PM
Posts: 153, Visits: 547
Hi dizzy,
Sounds like the fun has begun

A inaccurate but possibly useful rotate90() function might be achieved
by using the encoder read function. Get the value that does correspond
to your 90 degrees and perform rotate90() until that number is reached.

Like Jason mentions, accuracy is problematic at best. Perhaps a compass
will be your next investment


Don Lewis
Post #1771
Posted Monday, March 29, 2010 1:30 AM
Forum Member

Forum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum Member

Group: Forum Members
Last Login: Friday, October 19, 2012 1:38 AM
Posts: 46, Visits: 134
Thanks guys.
I will try your suggestion Don.

Jason, i'm trying to write some generic code that will work for sensors like the GP2D12 and Ping))) sonar. I notice that the API docs indicate that GP2D12 extends from IDistanceSensor while Ping extends DistanceSensorBase. The docs for DistanceSensorBase seem to bring up docs for CompassSensorBase, but i believe DistanceSensorBase extends IDistanceSensor, since i'm able to cast my Ping object to it.

This is great because it allows me to write some code that will work well regardless of whether my by IR or Sonar sensors triggers. The one problem i have however is that i wish that the interface IDistanceSensor offered an Update method as well. The reason for this is that when distance changed event is fired (either from the ir or sonar), i disable all sensors, and then try to determine which direction i will turn. To do this, i need to manually take readings as i pan left and right. Is this enhancement possible in the future?

thanks.

Post #1772
Posted Monday, March 29, 2010 2:20 AM
Forum Member

Forum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum Member

Group: Forum Members
Last Login: Friday, October 19, 2012 1:38 AM
Posts: 46, Visits: 134
One additional question, is there a method similar to QueryStatus available for Servos? one that will block until the servo has completed it's move?

thanks
Post #1774
Posted Monday, March 29, 2010 11:08 AM
Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

Group: Forum Members
Last Login: Friday, April 22, 2011 6:18 PM
Posts: 153, Visits: 547
I am also curious about this one. Presently I have to use delays while hoping
I get a sensor reading at a given servo position. These delays slow down the
process. I believe the MaxBotics EZ3 requires 50mS sample time and the
Sharp IR a little less. However, I have three and sometimes four IR samples
and a Sonar sample to deal with while my bot is rolling.


>dizzy (3/29/2010)One additional question, is there a method similar to QueryStatus
>available for Servos? one that will block until the servo has completed it's move?

>thanks


Don Lewis
Post #1776
Posted Monday, March 29, 2010 2:33 PM


Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

Group: Administrators
Last Login: Monday, October 31, 2011 9:18 PM
Posts: 640, Visits: 819
Dizzy,

DistanceSensorBase inherits from QueryableComponentBase, and IDistanceSensor.  It implements the IDistanceSensor interface, and gets all of the goodies that come with QueryableComponentBase.  The QueryableComponentBase class provides the interface for querying objects at a specified frequency, or allows you to disable that querying, and allow you to perform an "Update" as needed.

The GP2D12/120 objects inherit from AnalogSensor, and IDistanceSensor, and implements the IDistanceSensor interface.  This is because the GP2D12/120 are analog sensors.

The AnalogSensor class inherits from QueryableComponentBase as well, so the GP2D12/120 objects do have the ability to be have their "querying" turned off, and you can manually "update" them as needed.

Also, the Ping inherits directly from DistanceSensorBase, since the only thing the PING class needs to do is add the "Pin" property so you can set the appropriate pin, as well as store the actual command to send "pping".

So if you're using a GP2D12 for example, when you construct it, simply set it's "Enabled" property to 'false', and then just perform an "Update()", then read it's distance property when you're ready to take a reading.   If you do this, then you won't get a DistanceChanged Event!  But you don't care since you're manually querying it by performing an update. 

Also keep in mind that by manually querying it, you'll be waiting on the response to come back, and be validated, whereas if you were automatically querying it (by default), you would simply be getting the distance property back immediately, because the sensor value was sent/processed/validated while you were off doing something else.

Does that make sense?   Hope it helps!

Best Regards,

Jason Summerour
President,
Summerour Robotics Corporation
www.roboticsconnection.com

Post #1778
Posted Monday, March 29, 2010 2:46 PM
Forum Member

Forum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum Member

Group: Forum Members
Last Login: Friday, October 19, 2012 1:38 AM
Posts: 46, Visits: 134
jsummerour (3/29/2010)
Dizzy,

DistanceSensorBase inherits from QueryableComponentBase, and IDistanceSensor. It implements the IDistanceSensor interface, and gets all of the goodies that come with QueryableComponentBase. The QueryableComponentBase class provides the interface for querying objects at a specified frequency, or allows you to disable that querying, and allow you to perform an "Update" as needed.

The GP2D12/120 objects inherit from AnalogSensor, and IDistanceSensor, and implements the IDistanceSensor interface. This is because the GP2D12/120 are analog sensors.

The AnalogSensor class inherits from QueryableComponentBase as well, so the GP2D12/120 objects do have the ability to be have their "querying" turned off, and you can manually "update" them as needed.

Also, the Ping inherits directly from DistanceSensorBase, since the only thing the PING class needs to do is add the "Pin" property so you can set the appropriate pin, as well as store the actual command to send "pping".

So if you're using a GP2D12 for example, when you construct it, simply set it's "Enabled" property to 'false', and then just perform an "Update()", then read it's distance property when you're ready to take a reading. If you do this, then you won't get a DistanceChanged Event! But you don't care since you're manually querying it by performing an update.

Also keep in mind that by manually querying it, you'll be waiting on the response to come back, and be validated, whereas if you were automatically querying it (by default), you would simply be getting the distance property back immediately, because the sensor value was sent/processed/validated while you were off doing something else.

Does that make sense? Hope it helps!

Best Regards,


This makes sense, and i just tested that i can use QueryableComponentBase with both the GP2D12 and Ping to manually take readings...sweet!

I'm still absorbing your last paragraph...when manually calling the update method, is it Asynchronous or Synchronous? If it's Asynchronous, is there some means of determining when the value is ready to be read?
(The reason I THINK i need to disable the sensors and take manual reading is because after i have determined the vehicle needs to change direction, i feel it would be best to prevent the events from possibly firing while am trying to determine which direction to change to).
Post #1780
Posted Monday, March 29, 2010 3:11 PM


Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

Group: Administrators
Last Login: Monday, October 31, 2011 9:18 PM
Posts: 640, Visits: 819
Yes, it's asynchronous.  The way the library is designed is that one half of it provides the interface to you, and the other half handles the communication to the Serializer.  If you have objects set up to query periodically, the library does that for you, and stores the latest values int the objects properties (such as Distance property).  That way, when you want to read the distance, you don't have to wait on the round trip communication time, and it's very fast. Additionally, the events (e.g. DistanceChanged event) asynchronously fire off when the distance has changed more that the threshold you specified, and if you're signed up for that event, then you can happily go do other things, instead of waiting on communication. 

In some cases, like your own, however, you want to manually read the sensor to get the very latest reading. In this case, you do have to wait on the round trip communication time.

Best Regards,

Jason Summerour
President,
Summerour Robotics Corporation
www.roboticsconnection.com

Post #1782
Posted Monday, March 29, 2010 4:39 PM
Forum Member

Forum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum Member

Group: Forum Members
Last Login: Friday, October 19, 2012 1:38 AM
Posts: 46, Visits: 134
[b]...In some cases, like your own, however, you want to manually read the sensor to get the very latest reading. In this case, you do have to wait on the round trip communication time.


How do i do this? is there something property/attribute i can query that would indicate the round trip is complete and the value is ready to be read?

thanks.
Post #1787
« Prev Topic | Next Topic »

12»»

Reading This Topic Expand / Collapse
Active Users: 1 (1 guest, 0 members, 0 anonymous members)
No members currently viewing this topic.
Forum Moderators: jsummerour

Permissions Expand / Collapse

All times are GMT -8:00, Time now is 8:00pm

Powered By InstantForum.NET v4.1.4 © 2013
Execution: 0.141. 12 queries. Compression Disabled.