Yörüngeleri Manipüle Etmek

Bir yörünge oluşturulduktan sonra, belirli yöntemleri kullanarak ondan bilgi alabilirsiniz. Bu yöntemler, bu yörüngeleri izlemek için kod yazarken faydalı olacaktır.

Yörüngenin Toplam Süresini Elde Etmek

Because all trajectories have timestamps at each point, the amount of time it should take for a robot to traverse the entire trajectory is pre-determined. The TotalTime() (C++) / getTotalTimeSeconds() (Java) / totalTime (Python) method can be used to determine the time it takes to traverse the trajectory.

// Get the total time of the trajectory in seconds
double duration = trajectory.getTotalTimeSeconds();
// Get the total time of the trajectory
units::second_t duration = trajectory.TotalTime();
# Get the total time of the trajectory
duration = trajectory.totalTime()

Yörüngeyi Örnekleme

The trajectory can be sampled at various timesteps to get the pose, velocity, and acceleration at that point. The Sample(units::second_t time) (C++) / sample(double timeSeconds) (Java/Python) method can be used to sample the trajectory at any timestep. The parameter refers to the amount of time passed since 0 seconds (the starting point of the trajectory). This method returns a Trajectory::Sample with information about that sample point.

// Sample the trajectory at 1.2 seconds. This represents where the robot
// should be after 1.2 seconds of traversal.
Trajectory.Sample point = trajectory.sample(1.2);
// Sample the trajectory at 1.2 seconds. This represents where the robot
// should be after 1.2 seconds of traversal.
Trajectory::State point = trajectory.Sample(1.2_s);
# Sample the trajectory at 1.2 seconds. This represents where the robot
# should be after 1.2 seconds of traversal.
point = trajectory.sample(1.2)

`` Yörünge :: Örnek`` yapısı, örnek nokta hakkında birkaç parça bilgi içerir:

  • t: Yörüngenin başlangıcından örnekleme noktasına kadar geçen süre.

  • velocity: Numune noktasındaki hız.

  • acceleration: Örnek noktadaki ivme.

  • `` pose``: Örnek noktadaki poz (x, y, başlık).

  • curvature: Numune noktasındaki eğrilik (yörünge boyunca mesafeye göre yön değişim oranı).

Not: Numune noktasındaki açısal hız, hızı eğrilik ile çarparak hesaplanabilir.

Yörüngenin Tüm Durumlarını Alma (Gelişmiş)

A more advanced user can get a list of all states of the trajectory by calling the States() (C++) / getStates() (Java) / states (Python) method. Each state represents a point on the trajectory. When the trajectory is created using the TrajectoryGenerator::GenerateTrajectory(...) method, a list of trajectory points / states are created. When the user samples the trajectory at a particular timestep, a new sample point is interpolated between two existing points / states in the list.