CBC Accelerometer & more

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

Sorry, I'm really new to CBC programming, and I'm sure someone has already covered this either at GCER or in this forum, but please tell me, what is the function that lets me access the CBC's accelerometer?

Also, just a more general question, this year, our team had major problems with trying to make robots go straight. Most people's solution to this was making the robot line up on the PVC and eventually recalibrate itself. I also saw some hefty algorithms at the GCER talks too.

Regardless, I was wondering if there is a simple way to make robots go pretty much straight. For example, I saw one team this year that had an acceleration profile for their create. Do all the good teams do that? Does the create go extremely straight at a certain speed? I also heard it is much more accurate to count the ticks of motors to measure distance moved than to pick more arbitrary numbers for a velocity, and sleeptime. Is that true? If so, how far more accurate is it?

Thanks!

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

Welcome to the Botball Community!

The accelerometer can be accessed via accel_x(), accel_y(), and accel_z().

Making robots go straight... this is a complex topic. Norman Advanced found this year that the Create drifts when at lower battery levels; keeping your Create fully charged is a good way to stay straight. At full charges, Norman Advanced never had any issues with the Create driving straight.

Ticks are much, much more accurate than mav()/sleep(). Never use sleep() to try to go a specific distance; it will not be reliable. Also, mrp() usually results in shorter code than mav()/sleep(). Note that because motors vary, you may need to multiply all distances/velocities for one of your motors by a constant gain (which you will need to find experimentally) to keep the robot going straight.

That said, ticks are still not a full solution, because the ticks are measured through velocity integration and therefore drift a bit over time. Also, if your robot runs over a pom, etc., ticks will be off. Sensors and smart programming are the best way to handle this. There are various GCER papers about using ticks to make a rough estimate of your position, and using sensors to make small corrections as necessary (the RangeTrack paper by myself and Emily Curtis is a particularly complex example; a very simple example is backing into a wall, as you mentioned).

Hope this helps.

-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

brendarobers
Title: NooBot
Joined: 02/27/2022
Posts:
BotPoints: 10
User offline. Last seen 6 weeks 1 day ago.

Like most things in life that get good results, there is hard work and discipline involved. There are some sacrifices that you will have to make to reach your end goal of financial freedom. However, through the process of debt review you will undoubtedly have less stress and worry about your debt, and have more money left for your everyday living expenses. Annually, thousands of South African consumers receive clearance certificates from their registered debt counsellors and start over, free from the burden of overwhelming Disadvantages of debt review.