Jump to content

simulating balance


Recommended Posts

Guest iamtheplague
Posted

Ok, I'm planning on building something involving balance. I don't want to reveal it to everyone at this time because I'm acting childish and don't want to give out the idea. :D

 

basicly, with the segway as an example, i'm trying to figure out how to determine how fast the wheels should be moving (kmh or mph) to keep balance.

 

I've looked at http://tlb.org 's explanation on how he built a segway. This is his basic algorithm:

Inputs

angle, angle_rate: the tilt angle of the scooter in radians and its derivative in radians/sec

steer_knob: the reading from the steering knob, between -1 and +1.

Balance

balance_torque = 5.0 * (angle - rest_angle) + 0.4 * angle_rate

Limit top speed by tilting back

overspeed = max(0, cur_speed - 0.5)

if (overspeed > 0) {

overspeed_integral = min(0.4, overspeed_integral + min(0.2, overspeed+0.05) * dt)

}

else {

overspeed_integral = max(0, overspeed_integral - 0.04*dt)

}

rest_angle = 0.4*overspeed + 0.7*overspeed_integral

Steer. Decrease steering rate at high speed

steer_cmd = 0.07/(0.3+abs(cur_speed)) * steer_knob

Track current speed

cur_speed += 1.2 * balance_torque * dt

Differential steering

left_motor_pwm = balance_torque + cur_speed + steer_cmd

right_motor_pwm = balance_torque + cur_speed - steer_cmd

Outputs

left_motor_pwm and right_motor_pwm directly set the duty cycle of the pulse width modulator for the wheel controller, and range from -1 to +1 (+1 is 100% forward, -1 is 100% reverse.)

 

Could somebody explain this to me? I don't need any explination on overspeed or anything like that. I expect my design to be moving alot faster and it is oriented where it won't matter.

 

So all i want to know, is based on information gathered from a gyroscope, how fast does the vehicle need to be moving to maintain the balance.

 

Tell me if this post made any sense at all! lol

Guest iamtheplague
Posted

PS i'm new i used to be m@

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.