Hallo
So vielleicht:
Code:
// Die Drehrichtungen werden in RP6RobotBaseLib.h definiert:
// Direction:
// #define FWD 0
// #define BWD 1
// #define LEFT 2
// #define RIGHT 3
// moveAtSpeed() mit Drehrichtungsangabe als dritter Parameter
void moveAtSpeed2(uint8_t desired_speed_left, uint8_t desired_speed_right, uint8_t dir)
{
moveAtSpeed(desired_speed_left, desired_speed_right);
changeDirection(dir);
}
// rotoate() mit zwei unterschiedlichen Geschwindigkeiten (mit Weganpassung der Seiten)
void rotate2(uint8_t desired_speed_left, uint8_t desired_speed_right, uint8_t dir, uint16_t angle, uint8_t blocking)
{
uint16_t distance, distance_left, distanceright;
motion_status.move_L = true;
motion_status.move_R = true;
distance = (uint16_t) (((uint32_t)(ROTATION_FACTOR) * (uint16_t)angle)/100);
distance += distance; // Gesamtweg verteilen
distance_left = distance * desired_speed_left / (desired_speed_left + desired_speed_right);
distance_right = distance - distance_left;
preDecelerate_L = distance_left - 100;
preDecelerate_R = distance_right - 100;
preStop_L = distance_left;
preStop_R = distance_right;
if(distance_left < 40) {
distance_left = 40;
preStop_L = 20;
preDecelerate_L = 10;
}
if(distance_right < 40) {
distance_right = 40;
preStop_R = 20;
preDecelerate_R = 10;
}
moveAtSpeed(desired_speed_left, desired_speed_right);
changeDirection(dir);
mleft_dist = 0;
mright_dist = 0;
distanceToMove_L = distance_left;
distanceToMove_R = distance_right;
motion_status_tmp = motion_status.byte;
MOTIONCONTROL_stateChangedHandler();
if(blocking)
while(!isMovementComplete())
task_RP6System();
}
(ungetestet, Basis der Funktionen aus der RP6-Library)
Gruß
mic
Lesezeichen