Skip to content

Commit 5d8024e

Browse files
committed
Update docs for rotations
1 parent 59f38cf commit 5d8024e

16 files changed

+243
-27
lines changed

docs/make.jl

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,19 @@ makedocs(
1313
"continuous.md",
1414
"discrete.md",
1515
],
16+
"Rotations" => [
17+
# "liestate.md"
18+
"rotationstate.md",
19+
],
1620
"Important Types" => [
1721
"knotpoints.md",
22+
"trajectories.md",
23+
],
24+
"Internal API" => [
25+
"functionbase.md",
26+
"scalarfunction.md",
27+
"autodiff.md",
1828
],
19-
"Function Base" => "functionbase.md",
2029

2130
# "Getting Started" => [
2231
# "models.md",

docs/src/autodiff.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Differentiation API
2+
```@meta
3+
CurrentModule = RobotDynamics
4+
```
5+
RobotDynamics allows users to define different methods for obtaining derivatives of their
6+
functions. This is accomplished via the [`DiffMethod`](@ref) trait, which by default
7+
has three options:
8+
* `ForwardAD`: forward-mode automatic differentiation using
9+
[ForwardDiff.jl](https://github.com/JuliaDiff/ForwardDiff.jl)
10+
* `FiniteDifference`: finite difference approximation using
11+
[FiniteDiff.jl](https://github.com/JuliaDiff/FiniteDiff.jl)
12+
* `UserDefined`: analytical function defined by the user.
13+
14+
Almost every Jacobian is queried using the same form:
15+
16+
jacobian!(sig, diff, fun, J, y, z)
17+
18+
where `sig` is a [`FunctionSignature`](@ref), `diff` is a [`DiffMethod`](@ref), `fun` is
19+
an [`AbstractFunction`](@ref), `J` is the Jacobian, `y` is a vector the size of the
20+
output of the function, and `z` is an [`AbstractKnotPoint`]. Users are free to add more
21+
[`DiffMethod`](@ref) types to dispatch on their own differentiation method.
22+
23+
By default, no differentiation methods are provided for an [`AbstractFunction`](@ref),
24+
allowing the user to choose what methods they want defined, and to allow customization
25+
of the particular method to their function. However, we do provide the following macro
26+
to provide efficient implementations for `ForwardAD` and `FiniteDifference`:
27+
28+
```@docs
29+
@autodiff
30+
```

docs/src/functionbase.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# `AbstractFunction` API
1+
# [`AbstractFunction` API](@id AbstractFunction)
22
```@meta
33
CurrentModule = RobotDynamics
44
```
@@ -21,6 +21,10 @@ input_dim
2121
```@docs
2222
FunctionSignature
2323
DiffMethod
24+
StateVectorType
25+
EuclideanState
26+
RotationState
27+
statevectortype
2428
FunctionInputs
2529
functioninputs
2630
```

docs/src/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ them as a concatenated vector.
218218

219219
### Discretizing our dynamics
220220
We often need to discretize our continuous dynamics, either to simulate it or
221-
feed it into optimization frameworks. The [`DiscretizedModel`](@ref) type
221+
feed it into optimization frameworks. The [`DiscretizedDynamics`](@ref) type
222222
discretizes a [`ContinuousDynamics`](@ref) model, turning it into a
223223
[`DiscreteDynamics`](@ref) model by applying a [`QuadratureRule`](@ref).
224224
To discretize our system using, e.g. Runge-Kutta 4, we create a new

docs/src/liestate.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#

docs/src/rotationstate.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# The Rotation State
2+
```@meta
3+
CurrentModule = RobotDynamics
4+
```
5+
As mentioned in [AbstractFunction](@ref AbstractFunction), RobotDynamics can work
6+
with non-Euclidean state vectors, or state vectors whose composition rule is not
7+
simple addition. The most common example of non-Euclidean state vectors in robotics
8+
is that of 3D rotations. Frequently our state vectors include a 3D rotation together
9+
with normal Euclidean states such as position, linear or angular velocities, etc.
10+
The [`RotationState`](@ref) [`StateVectorType`](@ref) represents this type of state vector.
11+
In general, this represents a state vector of the following form:
12+
13+
```math
14+
\begin{bmatrix}
15+
x_1 \\
16+
q_1 \\
17+
x_2 \\
18+
q_2 \\
19+
\vdots \\
20+
x_{N-1} \\
21+
q_N \\
22+
x_N
23+
\end{bmatrix}
24+
```
25+
where ``x_k \in \mathbb{R}^{n_k}`` and ``q_k \in SO(3)``. Any of the ``n_k`` can be zero.
26+
27+
This state is described by the [`LieState`](@ref) struct:
28+
```@docs
29+
LieState
30+
QuatState
31+
```
32+
33+
## The `LieGroupModel` type
34+
To simplify the definition of models whose state vector is a [`RotationState`](@ref), we
35+
provide the abstract [`LieGroupModel`](@ref) type:
36+
37+
```@docs
38+
LieGroupModel
39+
```
40+
41+
## Single rigid bodies
42+
A lot of robotic systems, such as airplanes, quadrotors, underwater vehicles, satellites,
43+
etc., can be described as a single rigid body subject to external forces and actuators.
44+
RobotDynamics provides the [`RigidBody`](@ref) model type for this type of system:
45+
46+
```@docs
47+
RigidBody
48+
Base.position(::RBState)
49+
orientation
50+
linear_velocity
51+
angular_velocity
52+
build_state
53+
parse_state
54+
gen_inds
55+
flipquat
56+
```
57+
58+
## The `RBState` type
59+
When working with rigid bodies, the rotation can be represented a variety of methods and
60+
dealing with this ambiguity can be tedious. We provide the [`RBState`](@ref) type which
61+
represents a generic state for a rigid body, representing the orietation as a quaternion.
62+
It provides easy methods to convert to and from the state vector for a given `RigidBody{R}`.
63+
64+
```@docs
65+
RBState
66+
```

docs/src/scalarfunction.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Scalar Functions
2+
```@meta
3+
CurrentModule = RobotDynamics
4+
```
5+
Instead of working with vector-valued functions like dynamics functions, we often need
6+
to define scalar functions that accept our state and control vectors, such as cost /
7+
objective / reward functions. This page provides the API for working with these
8+
types of functions, represented by the abstract [`ScalarFunction`](@ref) type, which
9+
is a specialization of an [`AbstractFunction`](@ref) with an output dimension of 1.
10+
11+
```@docs
12+
ScalarFunction
13+
```

docs/src/trajectories.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
# Trajectories
2+
3+
```@meta
4+
CurrentModule = RobotDynamics
5+
```
6+
27
When dealing with dynamical sytems, we often need to keep track of and represent
38
trajectories of our system. RobotDynamics provides an [`AbstractTrajectory`](@ref)
49
that can represent any trajectory, continuous or discrete. The only requirements on an
@@ -11,7 +16,7 @@ AbstractTrajectory
1116

1217
One convenient way of representing a trajectory is by sampling the states and controls
1318
along it. RobotDynamics provides the `SampledTrajectory` type which is basically a vector
14-
of [`AbstractKnotPoint](@ref) types. This is described by the following API:
19+
of [`AbstractKnotPoint`](@ref) types. This is described by the following API:
1520

1621
```@docs
1722
SampledTrajectory

src/discretized_dynamics.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ abstract type Implicit <: QuadratureRule end
7474
DiscretizedDynamics
7575
7676
Represents a [`DiscreteDynamics`](@ref) model formed by integrating a continuous
77-
dynamics model. It is essentially a [`ContinuousModel`](@ref) paired with a
77+
dynamics model. It is essentially a [`ContinuousDynamics`](@ref) paired with a
7878
[`QuadratureRule`](@ref) that defines how to use the [`dynamics!`](@ref) function
7979
to get a [`discrete_dynamics!`](@ref) function.
8080

src/dynamics.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ longer computed using pure subtraction. We can define a custom function for taki
5252
differences between 2 states vectors based on the type of the state vector.
5353
5454
We can query the type of the state vector using [`statevectortype(model)`](@ref),
55-
which returns a [`StatVectorType`](@ref) trait (by default, [`EuclideanState`](@ref)).
55+
which returns a [`StateVectorType`](@ref) trait (by default, [`EuclideanState`](@ref)).
5656
After defining a new `StateVectorType` and the following methods (described in more
5757
detail in the documentation for [`StateVectorType`](@ref)):
5858

0 commit comments

Comments
 (0)