control
Control
¶
Bases: Variable
Control input variable for trajectory optimization problems.
Control represents control input variables (actuator commands) in a trajectory optimization problem. Unlike State variables which evolve according to dynamics, Controls are direct decision variables that the optimizer can freely adjust (within specified bounds) at each time step to influence the system dynamics.
Controls are conceptually similar to State variables but simpler - they don't have boundary conditions (initial/final specifications) since controls are typically not constrained at the endpoints. Like States, Controls support:
- Min/max bounds to enforce actuator limits
- Initial trajectory guesses to help the optimizer converge
Common examples of control inputs include:
- Thrust magnitude and direction for spacecraft/rockets
- Throttle settings for engines
- Steering angles for vehicles
- Torques for robotic manipulators
- Force/acceleration commands
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
Unique name identifier for this control variable |
_shape |
tuple[int, ...]
|
Shape of the control vector (typically 1D like (3,) for 3D thrust) |
_slice |
slice | None
|
Internal slice information for variable indexing |
_min |
ndarray | None
|
Minimum bounds for each element of the control |
_max |
ndarray | None
|
Maximum bounds for each element of the control |
_guess |
ndarray | None
|
Initial guess for the control trajectory (n_points, n_controls) |
Example
Scalar throttle control bounded [0, 1]:
throttle = Control("throttle", shape=(1,))
throttle.min = [0.0]
throttle.max = [1.0]
throttle.guess = np.full((50, 1), 0.5) # Start at 50% throttle
3D thrust vector for spacecraft:
thrust = Control("thrust", shape=(3,))
thrust.min = [-10, -10, 0] # No downward thrust
thrust.max = [10, 10, 50] # Limited thrust
thrust.guess = np.zeros((50, 3)) # Initialize with zero thrust
2D steering control (left/right, forward/backward):
steer = Control("steer", shape=(2,))
steer.min = [-1, -1]
steer.max = [1, 1]
steer.guess = np.linspace([0, 0], [0, 1], 50) # Gradual acceleration
Source code in openscvx/symbolic/expr/control.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 | |
scaling_max
property
writable
¶
Get the scaling maximum bounds for the control variables.
Returns:
| Type | Description |
|---|---|
|
Array of scaling maximum values for each control variable element, or None if not set. |
scaling_min
property
writable
¶
Get the scaling minimum bounds for the control variables.
Returns:
| Type | Description |
|---|---|
|
Array of scaling minimum values for each control variable element, or None if not set. |