Create or code problem?

3 replies [Last post]
SEAL491
SEAL491's picture
Title: NooBot+
Joined: 07/19/2011
Posts:
BotPoints: 54
User offline. Last seen 10 years 47 weeks ago.

I used create_spin_ccw and sleep to make the create turn 90 degrees. Then, I made the robot turn 90 degrees with 1 second pauses in between for a full 360 degree turn. This means the robot makes four spinning motions, simple enough. However, the create always turns only about 70 degrees in the third segment, so the create ultimately spins about 340 degrees. Could there be an explanation for this other than that we have received a bad create?

cannonh
Title: NooBot
Joined: 07/09/2012
Posts:
BotPoints: 19
User offline. Last seen 9 years 46 weeks ago.

Creates can be finicky, yes. But the fact that it's consistaitly spinning low on only one turn is weird. If your create was bad it would be inconsistaintly inconsistaint, instead of consistaintly inconsistaint. Maybe using sleep(), which uses floats, is not running right on the cbc with all the lag from interpreted code and hardware constraints. Try using msleep() instead perhaps?
But first I'd check the tires of the create (how worn are they?), charge the battery, and perhaps try it on another create (if you have access to one) or another cbc. Also have you tested the code in different locations and orientations of the create? It could be that the board is slippery there, meaning you lose power on spinup or something.

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

I doubt that sleep vs msleep is the issue. C programs are compiled, not interpreted, and the overhead of casting the floating point value into an integer value is negligible unless you're calling it repeatedly.

Using timing to figure out how far you've traveled is generally not a good idea, because it varies widely. Use the distance functions in the Create library to determine exactly how far you've traveled in millimeters or degrees. For even better accuracy, use a Create OI script with the "wait distance" or "wait angle" command.

-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

awesome
Title: NooBot
Joined: 04/24/2015
Posts:
BotPoints: 2
User offline. Last seen 8 years 5 weeks ago.

hanks for the previous reply

EDIT: I just realized the vertical nonmoving acceleration is around 64 = 1G, so it can measure +-2 G at maximum values? Also is the measured value in linear correspondance to actual G's? So if 64 = 1G then does 32 = 0.5G and 127 = 2G?

Sumer