Closed salvantj closed 7 years ago
/ Variables to control the reference speed and steering int speed = 0, steering = 0;
//Joystick positions int joyStickLeft = 0, joyStickRight = 0;
//Maximum speed and steering when remote joysticks are fully moved forward const int kMaxRemoteSpeed = 20; const int kMaxRemoteSteering = 10;
//Initialization complete setTouchLEDRGB(touchLed, 0, 255, 0);
//Run the main loop until the touch LED is touched. while(getTouchLEDValue(touchLed)==0) {
///////////////////////////////////////////////////////////////
//
// Driving and Steering. Modify the <<speed>> and <<steering>>
// variables as you like to make your segway go anywhere!
//
// (If you don't have the controller, just delete the four lines
// below. Then <<speed>> and <<steering>> remain zero.)
//
///////////////////////////////////////////////////////////////
joyStickLeft = getJoystickValue(ChA);
joyStickRight = getJoystickValue(ChD);
displayControllerValues(1, ChD); displayControllerValues(2, ChA); speed = (joyStickRight + joyStickLeft)/2.0 * (kMaxRemoteSpeed /100.0); steering = (joyStickRight - joyStickLeft)/2.0 * (kMaxRemoteSteering/100.0);
forward and back are really slow
This is currently limited by kMaxRemoteSpeed, which is currently set to 20
//Maximum speed and steering when remote joysticks are fully moved forward
const int kMaxRemoteSpeed = 20;
const int kMaxRemoteSteering = 10;
You can set it to a higher value, but that leaves "less speed" for balancing.
Smoothness is controlled by these tuning parameters:
gainGyroAngle = 1000,
gainGyroRate = 40,
gainMotorAngle = 15,
gainMotorAngularSpeed = 9.6,
gainMotorAngleErrorAccumulated = 3;
These values indicate how much power is applied to the motor for each of the signals (Gyro angle, etc.) deviating from their normal value.
Increasing gainGyroAngle, for example, will make it respond more aggressively when you push the robot a bit. Try playing with these values and adjust them slightly to see if you can make it more smooth.
mines just moving the wheels forward and backward really fast in order to balance, not really balancing smooth though i dont even know what half the tuning variables mean
gainGyroAngle = 1000, gainGyroRate = 85, gainMotorAngle = 15, gainMotorAngularSpeed = 9.6, gainMotorAngleErrorAccumulated = 3;
forward and back are really slow and not smooth at all.. turning seems to be doing ok but not as smooth as your video..