Skip to content

Commit

Permalink
docs: Explain cost function within get_reward()
Browse files Browse the repository at this point in the history
  • Loading branch information
iwishiwasaneagle committed Mar 2, 2023
1 parent 8af69f8 commit b175e1c
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/jdrones/envs/position.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,38 @@ def reset(

@staticmethod
def get_reward(states: States) -> float:
"""
Calculate the cost of the segment with
.. math::
\\begin{gather}
J = \\sum_{i=0}^{T/dt} Q \\frac{\\vec x_i}{dt}
\\\\
Q =
\\left[
1000,1000,1000,0,0,0,0,10,10,10,1,1,1,1,1,1,0,0,0,0
\\right]
\\\\
\\vec x =
\\left[
x,y,z,q_x,q_y,q_z,q_w,\\phi,\\theta,\\psi,\\dot x,\\dot y,\\dot z,
p,q,r,P_1,P_2,P_3,P_4
\\right]
\\end{gather}
Where :math:`\\vec x_i` is the state matrix at time-step :math:`i`, and
:math:`Q` is a cost matrix prioritizing error in position and angle.
Parameters
----------
states : jdrones.data_models.States
Iterable containing the observed states at regular intervals :math:`dt`
Returns
-------
float
The calculated cost
"""
df = states.to_df(tag="temp")
df_sums = (
df.sort_values("t")
Expand Down

0 comments on commit b175e1c

Please sign in to comment.