Hello, I use the following code to control my car but those code can not make a 90 degree turn
if (res&LINE_VECTOR)
{
// Calculate heading error with respect to m_x1, which is the far-end of the vector,
// the part of the vector we’re heading toward.
error = (int32_t)pixy.line.vectors->m_x1 - (int32_t)X_CENTER;
pixy.line.vectors->print();
// Perform PID calcs on heading error.
headingLoop.update(error);
// separate heading into left and right wheel velocities.
left = headingLoop.m_command;
right = -headingLoop.m_command;
// If vector is heading away from us (arrow pointing up), things are normal.
if (pixy.line.vectors->m_y0 > pixy.line.vectors->m_y1)
{
// ... but slow down a little if intersection is present, so we don't miss it.
if (pixy.line.vectors->m_flags&LINE_FLAG_INTERSECTION_PRESENT)
{
left += ZUMO_SLOW;
right += ZUMO_SLOW;
}
else // otherwise, pedal to the metal!
{
left += ZUMO_FAST;
right += ZUMO_FAST;
}
}
else // If the vector is pointing down, or down-ish, we need to go backwards to follow.
{
left -= ZUMO_SLOW;
right -= ZUMO_SLOW;
}
motors.setLeftSpeed(left);
motors.setRightSpeed(right);
}