Skip to content

Commit

Permalink
Update Representation name on Rd
Browse files Browse the repository at this point in the history
  • Loading branch information
Danfoa committed Nov 6, 2023
1 parent b18ccc3 commit 1c34658
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,15 +156,15 @@ In practice, products and additions of these representations are enough to obtai
Vector measurements can represent linear velocities, forces, linear accelerations, etc. While [pseudo-vectors](https://en.wikipedia.org/wiki/Pseudovector#:~:text=In%20physics%20and%20mathematics%2C%20a,of%20the%20space%20is%20changed) (or axial-vectors) can represent angular velocities, angular accelerations, etc. To obtain symmetric measurements we transform vectors with $`
\rho_{\mathrm{O}_d}`$. Likewise, to obtain symmetric pseudo-vectors we use $`\rho_{\mathrm{O}_{d,pseudo}}(g) := |\rho_{\mathrm{O}_d}(g)| \rho_{\mathrm{O}_d}(g) \; | \; g \in \mathcal{G}`$. Equivalently, in code we can do:
```python
rep_Od = G.representations['Od'] # rep_Od(g) is an orthogonal matrix ∈ R^dxd
rep_Od_pseudo = G.representations['Od_pseudo']
rep_Rd = G.representations['Rd'] # rep_Rd(g) is an orthogonal matrix ∈ R^dxd
rep_Rd_pseudo = G.representations['Od_pseudo']

v = np.random.rand(3) # Example vector in Ed, assuming d=3. E.g. linear velocity of the base frame.
w = np.random.rand(3) # Example pseudo-vector in Ed, assuming d=3. E.g. angular velocity of the base frame.
# The orbit of the vector is a map from group elements g ∈ G to the set of symmetric vectors g·v ∈ R^d
orbit_v = {g: rep_Od(g) @ v for g in G.elements}
orbit_v = {g: rep_Rd(g) @ v for g in G.elements}
# The orbit of the pseudo-vector is a map from group elements g ∈ G to the set of symmetric pseudo-vectors g·w ∈ R^d
orbit_w = {g: rep_Od_pseudo(g) @ w for g in G.elements}
orbit_w = {g: rep_Rd_pseudo(g) @ w for g in G.elements}
```

> As an example you can check the script [robot_symmetry_visualization.py](https://github.com/Danfoa/MorphoSymm/blob/devel/morpho_symm/robot_symmetry_visualization.py), where we use the symmetry representations to generate the animations of all robot in the library (with the same script).
Expand Down
12 changes: 6 additions & 6 deletions morpho_symm/robot_symmetry_visualization.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ def main(cfg: DictConfig):
rep_QJ = G.representations['Q_js'] # rep_QJ(g) is a permutation matrix ∈ R^nqj
rep_TqQJ = G.representations['TqQ_js'] # rep_TqQJ(g) is a permutation matrix ∈ R^nvj
rep_Ed = G.representations['Ed'] # rep_Ed(g) is a homogenous transformation matrix ∈ R^(d+1)x(d+1)
rep_Od = G.representations['Od'] # rep_Od(g) is an orthogonal matrix ∈ R^dxd
rep_Od_pseudo = G.representations['Od_pseudo'] # rep_Od_pseudo(g) is an orthogonal matrix ∈ R^dxd
rep_Rd = G.representations['Rd'] # rep_Rd(g) is an orthogonal matrix ∈ R^dxd
rep_Rd_pseudo = G.representations['Rd_pseudo'] # rep_Rd_pseudo(g) is an orthogonal matrix ∈ R^dxd

# Configuration of the 3D visualization -------------------------------------------------------------------------
# Not really relevant to understand.
Expand Down Expand Up @@ -75,7 +75,7 @@ def main(cfg: DictConfig):
# Consider the robot Center of Mass (CoM) momentum in base `B` coordinates. A vector and a pseudo-vector.
hg_B = np.array([0.1, 0.1, 0.0, -0.0, -0.2, -0.2]) # Set to fix value for visualization.
# The representation for the linear `l` and angular `k` components of Center of Mass (CoM) momentum `h=[l,k]` is:
rep_h = rep_Od + rep_Od_pseudo # Additions of representations amounts to block-diagonal matrix concatenation.
rep_h = rep_Rd + rep_Rd_pseudo # Additions of representations amounts to block-diagonal matrix concatenation.

# Define mock surface orientations `Rf_w`, force contact points `rf_w` and contact forces `f_w`
Rf1, Rf2, f1, f2, rf1, rf2 = get_mock_ground_reaction_forces(pb, robot, cfg.robot)
Expand Down Expand Up @@ -104,13 +104,13 @@ def main(cfg: DictConfig):

# Use symmetry representations to get symmetric versions of Euclidean vectors, representing measurements of data
# We could also add some pseudo-vectors e.g. torque, and augment them as we did with `k`
orbit_f1[g], orbit_f2[g] = rep_Od(g) @ f1, rep_Od(g) @ f2
orbit_f1[g], orbit_f2[g] = rep_Rd(g) @ f1, rep_Rd(g) @ f2
orbit_rf1[g] = (rep_Ed(g) @ np.concatenate((rf1, np.ones(1))))[:3] # using homogenous coordinates
orbit_rf2[g] = (rep_Ed(g) @ np.concatenate((rf2, np.ones(1))))[:3]

# Apply transformations to the terrain elevation estimations/measurements
orbit_Rf1[g] = rep_Od(g) @ Rf1 @ rep_Od(g).T
orbit_Rf2[g] = rep_Od(g) @ Rf2 @ rep_Od(g).T
orbit_Rf1[g] = rep_Rd(g) @ Rf1 @ rep_Rd(g).T
orbit_Rf2[g] = rep_Rd(g) @ Rf2 @ rep_Rd(g).T
# =============================================================================================================

# Visualization of orbits of robot states and of data ==========================================================
Expand Down
1 change: 0 additions & 1 deletion morpho_symm/utils/rep_theory_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ def isotypic_decomp_representation(rep: Representation) -> [Representation]:

def isotypic_basis(representation: Representation, multiplicity: int = 1, prefix=''):
rep_iso = isotypic_decomp_representation(representation)
Q_iso = rep_iso.change_of_basis

iso_reps = OrderedDict()
iso_range = OrderedDict()
Expand Down

0 comments on commit 1c34658

Please sign in to comment.