# Update the ts_hexapod internal simulator with the correct geometry for the hexapod

XMLWordPrintable

#### Details

• Type: Story
• Status: Done
• Resolution: Done
• Fix Version/s: None
• Component/s:
• Labels:
• Story Points:
1
• Sprint:
TSSW Sprint - Feb3 - Feb 14
• Team:
Telescope and Site
• Urgent?:
No

#### Description

Update the simulator in ts_hexapod with the correct geometry for the hexapod. That way when the CSC is run in simulation mode the commanded actuator lengths will be at at least approximately correct.

One known reason that the simulator may still differ from the Moog code is that the simulator assumes that pivot rotations are applied in order: x, y, z. For small rotations it doesn't matter much, but for larger motions the order is important.

Also change the simulator so length = 0 at nominal position (with the position set to 0,0,0 0,0,0).

#### Activity

Hide
Russell Owen added a comment -

Other changes:

• Since the simulator now moves more realistically, I added code to test_csc.py to allow speeding up mock controller moves, so the tests run reasonably quickly.
• I reformatted the code with black and added a git pre-commit hook to keep it that way.
• I added a revision history.

Pull request: https://github.com/lsst-ts/ts_hexapod/pull/11

Show
Russell Owen added a comment - Other changes: Since the simulator now moves more realistically, I added code to test_csc.py to allow speeding up mock controller moves, so the tests run reasonably quickly. I reformatted the code with black and added a git pre-commit hook to keep it that way. I added a revision history. Pull request: https://github.com/lsst-ts/ts_hexapod/pull/11
Hide
Te-Wei Tsai added a comment -

Update looks good and reflect the real system. Great job!

Show
Te-Wei Tsai added a comment - Update looks good and reflect the real system. Great job!
Hide
Russell Owen added a comment -

Te-Wei Tsai's review:

[mock_controller.py]

1. Do you want to put the file of “CAMERA HEXAPOD STRUT FLEXURE COORDINATES.xlsx” in the doc or doc/ref? Otherwise, no one knows what is this. In addition, I do not know the comment like “emailed to me (indirectly) from John Andrew 2020-02-13” is necessary or not for a future’s maintainer.

2. It might be goood to have the above file to let people know the meaning of the magic number here:

3. What is the benefit to write a number as 500_000 instead of 500000 or 5*1e5?

4. Although I know this is a guess, I am a little shocked to see the resolution could be in nm level:

[utils.py]

1. I could understand you reformatted the code in this PR for the readibility (or whatever the reason). But I thought here the original one is more familiar for a rotation matrix:

https://github.com/lsst-ts/ts_hexapod/pull/11/files#diff-1fe6a08da4d9305d9b23debf785a8728L126-R135

Show
Russell Owen added a comment - Te-Wei Tsai 's review: [mock_controller.py] 1. Do you want to put the file of “CAMERA HEXAPOD STRUT FLEXURE COORDINATES.xlsx” in the doc or doc/ref? Otherwise, no one knows what is this. In addition, I do not know the comment like “emailed to me (indirectly) from John Andrew 2020-02-13” is necessary or not for a future’s maintainer. https://github.com/lsst-ts/ts_hexapod/pull/11/files#diff-3eff6648ada2ac75c09c6e8ba651ea62R81-R82 2. It might be goood to have the above file to let people know the meaning of the magic number here: https://github.com/lsst-ts/ts_hexapod/pull/11/files#diff-3eff6648ada2ac75c09c6e8ba651ea62R83-R98 3. What is the benefit to write a number as 500_000 instead of 500000 or 5*1e5? https://github.com/lsst-ts/ts_hexapod/pull/11/files#diff-3eff6648ada2ac75c09c6e8ba651ea62R106 4. Although I know this is a guess, I am a little shocked to see the resolution could be in nm level: https://github.com/lsst-ts/ts_hexapod/pull/11/files#diff-3eff6648ada2ac75c09c6e8ba651ea62R108-R109 [utils.py] 1. I could understand you reformatted the code in this PR for the readibility (or whatever the reason). But I thought here the original one is more familiar for a rotation matrix: https://github.com/lsst-ts/ts_hexapod/pull/11/files#diff-1fe6a08da4d9305d9b23debf785a8728L126-R135
Hide
Russell Owen added a comment -

Thank you for the thorough review, and getting it done so quickly.

[mock_controller.py]

1. Good suggestion. I will add the file to the doc directory and clean up the description.

2. Likewise. I will add a URL to the comment.

3. I prefer _ every 3 digits for long integers to make the magnitude clearer. Unfortunately it only works for integers and these are treated as floats (and would be floats if we had higher resolution) so I'll remove the underscores. I suppose I could use exponential notation, but I find that more difficult to read.

4. Good catch! I agree that resolution is unrealistic. I'll back it off to 10.

[utils.py]

1. I agree that the code may be slightly harder to read, but in my opinion it is still quite readable. And it has the virtue of looking like black formatted code, thus looking more like the code around it. One of the great benefits of black is that it avoids having to think about code format. I prefer to only override black in extreme cases, and so far I have not come across any.

Show
Russell Owen added a comment - Thank you for the thorough review, and getting it done so quickly. [mock_controller.py] 1. Good suggestion. I will add the file to the doc directory and clean up the description. 2. Likewise. I will add a URL to the comment. 3. I prefer _ every 3 digits for long integers to make the magnitude clearer. Unfortunately it only works for integers and these are treated as floats (and would be floats if we had higher resolution) so I'll remove the underscores. I suppose I could use exponential notation, but I find that more difficult to read. 4. Good catch! I agree that resolution is unrealistic. I'll back it off to 10. [utils.py] 1. I agree that the code may be slightly harder to read, but in my opinion it is still quite readable. And it has the virtue of looking like black formatted code, thus looking more like the code around it. One of the great benefits of black is that it avoids having to think about code format. I prefer to only override black in extreme cases, and so far I have not come across any.
Hide
Russell Owen added a comment -

Merged to develop and master and tagged as v0.4.0

Note: the geometry is set as class variables in MockController in these lines of mock_controller.py: https://github.com/lsst-ts/ts_hexapod/blob/e86047c695e4cd19d2e451928919e8cc270d2337/python/lsst/ts/hexapod/mock_controller.py#L80-L110.

Thus it is very easy to override it in the script that runs the CSC. Here is an example showing how to override the actuator length limits:

 import asyncio   from lsst.ts import hexapod   hexapod.MockController.actuator_max_length =  hexapod.MockController.actuator_min_length =    asyncio.run(hexapod.HexapodCsc.amain()) 

Show
Russell Owen added a comment - Merged to develop and master and tagged as v0.4.0 Note: the geometry is set as class variables in MockController in these lines of mock_controller.py: https://github.com/lsst-ts/ts_hexapod/blob/e86047c695e4cd19d2e451928919e8cc270d2337/python/lsst/ts/hexapod/mock_controller.py#L80-L110 . Thus it is very easy to override it in the script that runs the CSC. Here is an example showing how to override the actuator length limits: import asyncio   from lsst.ts import hexapod   hexapod.MockController.actuator_max_length = <new value> hexapod.MockController.actuator_min_length = <new value>   asyncio.run(hexapod.HexapodCsc.amain())

#### People

Assignee:
Russell Owen
Reporter:
Russell Owen
Reviewers:
Te-Wei Tsai
Watchers:
Andy Clements, Doug Neill, Russell Owen, Te-Wei Tsai