Holonomik Sürücü Kontrolcüsü

Holonomik sürücü kontrolcüsü, holonomik aktarma organlarına sahip robotlar için bir yörünge izleyicidir (örn. sapma, mekanum, vb.). Bu, küçük sıkıntılar için düzeltme ile yörüngeleri doğru bir şekilde izlemek için kullanılabilir.

Holonomik Sürücü Kontrolcüsü Oluşturma

Holonomik sürücü kontrolcüsü, 2 PID kontrolcüsü ve 1 profilli PID kontrolcüsü ile somutlaştırılmalıdır.

Not

PID kontrolü hakkında daha fazla bilgi için bakınız WPILib’de PID Kontrolü.

2 PID kontrolcü, sırasıyla alana-göre x ve y yönlerindeki hatayı düzeltmesi gereken kontrolcülerdir. Örneğin, ilk 2 bağımsız değişken sırasıyla PIDController (1, 0, 0) ve PIDController (1.2, 0, 0) ise, holonomik sürücü kontrolcüsü; x yönündeki her hata metresi için x’ e saniyede ek bir metre ekleyecektir ve y yönündeki her hata metresi için y’ ye saniyede ek 1,2 metre ekleyecektir.

Son parametre, robotun dönüşü için bir ProfiledPIDController``dır. Bir holonomik aktarma organının dönüş dinamikleri x ve y yönlerindeki hareketten ayrıldığından, kullanıcılar bir yörüngeyi izlerken özel yön referansları ayarlayabilir. Bu rota referansları, ``ProfiledPIDController içinde ayarlanan parametrelere göre profillenmiştir.

var controller = new HolonomicDriveController(
  new PIDController(1, 0, 0), new PIDController(1, 0, 0),
  new ProfiledPIDController(1, 0, 0,
    new TrapezoidProfile.Constraints(6.28, 3.14)));
// Here, our rotation profile constraints were a max velocity
// of 1 rotation per second and a max acceleration of 180 degrees
// per second squared.
frc::HolonomicDriveController controller{
  frc::PIDController{1, 0, 0}, frc::PIDController{1, 0, 0},
  frc::ProfiledPIDController<units::radian>{
    1, 0, 0, frc::TrapezoidProfile<units::radian>::Constraints{
      6.28_rad_per_s, 3.14_rad_per_s / 1_s}}};
// Here, our rotation profile constraints were a max velocity
// of 1 rotation per second and a max acceleration of 180 degrees
// per second squared.

Ayarlanmış Hızları Alma

Holonomik sürücü kontrolcüsü, robot bu hızları takip ettiğinde hedef noktasına doğru bir şekilde ulaşacak şekilde “ayarlanmış hızları” geri döndürür. Kontrolcü, yeni hedefle periyodik olarak güncellenmelidir. Hedef, istenen bir poz, doğrusal hız ve rotadan oluşur.

Not

The “goal pose” represents the position that the robot should be at a particular timestamp when tracking the trajectory. It does NOT represent the trajectory’s endpoint.

Kontrolcü, Calculate (C++) / calculate (Java) yöntemi kullanılarak güncellenebilir. Bu yöntem için iki aşırı yük vardır. Bu aşırı yüklerin her ikisi de mevcut robot konumunu ilk parametre olarak ve istenen rotayı son parametre olarak kabul eder. Ortadaki parametreler için, bir aşırı yük istenen pozu ve doğrusal hız referansını kabul ederken, diğeri hedef pozu hakkında bilgi içeren bir Trajectory.State nesnesini kabul eder. İkinci yöntem, yörüngeleri izlemek için tercih edilir.

// Sample the trajectory at 3.4 seconds from the beginning.
Trajectory.State goal = trajectory.sample(3.4);

// Get the adjusted speeds. Here, we want the robot to be facing
// 70 degrees (in the field-relative coordinate system).
ChassisSpeeds adjustedSpeeds = controller.calculate(
  currentRobotPose, goal, Rotation2d.fromDegrees(70.0));
// Sample the trajectoty at 3.4 seconds from the beginning.
const auto goal = trajectory.Sample(3.4_s);

// Get the adjusted speeds. Here, we want the robot to be facing
// 70 degrees (in the field-relative coordinate system).
const auto adjustedSpeeds = controller.Calculate(
  currentRobotPose, goal, 70_deg);

Ayarlanmış Hızları Kullanma

Ayarlanan hızlar ChassisSpeeds tipindedir, bir `` vx ‘’ (ileri yönde doğrusal hız) içerir, a `` vy ‘’ (yan yöndeki doğrusal hız) ve bir `` omega ‘’ (robot çerçevesinin merkezi etrafındaki açısal hız).

Döndürülen ayarlanmış hızlar, aktarma sistemi tipiniz için kinematik sınıfları kullanılarak kullanılabilir hızlara dönüştürülebilir. Aşağıdaki örnek kodda, bir swerve sürücü robotu varsayacağız; bununla birlikte, kinematik kodu, MecanumDriveKinematics kullanımı haricinde bir mecanum tahrik robotu için tamamen aynıdır.

SwerveModuleState[] moduleStates = kinematics.toSwerveModuleStates(adjustedSpeeds);

SwerveModuleState frontLeft = moduleStates[0];
SwerveModuleState frontRight = moduleStates[1];
SwerveModuleState backLeft = moduleStates[2];
SwerveModuleState backRight = moduleStates[3];
auto [fl, fr, bl, br] = kinematics.ToSwerveModuleStates(adjustedSpeeds);

Bu sapma modülü durumları, hala hızlar ve açılar olduğundan; bu hızları ve açıları ayarlamak için PID kontrolcüleri kullanmanız gerekecektir.