Introduction to Kinematics and The ChassisSpeeds Class

Not

Kinematics and odometry uses a common coordinate system. You may wish to reference the Coordinate System section for details.

Kinematik nedir?

The kinematics suite contains classes for differential drive, swerve drive, and mecanum drive kinematics and odometry. The kinematics classes help convert between a universal ChassisSpeeds (Java, C++, Python)object, containing linear and angular velocities for a robot to usable speeds for each individual type of drivetrain i.e. left and right wheel speeds for a differential drive, four wheel speeds for a mecanum drive, or individual module states (speed and angle) for a swerve drive.

Odometri nedir?

Odometri, robotun sahadaki konumunun bir tahminini oluşturmak için robot üzerindeki sensörlerin kullanılmasını içerir. FRC’de bu sensörler tipik olarak birkaç kodlayıcıdır (tam sayı sürücü tipine bağlıdır) ve robot açısını ölçmek için bir jiroskoptur. Odometri sınıfları, robotun sahadaki konumunun bir tahminini oluşturmak için hızlarla (ve sapma durumunda açılar) ilgili periyodik kullanıcı girdileriyle birlikte kinematik sınıflarını kullanır.

The ChassisSpeeds Class

ChassisSpeeds nesnesi, yeni WPILib kinematik ve odometri takımı için çok önemlidir. ChassisSpeeds nesnesi, bir robot kasasının hızlarını temsil eder. Bu yapının üç bileşeni vardır:

  • `` vx`` : Robotun x (ileri) yönündeki hızı.

  • vy : Robotun y (yana doğru) yönündeki hızı. (Pozitif değerler, robotun sola hareket ettiği anlamına gelir).

  • omega : Robotun saniyede radyan cinsinden açısal hızı.

Not

Holonomik olmayan bir aktarma organı (yani, yana doğru hareket edemeyen bir aktarma organı, örneğin bir diferansiyel tahrik), yanlara doğru hareket edememesi nedeniyle sıfır vy bileşenine sahip olacaktır.

ChassisSpeeds nesnesi oluşturma

The constructor for the ChassisSpeeds object is very straightforward, accepting three arguments for vx, vy, and omega. In Java and Python, vx and vy must be in meters per second. In C++, the units library may be used to provide a linear velocity using any linear velocity unit.

// The robot is moving at 3 meters per second forward, 2 meters
// per second to the right, and rotating at half a rotation per
// second counterclockwise.
var speeds = new ChassisSpeeds(3.0, -2.0, Math.PI);
// The robot is moving at 3 meters per second forward, 2 meters
// per second to the right, and rotating at half a rotation per
// second counterclockwise.
frc::ChassisSpeeds speeds{3.0_mps, -2.0_mps,
  units::radians_per_second_t(std::numbers::pi)};
import math
from wpimath.kinematics import ChassisSpeeds

# The robot is moving at 3 meters per second forward, 2 meters
# per second to the right, and rotating at half a rotation per
# second counterclockwise.
speeds = ChassisSpeeds(3.0, -2.0, math.pi)

Saha-bağıl hızlardan ChassisSpeeds Nesnesi Oluşturma

Robot açısı verildiğinde, bir dizi alana bağlı hızdan bir ChassisSpeeds nesnesi de oluşturulabilir. Bu, alana göre bir dizi istenen hızı (örneğin, karşı ittifak istasyonuna doğru ve sağ alan sınırına doğru) robot çerçevesine göre hızları temsil eden bir ChassisSpeeds nesnesine dönüştürür. Bu, bir sapma veya mecanum tahrik robotu için saha odaklı kontrolleri uygulamak için kullanışlıdır.

The static ChassisSpeeds.fromFieldRelativeSpeeds (Java / Python) / ChassisSpeeds::FromFieldRelativeSpeeds (C++) method can be used to generate the ChassisSpeeds object from field-relative speeds. This method accepts the vx (relative to the field), vy (relative to the field), omega, and the robot angle.

// The desired field relative speed here is 2 meters per second
// toward the opponent's alliance station wall, and 2 meters per
// second toward the left field boundary. The desired rotation
// is a quarter of a rotation per second counterclockwise. The current
// robot angle is 45 degrees.
ChassisSpeeds speeds = ChassisSpeeds.fromFieldRelativeSpeeds(
  2.0, 2.0, Math.PI / 2.0, Rotation2d.fromDegrees(45.0));
// The desired field relative speed here is 2 meters per second
// toward the opponent's alliance station wall, and 2 meters per
// second toward the left field boundary. The desired rotation
// is a quarter of a rotation per second counterclockwise. The current
// robot angle is 45 degrees.
frc::ChassisSpeeds speeds = frc::ChassisSpeeds::FromFieldRelativeSpeeds(
  2_mps, 2_mps, units::radians_per_second_t(std::numbers::pi / 2.0), Rotation2d(45_deg));
import math
from wpimath.kinematics import ChassisSpeeds
from wpimath.geometry  import Rotation2d

# The desired field relative speed here is 2 meters per second
# toward the opponent's alliance station wall, and 2 meters per
# second toward the left field boundary. The desired rotation
# is a quarter of a rotation per second counterclockwise. The current
# robot angle is 45 degrees.
speeds = ChassisSpeeds.fromFieldRelativeSpeeds(
  2.0, 2.0, math.pi / 2.0, Rotation2d.fromDegrees(45.0))

Not

Açısal hız, açık bir şekilde “sahaya göre” olarak belirtilmemiştir çünkü açısal hız, bir alan perspektifinden veya bir robot perspektifinden ölçülen ile aynıdır.