Can you be more specific on what trouble you are having? Have you completed the servo ramping exercise? To do a sine wave you will need to ramp both servos in a sawtooth wave between stop and full forward, the two servos waveforms are set 180 degrees apart.
Ok, i see.
But I was trying to let the BS2 calculate the sine-function and trying to figure out how to make the servo's respond to that.
Did not make a code simply because I didn't see a solution on how to let the servo's respond to the calculation of the sine.
You can do it that way as well, in that instance you need to think in terms of forces acting upon the "drawing particle" (in your case the bot). The bot can be thought of accelerating back and forth creating the sin wave. Acceleration is the second derivative of·position and we know the position is sin(x), so the acceleration would be -sin(x). This is the "force" acting upon your servos, this force is split between the wheels in opposing directions, and if you have the same "handedness" for your servos (the pulse for one going forward is the same pulse for the other going backward) you just divide the "acceleration" by two and add this value to both servo speeds.·This will have the effect of incrementally changing the servos so the resultant movement is sinusoid.
PS. you can just use sin(x) when calculating the acceleration, it will do the same thing except one would start the bot off by turning left, the other to the right)
There is some addition math required, such as scaling the sin(x) (changing the servo value by ± 1 isn't going to make the bot turn very much).
Post Edited (Paul Baker) : 6/1/2005 11:27:12 PM GMT
Comments
a few questions at a time and that would us to answer them as you go through the book.
Dave
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Dave Andreae
Tech Support
dandreae@parallax.com
www.parallax.com
·
I'm having trouble coding a program for the project at the end of Chapter 2 (Robotics),
where there is asked to make the Boe-Bot to follow a sine wave pattern.
Theo
btw. I have version 1.5 of the Robotics Student Workbook (not v1.1) Sorry
The result is the bot will travel in a sine wave.
But I was trying to let the BS2 calculate the sine-function and trying to figure out how to make the servo's respond to that.
Did not make a code simply because I didn't see a solution on how to let the servo's respond to the calculation of the sine.
Theo
PS. you can just use sin(x) when calculating the acceleration, it will do the same thing except one would start the bot off by turning left, the other to the right)
There is some addition math required, such as scaling the sin(x) (changing the servo value by ± 1 isn't going to make the bot turn very much).
Post Edited (Paul Baker) : 6/1/2005 11:27:12 PM GMT