Skip to content

Conversation

@zhouzq-thu
Copy link
Contributor

@zhouzq-thu zhouzq-thu commented May 13, 2019

References to other Issues or PRs

Fix ReferenceFrame DCM diff error #16824

Brief description of what is fixed or changed

Fix angular velocity from time differentiating the DCM.

from sympy import symbols
from sympy.physics.mechanics import ReferenceFrame, dynamicsymbols

q1, q2, q3 = dynamicsymbols('q1:4')

N = ReferenceFrame('N')
A = N.orientnew('A', 'axis', [q1, N.x])
B = A.orientnew('B', 'axis', [q2, A.y])
C = B.orientnew('C', 'axis', [q3, B.z])

DCM = C.dcm(N).T

D = N.orientnew('D', 'DCM', DCM)

print('DCM diff:', D.dcm(N) - C.dcm(N))
print('ang vel diff:', (D.ang_vel_in(N) - C.ang_vel_in(N)).simplify().express(N))

Result:

DCM diff: Matrix([[0, 0, 0], [0, 0, 0], [0, 0, 0]])
ang vel diff: 0

Other comments

Release Notes

  • physics.vector
    • fix ReferenceFrame _w_diff_dcm method

@sympy-bot
Copy link

sympy-bot commented May 13, 2019

Hi, I am the SymPy bot (v147). I'm here to help you write a release notes entry. Please read the guide on how to write release notes.

Your release notes are in good order.

Here is what the release notes will look like:

This will be added to https://github.com/sympy/sympy/wiki/Release-Notes-for-1.5.

Note: This comment will be updated with the latest check if you edit the pull request. You need to reload the page to see it.

Click here to see the pull request description that was parsed.

<!-- Your title above should be a short description of what
was changed. Do not include the issue number in the title. -->

#### References to other Issues or PRs
<!-- If this pull request fixes an issue, write "Fixes #NNNN" in that exact
format, e.g. "Fixes #1234". See
https://github.com/blog/1506-closing-issues-via-pull-requests . Please also
write a comment on that issue linking back to this pull request once it is
open. -->

Fix ReferenceFrame DCM diff error #16824 

#### Brief description of what is fixed or changed

Fix angular velocity from time differentiating the DCM.

```
from sympy import symbols
from sympy.physics.mechanics import ReferenceFrame, dynamicsymbols

q1, q2, q3 = dynamicsymbols('q1:4')

N = ReferenceFrame('N')
A = N.orientnew('A', 'axis', [q1, N.x])
B = A.orientnew('B', 'axis', [q2, A.y])
C = B.orientnew('C', 'axis', [q3, B.z])

DCM = C.dcm(N).T

D = N.orientnew('D', 'DCM', DCM)

print('DCM diff:', D.dcm(N) - C.dcm(N))
print('ang vel diff:', (D.ang_vel_in(N) - C.ang_vel_in(N)).simplify().express(N))
```

Result:

```
DCM diff: Matrix([[0, 0, 0], [0, 0, 0], [0, 0, 0]])
ang vel diff: 0
```


#### Other comments


#### Release Notes

<!-- Write the release notes for this release below. See
https://github.com/sympy/sympy/wiki/Writing-Release-Notes for more information
on how to write release notes. The bot will check your release notes
automatically to see if they are formatted correctly. -->

<!-- BEGIN RELEASE NOTES -->

* physics.vector
  * fix ReferenceFrame ```_w_diff_dcm``` method

<!-- END RELEASE NOTES -->

Update

The release notes on the wiki have been updated.

@codecov
Copy link

codecov bot commented May 13, 2019

Codecov Report

Merging #16828 into master will increase coverage by 0.014%.
The diff coverage is 100%.

@@              Coverage Diff              @@
##            master    #16828       +/-   ##
=============================================
+ Coverage   73.849%   73.864%   +0.014%     
=============================================
  Files          619       619               
  Lines       159669    159712       +43     
  Branches     37476     37486       +10     
=============================================
+ Hits        117915    117970       +55     
+ Misses       36294     36281       -13     
- Partials      5460      5461        +1

@oscarbenjamin
Copy link
Collaborator

This looks reasonable although I haven't checked the calculation in detail. Was it just a bug in the formula?

Can you add a test for this? The example from #16824 could be added to sympy/physics/vector/tests/test_frame.py

@zhouzq-thu
Copy link
Contributor Author

zhouzq-thu commented May 14, 2019

@oscarbenjamin, the test function has been added. Please check it.

Two test functions test_w_diff_dcm1() and test_w_diff_dcm2() both can be passed now.

DCM = C.dcm(N).T
D = N.orientnew('D', 'DCM', DCM)

assert D.dcm(N) == C.dcm(N)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you also include explicitly what this is testing for rather than just comparing the output of two different functions?

Otherwise this test will pass even if both just output e.g. zero.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added some documentation for both test functions and rewritten the original test_w_diff_dcm1() since it looks not good.

Co-Authored-By: Christopher Smith <smichr@gmail.com>
@smichr smichr merged commit 68e8ee9 into sympy:master May 14, 2019
@oscarbenjamin
Copy link
Collaborator

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants