Pyscurve

pyscurve.constant_time_optimizer module

Optimization Functions for Trajectory Planning

This module defines functions for optimizing trajectory planning based on specified constraints. It utilizes the scipy.optimize module for numerical optimization.

Functions:
  • optimization_function: Returns the cost function and its gradient for trajectory optimization.

  • optimize_trajectory: Optimizes the trajectory using the Sequential Least Squares Quadratic Programming (SLSQP) method.

  • plan_trajectory: Plans the trajectory based on the optimized parameters.

pyscurve.constant_time_optimizer.optimization_function(S, v0, a_max, T)
pyscurve.constant_time_optimizer.optimize_trajectory(S, v0, a_max, T)
pyscurve.constant_time_optimizer.plan_trajectory(S, v0, a_max, T)

pyscurve.planner module

Abstract Base Class for Trajectory Planners

This module defines an abstract base class TrajectoryPlanner for trajectory planning algorithms. Any concrete class that implements this base class must provide an implementation for the plan_trajectory method.

Classes:
  • TrajectoryPlanner: Abstract base class for trajectory planners.

Methods:
  • plan_trajectory: Abstract method to be implemented by concrete subclasses for trajectory planning.

  • _check_shape: Internal method to check if all parameters have the same dimension.

class pyscurve.planner.TrajectoryPlanner

Bases: object

Abstract Base Class for Trajectory Planners.

Attributes:
  • __metaclass__ (ABCMeta): Metaclass for abstract base classes.

Methods:
  • __init__: Initializes the TrajectoryPlanner object.

  • plan_trajectory: Abstract method to be implemented by concrete subclasses for trajectory planning.

  • _check_shape: Internal method to check if all parameters have the same dimension.

abstract plan_trajectory()

Abstract method to be implemented by concrete subclasses for trajectory planning.

Parameters:
  • args: Variable-length argument list.

  • kwargs: Arbitrary keyword arguments.

Returns:
  • result: Result of the trajectory planning algorithm.

pyscurve.scurve module

S-Curve Trajectory Planner

This module implements the S-curve trajectory planner for multi-degree-of-freedom (DOF) robotic systems. The planner is capable of generating smooth and feasible trajectories while considering velocity, acceleration, and jerk constraints.

Classes:
  • ScurvePlanner: S-curve trajectory planner derived from the TrajectoryPlanner abstract base class.

Methods:
  • plan_trajectory: Plan S-curve trajectory with given constraints.

class pyscurve.scurve.ScurvePlanner(debug=False)

Bases: TrajectoryPlanner

S-Curve Trajectory Planner Class

Attributes:
  • planning_logger: Logger for logging planning information.

Methods:
  • __init__: Initializes the ScurvePlanner object.

  • __scurve_check_possibility: Checks whether the trajectory is feasible.

  • __compute_maximum_speed_reached: Computes parameters for maximum speed reached profile.

  • __compute_maximum_speed_not_reached: Computes parameters for maximum speed not reached profile.

  • __scurve_search_planning: Iteratively tries to achieve requirements with decreasing maximum possible acceleration.

  • __sign_transforms: Performs sign transforms for calculating trajectory with q1 < q0.

  • __point_sign_transform: Transforms a point back to the original sign.

  • __get_trajectory_func: Returns a function of time for the trajectory.

  • __get_trajectory_function: Wraps trajectory function with sign transforms.

  • __scurve_profile_no_opt: Computes S-curve trajectory parameters without optimization.

  • __put_params: Sets parameters in the trajectory list.

  • __get_dof_time: Computes the time for a specific degree of freedom.

  • __get_traj_params_containers: Initializes containers for trajectory parameters.

  • __plan_trajectory_1D: Plans a 1D S-curve trajectory.

  • plan_trajectory: Plans an S-curve trajectory with given constraints.

Example

>>> planner = ScurvePlanner()
>>> trajectory = planner.plan_trajectory(q0, q1, v0, v1, v_max, a_max, j_max)
plan_trajectory(q0, q1, v0, v1, v_max, a_max, j_max, t=None)

Plan S-curve trajectory with given constraints.

Parameters:
  • q0 (numpy.ndarray): Initial positions.

  • q1 (numpy.ndarray): Final positions.

  • v0 (numpy.ndarray): Initial velocities.

  • v1 (numpy.ndarray): Final velocities.

  • v_max (float): Maximum velocity constraint.

  • a_max (float): Maximum acceleration constraint.

  • j_max (float): Maximum jerk constraint.

  • t (float): Optional constant time constraint.

Returns:
  • Trajectory: Trajectory object containing time, trajectory functions, and degree of freedom information.

pyscurve.trajectory module

Trajectory Utilities

This module provides utilities for trajectory planning and visualization.

Classes:
  • PlanningError: Custom exception for planning errors.

  • Trajectory: Class representing a trajectory with acceleration, speed, and position profiles.

Methods:
  • plot_trajectory: Plot acceleration, speed, and position profiles of a trajectory.

Attributes:
  • ACCELERATION_ID: Identifier for acceleration in the trajectory profile.

  • SPEED_ID: Identifier for speed in the trajectory profile.

  • POSITION_ID: Identifier for position in the trajectory profile.

  • OPTIMIZER_THRESHOLD: Threshold for trajectory optimizer convergence.

  • EPSILON: Small value for numerical computations.

  • trajectory_logger: Logger for logging trajectory information.

exception pyscurve.trajectory.PlanningError(msg)

Bases: Exception

Custom exception class for planning errors.

class pyscurve.trajectory.Trajectory(debug=True)

Bases: object

Trajectory Class

Attributes:
  • debug (bool): Flag to enable debug logging.

  • time (float): Total time of the trajectory.

  • dof (int): Number of degrees of freedom.

  • trajectory (list): List of trajectory functions for each degree of freedom.

Methods:
  • __call__: Computes acceleration, speed, and position at a given time.

Example

>>> # Instantiate a Trajectory object
>>> trajectory = Trajectory()
>>> # Access and set attributes
>>> trajectory.debug = True
>>> trajectory.time = 5.0
>>> trajectory.dof = 3
>>> trajectory.trajectory = [traj_func_1, traj_func_2, traj_func_3]
>>> # Call the trajectory at a specific time
>>> result = trajectory(2.5)
property debug
property dof
property time
property trajectory
pyscurve.trajectory.plot_trajectory(traj, dt)

Plot acceleration, speed, and position profiles of a trajectory.

Parameters:
  • traj (Trajectory): Trajectory object.

  • dt (float): Time step for plotting.