Helo forum, Vaironl here.
I would like to know if there is a method I could use to turn the robot according to angles, or a radius. I'm not the best at math and therefore I din't try to make any calculations, but I can still understand many things. Please if possible can you guys provide me with efficient methods.
Hello Vaironl,
While I am also working on my own angle-turn function, I would like to note something I came across to ask the Botball Community
Here is a snippet of my code:
set_create_normalized_angle(0);
create_spin_CCW(40); <------- NOTE THIS LINE
while(get_create_normalized_angle(0.0) <= 45)
{
printf("%d\n", get_create_normalized_angle(0.0));
sleep(0.01);
}
create_stop();
I found that at lower speeds, the simulator completely overshoots (the create spins about 5 times to reach "45" degrees), but on higher speeds, the simulator is more accurate.
Is this a problem with the simulator or my code? In any case, this is frustrating because I am trying to create an acceleration profile (speed starting at 20 and goes up to the highest speed possible before slowing down) for turning.
Hi Vaironl,
Can you clarify exactly what you're trying to do? Are you trying to have the Create turn in place by a certain angle? Or are you trying to have it drive in a circular arc with a certain radius? Both are possible; I'm just not sure what you're asking.
Thanks.
-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
Hi SEAL491,
While I haven't tested your code, my guess is that this is a simulator bug. I developed a 3D Botball simulator (ImperiSim) and hacked the IC Botball simulator to handle the back-EMF motor commands, and based on my experience, I can say that getting simulators to accurately reflect reality is not an easy task, and in most cases, you're better off running your code on an actual robot.
-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
Hello, SEAL491.
I'm sorry to disappoint you but I'm not a very good at CBC, and I might give you wrong information.
But if you would hear my opinion I think you can get an idea of whats going on.
When I test my basic programs of bumper collision, I see that the simulator at least before the 3.0.3 Update where very inaccurate.
The bump is detected but it keeps going, while the actual Irobot detects the bump perfectly.
Doing science.
I'm trying to stop turn 90degrees.
But now that you mention it turning while moving might be a good tip to have if you can provide it.
Doing science.
For a lego bot:
The math for calculating the number of ticks per degree to turn in place would go something like this:
You would then multiply TicksPerDegree by the number of degrees you want to go. That will give you the number of ticks you need to turn. Plug that number into mrp like this:
you will need to change the motor ports and - signs, but that should work
-Marty Rand
{
Senior programmer at Norman Advanced Robotics
Former senior programmer at Whittier Middle School
Youth Advisory Council
All around nerd
}
For a create:
for clockwise turns you need a negative angle
-Marty Rand
{
Senior programmer at Norman Advanced Robotics
Former senior programmer at Whittier Middle School
Youth Advisory Council
All around nerd
}
You could put either of these in a function to simplify and shorten the code like this:
For the create function, a positive speed AND angle will yield a counter-clockwise turn. Put a negative speed AND Angle for a clockwise turn
-Marty Rand
{
Senior programmer at Norman Advanced Robotics
Former senior programmer at Whittier Middle School
Youth Advisory Council
All around nerd
}
Is "msleep(5);" an adequate sleep time to make the create turn accurately? How accurate could you get the create to turn?
Yes, but the real problem is that there is a variable lag between the create and the CBC that cannot be shortened. It isn't very long, but it will cause some error. That's why when you tell it to turn 90 degrees, it goes 90 - 95. It's not just because the create skids. The easiest way to fix it to backup into a wall with the flat back of the create. Go a little too far, so the create is flat against it. This will align you fairly well. If you have time, do it again with a perpendicular wall.
-Marty Rand
{
Senior programmer at Norman Advanced Robotics
Former senior programmer at Whittier Middle School
Youth Advisory Council
All around nerd
}