crosspost: request for algorithms!

Hi,
I have a 2 wheel balancing robot I am working on that needs some TLC in the form of new algorithms. I am starting to hear creaks and groans
in its drivetrain caused by my experiments trying to get this robot to drive around. I have the robot able to balance well in one spot using a simple PID loop, but I am getting tired watching it sit in one place and would like to see it drive around a bit without having a seizure as it currently does. For those who reply to this, I will put your algorithm on the robot and test it out and will film and post the best performing ones to the web. Any type of algorithm is appreciated, but the main goals of the robot are first to balance, drive forwards and backwards and steer. I have measured the properties of the robot and put them in the below C code under the comment "robot physical characteristics". There are sensor feedback variables under the comment "robot sensor derived variables", and the joystick variables under the comment "robot control input variables". The two variables that must be set by the algorithms are under the comment "robot control output variables" which are the left and right wheel torques. These can be scaled linearly from -1 to +1 or -100 to +100 for each wheel. Zero is no torque.
If you need any other variables let me know or you can declare them as static (in C code). I have a task loop that can switch between 5 different algorithms on the fly so testing should be fast if you want to try multiple algorithms. The balance algorithm is called 33.3 times per second but this can be changed too.
Here is the algorithm I am using for balancing right now:
balance_loop()    //called 33.3X per second {
left_wheel_torque = (platform_pitch_degrees * K1) + (platform_pitch_degrees_per_second * K2);    //K1 = 7, K2 = 0.8
right_wheel_torque = left_wheel_torque;
powerMotors();
}
If you want to set gain factors for your algorithm, use these variables: float K1; float K2; //etc
Thanks for your participation and may the best algorithm win!
best regards, Jamie Morken
//////////////////////////////////////// //BALANCE CALCULATION VARIABLES
//robot physical characteristics #define wheel1_diameter_meters        0.495 #define wheel1_circumference_meters    (pi * wheel1_diameter_meters) #define wheel2_diameter_meters        0.495 #define wheel2_circumference_meters    (pi * wheel2_diameter_meters) #define robot_weight_kg            71.2    //it's heavy! #define center_of_gravity_height_meters    0.54 #define wheel_axle_height_meters    0.24 #define wheelbase_meters        0.556
//robot sensor derived variables float platform_pitch_degrees;    //forwards backwards tilt float platform_pitch_degrees_per_second; float platform_yaw_degrees;    //steering float platform_yaw_degrees_per_second; float encoder1_degrees_per_second;    //left wheel encoder float encoder2_degrees_per_second;    //right wheel encoder float wheel1_degrees_per_second; float wheel2_degrees_per_second; float wheel1_meters_per_second; float wheel2_meters_per_second; float platform_meters_per_second; float wheel1_position_meters; float wheel2_position_meters; float platform_position_meters;
//robot control input variables (joystick driving and steering) float desired_platform_meters_per_second; float desired_platform_yaw_degrees_per_second;
//robot control output variables float left_wheel_torque; float right_wheel_torque;
//END OF BALANCE CALCULATION VARIABLES ////////////////////////////////////////
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
Jamie Morken wrote:

The algorithm used by the first balancing two wheeled robot and by far the most common algorithm to get the robot to drive around is to add an offset to the platform_pitch_degrees. And to get it to steer is to again add a differential between the left and right wheels. I'd do something like:
torque = ((platform_pitch_degrees + offset) * K1) + (platform_pitch_degrees_per_second * K2);
left_wheel_torque = torque + steering; right_wheel_torque = torque - steering;
Basically what this method does is to trick the balancing algorithm by lying to it about the actual platform pitch and so you're really using the balancing algorithm to constantly get the robot to be slightly off-balance causing it to constantly try to re-balance the robot which in turn causes an average motion in one direction. Kind of like how a human would do it when balancing a broom - you'd tilt the broom a bit in order to move forward.
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload

Polytechforum.com is a website by engineers for engineers. It is not affiliated with any of manufacturers or vendors discussed here. All logos and trade names are the property of their respective owners.