Skip to content

Conversation

@akeeste
Copy link
Contributor

@akeeste akeeste commented May 25, 2021

This PR adds the ability to include multiple consecutive rotations in the body, constraint and pto setInitDisp() methods.

To keep compatibility with the old setInitDisp function, the axis-angle input is kept. Now, a list of axes is input as a size [nAngle 3] array, and the angle is input as [nAngle 1] array. I thought this implementation is less restrictive than forcing users to input Euler-XYZ convention or similar. They can effectively use any extrinsic convention by listing axes in the desired order.

I removed the x_rot (rotation point) parameter because only the relative coordinates are required. The displacement due to the rotation can be simplified to only depend on relCoord = cg - x_rot, removing the requirement for the cg or rotation point to be defined. For simplicity, only a single relCoord is allowed.

@akeeste akeeste requested a review from dav-og May 25, 2021 00:04
@akeeste akeeste added Feature new feature request Body Class Body Class (bodyClass.m) Constraint Class Constraint Class (constraintClass.m) Mooring Class Mooring Class (mooringClass.m) PTO Class Power Take-off Class (ptoClass.m) labels May 25, 2021
@akeeste akeeste linked an issue May 26, 2021 that may be closed by this pull request
@dav-og
Copy link
Contributor

dav-og commented May 26, 2021

Hey @akeeste would it be possible to get some unit tests for this function? I'm thinking at least two tests, where we pass different rotation sequences and check that its returning what we expect...

e.g.
z 180, y 180, x 180 (should rotate back to original orientation I think)

x 90, z 90, x -90
should be consistent with y 90 (I think?)

@akeeste
Copy link
Contributor Author

akeeste commented May 26, 2021

@dav-og Good idea, I'll make tests for those cases. I'll also add two for the special cases of converting a rotation matrix back to an axis-angle (180 deg or 0 deg in an axis)

@dav-og
Copy link
Contributor

dav-og commented May 26, 2021

Also, what do you think of passing the rotation axis and amount together?
e.g.
image
I feel like passing them together rather than in 2 separate lists might make it easier for the user to ensure that they've set their sequence correctly?

(You could then also just have a couple lines to extract angleList and axisList so to keep the rest of the code as it is 👍)

@akeeste
Copy link
Contributor Author

akeeste commented May 27, 2021

@dav-og
Yes I think that will help users keep their input parameters in order. However if we change the convention to passing axis and angle together, I think we should change the rest of the rotation functions too. This is likely the only time users pass these so it should be consistent for them either way, but it will help the development team from mixing conventions.

Also I'm not sure why ptoClass.m is conflicting, but I'll fix that when I push the tests too.

@akeeste
Copy link
Contributor Author

akeeste commented Jun 2, 2021

@dav-og I have pushed a few CI tests for these functions and fixed the ptoClass.m conflict. Do you think it is worthwhile to change all the function parameters to a combined axis-angle format or leave them as is?

@dav-og
Copy link
Contributor

dav-og commented Jun 3, 2021

hey @akeeste, do you mean like the rotMat function, where axis & angle are separate arguments?
function rotMat = axisAngle2RotMat(axis,angle)

I think it would be neater/consistent...but any function that just takes one axis & one rotation is less of a priority IMO. I just thought for a UI that enables a sequence of rotations...then maybe passing one list of axes & angles would be a cleaner UI than a list of axes and a separate list of angles?

@akeeste
Copy link
Contributor Author

akeeste commented Jun 4, 2021

@dav-og

Yes I was referring to the other angle functions like axisAngle2RotMat or rotateXYZ. Since its not as important, I will leave them as is for now. Its a library change that will be more difficult to pull in/check.

I did push an update to combine the axis-angle for body, constraint, pto, mooring setInitDisp() method as you suggest.

All the CI tests I added for the function are working.

Copy link
Contributor

@dav-og dav-og left a comment

Choose a reason for hiding this comment

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

This is a good new feature that gives greater flexibility to the user when defining initial displacement/orientation (i.e. for decay tests). Any rotation sequence can be specified to set the initial orientation - and the function is agnostic wrt the rotation order convention used, which is great.

My feedback:

  • ✅ unit tests
    • tests look good and they are all passing on my local version
  • ✅ modified UI
    • I suggested combining axis and angle - maybe in a dictionary - to make it simpler for the user (and harder to specify the wrong angle for desired axis). The modification does this and I think its fine but everything is in one list - so we do have mixed types in the same array. Probably fine but something to bear in mind.

@akeeste akeeste merged commit 5fa3f6b into WEC-Sim:dev Jun 9, 2021
@akeeste akeeste deleted the feature_multiRotation branch June 9, 2021 17:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Body Class Body Class (bodyClass.m) Constraint Class Constraint Class (constraintClass.m) Feature new feature request Mooring Class Mooring Class (mooringClass.m) PTO Class Power Take-off Class (ptoClass.m)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Multiple initial rotations in setInitDisp() method

2 participants