Differential Drive Kinematiği
DifferentialDriveKinematics
sınıfı, ChassisSpeeds
nesnesi ile bir diferansiyel sürücü robotunun sol ve sağ tarafları için hızları içeren bir DifferentialDriveWheelSpeeds
nesnesi arasında dönüşüm sağlayan kullanışlı bir araçtır. .
Kinematik Nesnesini Oluşturmak
DifferentialDriveKinematics
nesnesi, robotun iz genişliği olan bir yapıcı argümanını kabul eder. Bu, bir diferansiyel sürücü üzerindeki iki tekerlek seti arasındaki mesafeyi temsil eder.
Not
Java’da iz genişliği metre cinsinden olmalıdır. C++ ‘da, birimler kitaplığı, herhangi bir uzunluk birimi kullanılarak iz genişliğini geçmek için kullanılabilir.
Şasi Hızlarını Tekerlek Hızlarına Dönüştürme
ChassisSpeeds
nesnesini bir DifferentialDriveWheelSpeeds
nesnesine dönüştürmek için toWheelSpeeds(ChassisSpeeds hızları)
(Java) / ToWheelSpeeds(ChassisSpeeds hızları)
(C ++) yöntemi kullanılmalıdır. Bu, doğrusal bir hızı (vx
) ve açısal hızı (omega
) sol ve sağ tekerlek hızlarına dönüştürmeniz gereken durumlarda yararlıdır.
// Creating my kinematics object: track width of 27 inches
DifferentialDriveKinematics kinematics =
new DifferentialDriveKinematics(Units.inchesToMeters(27.0));
// Example chassis speeds: 2 meters per second linear velocity,
// 1 radian per second angular velocity.
var chassisSpeeds = new ChassisSpeeds(2.0, 0, 1.0);
// Convert to wheel speeds
DifferentialDriveWheelSpeeds wheelSpeeds = kinematics.toWheelSpeeds(chassisSpeeds);
// Left velocity
double leftVelocity = wheelSpeeds.leftMetersPerSecond;
// Right velocity
double rightVelocity = wheelSpeeds.rightMetersPerSecond;
// Creating my kinematics object: track width of 27 inches
frc::DifferentialDriveKinematics kinematics{27_in};
// Example chassis speeds: 2 meters per second linear velocity,
// 1 radian per second angular velocity.
frc::ChassisSpeeds chassisSpeeds{2_mps, 0_mps, 1_rad_per_s};
// Convert to wheel speeds. Here, we can use C++17's structured bindings
// feature to automatically split the DifferentialDriveWheelSpeeds
// struct into left and right velocities.
auto [left, right] = kinematics.ToWheelSpeeds(chassisSpeeds);
Tekerlek Hızlarını Şasi Hızlarına Dönüştürme
Tek tek tekerlek hızlarını (sol ve sağ) tekil bir ChassisSpeeds
nesnesine dönüştürmek için kinematik nesnesi de kullanılabilir. Bunu başarmak için toChassisSpeeds (DifferentialDriveWheelSpeeds hızları)
(Java) / ToChassisSpeeds (DifferentialDriveWheelSpeeds hızları)
(C ++) yöntemi kullanılmalıdır.
// Creating my kinematics object: track width of 27 inches
DifferentialDriveKinematics kinematics =
new DifferentialDriveKinematics(Units.inchesToMeters(27.0));
// Example differential drive wheel speeds: 2 meters per second
// for the left side, 3 meters per second for the right side.
var wheelSpeeds = new DifferentialDriveWheelSpeeds(2.0, 3.0);
// Convert to chassis speeds.
ChassisSpeeds chassisSpeeds = kinematics.toChassisSpeeds(wheelSpeeds);
// Linear velocity
double linearVelocity = chassisSpeeds.vxMetersPerSecond;
// Angular velocity
double angularVelocity = chassisSpeeds.omegaRadiansPerSecond;
// Creating my kinematics object: track width of 27 inches
frc::DifferentialDriveKinematics kinematics{27_in};
// Example differential drive wheel speeds: 2 meters per second
// for the left side, 3 meters per second for the right side.
frc::DifferentialDriveWheelSpeeds wheelSpeeds{2_mps, 3_mps};
// Convert to chassis speeds. Here we can use C++17's structured bindings
// feature to automatically split the ChassisSpeeds struct into its 3 components.
// Note that because a differential drive is non-holonomic, the vy variable
// will be equal to zero.
auto [linearVelocity, vy, angularVelocity] = kinematics.ToChassisSpeeds(wheelSpeeds);