Go Down

Topic: Some programming questions (Read 1 time) previous topic - next topic

wlinton1

Hey everyone so I need help on two issues I have been working on. How would I program my BOE shield bot to do a continuous figure 8 maneuver and how would I make my bot do a spiral that gets larger in diameter the longer the program is set to run?

AWOL

#1
Oct 04, 2016, 01:55 pm Last Edit: Oct 04, 2016, 01:55 pm by AWOL
What have you got so far?
When does our assignment have to be finished?
And remember, not everyone knows what a "BOE shield bot" is, or what it is capable of.

wlinton1

Well so far I have figured out how to make the bot do a circle to the right but after than I am stumped on how to make it go to the left after finishing the first circle, honestly I am completely lost on both of these questions. Do you know what the shield bot is? thanks for replying

wlinton1

oh and this isn't an assignment, it is more like I am trying to teach myself and I found some questions online to try and make the bot do and now I want to figure out how to make the bot do these maneuvers. I would like to know how within a couple hours if at all possible.

AWOL

You're not helping us to help you - we still don't know what your robot is or what it is capable of, nor what code you already have.

At its simplest, a figure-of-eight is one clockwise circle then an anticlockwise circle. (or even vice versa)

wlinton1

I am using Arduino 1.6.11 to code and what do you mean what my robot is capable of? and yes I realize that and I can make the robot turn clockwise but how with my coding software do I make it do a counterclockwise circle?

AWOL

Quote
but how with my coding software do I make it do a counterclockwise circle?
I don't know, because you haven't shown us any of your code.

You have five minutes between posts - why not use that time to think about how to get the most out of your next post?

wlinton1

#include <Servo.h>                   
 
Servo servoLeft;                     
Servo servoRight;
 
void setup()                         
{
  tone(4, 3000, 1000);               
  delay(1000);                       

  servoLeft.attach(13);               
  servoRight.attach(12);             
 
  servoLeft.writeMicroseconds(1600); 
  servoRight.writeMicroseconds(1450);
  delay(17000);                       
 
  servoLeft.detach();                 
  servoRight.detach();

}

this Is how I got my bot to do a clockwise circle.

AWOL

#8
Oct 04, 2016, 02:39 pm Last Edit: Oct 04, 2016, 02:40 pm by AWOL
So, I'm guessing you're using continuous rotation ex-servos to drive the wheels at different speeds.
What happens if you swap the servo speeds over, so you now write the left servo value to the right servo, and vice versa?

Please get into the habit of using code tags when posting code.

wlinton1

I'm sorry I am really new what are code tags? yes those are the servos I am using and if I swap the speeds over the bot will go backwards instead of doing a counterclockwise circle. I have tried messing with the values for a couple hours and I haven't been able to get the bot to do a counterclockwise circle to finish the figure eight.

AWOL

At some point in the range 1000 to 2000 for the "writeMicroseconds", the motors (I don't like calling them servos) will stop, past that point go in the opposite direction.
Try to figure out what point the motors stop.

The outside (with respect to the centre of the circle) motor of the robot has to travel faster than the inside motor.

wlinton1

these motors say 1300 to 1700. 1300 being fullspeed clockwise and 1700 fullspeed counterclockwise. am I allowed to go outside of this range then or should I stick with what I have been shown? I guess ill just keep going through trial and error then.

AWOL

Trial and error will get you there (eventually), but you may find you've lost all your hair.

Simple clear logical thought (and maybe some simple directed experiments) will get you there quicker.

PaulMurrayCbr

#13
Oct 05, 2016, 01:33 am Last Edit: Oct 05, 2016, 01:38 am by PaulMurrayCbr
You will have completed a circle when ... come to think of it, this actually involves some math involving the wheel diameter, the axle length, and the rate at which the two servos are rotating.

After completing a circle, the circumference of the circle traced out by the outer wheel will be 2πl greater than that traced out by the inner one (where l is the axle length). So if the outer wheel is travelling at Vo and the inner one at Vi, you will get a complete circle at 2πl/(Vo-Vi) seconds. Vo is πd omega_o, where d is the wheel diameter and omega_o is the rotational speed of the outer wheel in rotations per second. So we get 2πl / [πd (omega_o - omega_i)]. The π cancels out a little suspiciously, leaving us with 2l/d * 1/(difference of the wheel speeds in rotations per second) seconds to complete a circle.

Something like that, anyway. I shall leave the calculation of the diameter of the circle in which the outer wheel travels as an exercise for the reader. Hint: you want this to be smaller than the floor.

In any case, to do a figure 8: go left, wait till you have finished going left, then go right and wait untill you have finished going right. People omit that last step, and wonder why their robot only goes left.
http://paulmurraycbr.github.io/ArduinoTheOOWay.html

Delta_G

I'm sorry I am really new what are code tags?
So you just skipped the "How to Use This Forum" post at the top of every board and just started posting away huh?  That doesn't bode well for you. The ability to stop and read the documentation before you start even when you think you already know what to do is what separates good programmers from frustrated noobs.  It is a habit you would do well to get into.
|| | ||| | || | ||  ~Woodstock

Please do not PM with technical questions or comments.  Keep Arduino stuff out on the boards where it belongs.

Go Up