-
Notifications
You must be signed in to change notification settings - Fork 4
Feature/pose comparison #161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
DamienGilliard
wants to merge
30
commits into
release/2.0.0
Choose a base branch
from
feature/pose_comparison
base: release/2.0.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
dd62996
feat: bump up version from 1.3.0 to 1.3.1 in manifest.yml
DamienGilliard efa2582
Update manifest.yml
DamienGilliard 227504f
Merge pull request #156 from diffCheckOrg/DamienGilliard-patch-2
DamienGilliard 21f34f2
Update manifest.yml
DamienGilliard efdca84
Update manifest.yml
DamienGilliard b985813
ACTION_BOT: Sync version for release (#158)
github-actions[bot] 8f668b1
Merge pull request #157 from diffCheckOrg/DamienGilliard-patch-2
eleniv3d e2dead4
feat-wip: creation of pose comparison component
DamienGilliard cdef3ba
fix: remove unneeded markdown file
DamienGilliard 9475b6e
feat: add a plane property to beams, automatically computed and with …
DamienGilliard 7348919
feat: bump up version from 1.3.0 to 1.3.1 in manifest.yml
DamienGilliard f15c055
Update manifest.yml
DamienGilliard 0c3835d
ACTION_BOT: Sync version for release (#158)
github-actions[bot] 3d1be89
Update manifest.yml
DamienGilliard 63feaf7
Update manifest.yml
DamienGilliard eb0b20d
feat-wip: creation of pose comparison component
DamienGilliard b2a10b3
fix: remove unneeded markdown file
DamienGilliard af989eb
feat: add a plane property to beams, automatically computed and with …
DamienGilliard 28d6bb2
feat-wip: use assembly instead of explicit list of planes
DamienGilliard b97e8c6
rebasing to release/2.0.0 so the pose comparison component has the la…
DamienGilliard c1f2c86
feat: remove unneeded message about evaluation during assembly of aft…
DamienGilliard b466cd1
fix: rebase variable name mixup
DamienGilliard 32d9456
feat: update metadata of pose comparison conponent
DamienGilliard 0500f54
feat: adapt pose comparison component so it also works with the full …
DamienGilliard 12bd9e3
feat: remove type hint for i_measured_poses so it takes datatree as well
DamienGilliard 5683c05
fix: use plane instead of pose
DamienGilliard 6660ecb
fix: use consistent naming between pose estimation and pose comparison
DamienGilliard e0e314c
feat-fix: pose comparison takes (or converts to) data tree as input a…
DamienGilliard 5beaaaf
fix: more robust check for validity of poses that are used in the pos…
DamienGilliard 8c54bc5
fix: create DFBeam base plane with coherent orientation with plane de…
DamienGilliard File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule eigen
updated
from 81044e to 954e21
Submodule pybind11
updated
37 files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| --- | ||
| name: diffCheck | ||
| version: 1.3.0 | ||
| version: 1.3.1 | ||
| authors: | ||
| - Andrea Settimi | ||
| - Damien Gilliard | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| """Compares CAD poses with measured poses to compute errors.""" | ||
| #! python3 | ||
|
|
||
| import Rhino | ||
| import Grasshopper | ||
| from ghpythonlib.componentbase import executingcomponent as component | ||
| import ghpythonlib.treehelpers as th | ||
|
|
||
| import diffCheck.df_geometries | ||
| import numpy | ||
|
|
||
| def compute_comparison(measured_pose, cad_pose): | ||
| cad_origin = cad_pose.Origin | ||
| measured_origin = measured_pose.Origin | ||
| distance = cad_origin.DistanceTo(measured_origin) | ||
|
|
||
| # Compare the orientations using the formula: $$ \theta = \arccos\left(\frac{\text{trace}(R_{\text{pred}}^T R_{\text{meas}}) - 1}{2}\right) $$ | ||
| transform_o_to_cad = Rhino.Geometry.Transform.PlaneToPlane(Rhino.Geometry.Plane.WorldXY, cad_pose) | ||
| transform_o_to_measured = Rhino.Geometry.Transform.PlaneToPlane(Rhino.Geometry.Plane.WorldXY, measured_pose) | ||
| np_transform_o_to_cad = numpy.array(transform_o_to_cad.ToDoubleArray(rowDominant=True)).reshape((4, 4)) | ||
| np_transform_o_to_measured = numpy.array(transform_o_to_measured.ToDoubleArray(rowDominant=True)).reshape((4, 4)) | ||
|
|
||
| R_cad = np_transform_o_to_cad[:3, :3] | ||
| R_measured = np_transform_o_to_measured[:3, :3] | ||
| R_rel = numpy.dot(R_cad.T, R_measured) | ||
| theta = numpy.arccos(numpy.clip((numpy.trace(R_rel) - 1) / 2, -1.0, 1.0)) | ||
|
|
||
| # Compute the transformation matrix between the CAD pose and the measured pose | ||
| transform_cad_to_measured = Rhino.Geometry.Transform.PlaneToPlane(cad_pose, measured_pose) | ||
| return distance, theta, transform_cad_to_measured | ||
|
|
||
| class DFPoseComparison(component): | ||
| def RunScript(self, i_assembly: diffCheck.df_geometries.DFAssembly, i_measured_planes: Grasshopper.DataTree[object]): | ||
|
|
||
| CAD_poses = [beam.plane for beam in i_assembly.beams] | ||
|
|
||
| o_distances = [] | ||
| o_angles = [] | ||
| o_transforms_cad_to_measured = [] | ||
| # Compare the origins | ||
| # measure the distance between the origins of the CAD pose and the measured pose and output this in the component | ||
|
|
||
| bc = i_measured_planes.BranchCount | ||
| if bc > 1: | ||
| poses_per_beam = i_measured_planes.Branches | ||
| for beam_id, poses in enumerate(poses_per_beam): | ||
| o_distances.append(bc * []) | ||
| o_angles.append(bc * []) | ||
| o_transforms_cad_to_measured.append(bc * []) | ||
| for pose in poses: | ||
| if not pose or not pose.IsValid: | ||
| o_distances[beam_id].append(None) | ||
| o_angles[beam_id].append(None) | ||
| o_transforms_cad_to_measured[beam_id].append(None) | ||
| else: | ||
| dist, angle, transform_cad_to_measured = compute_comparison(pose, CAD_poses[beam_id]) | ||
| o_distances[beam_id].append(dist) | ||
| o_angles[beam_id].append(angle) | ||
| o_transforms_cad_to_measured[beam_id].append(transform_cad_to_measured) | ||
| else: | ||
| i_measured_planes.Flatten() | ||
| measured_plane_list = th.tree_to_list(i_measured_planes) | ||
| print(measured_plane_list) | ||
| for i, plane in enumerate(measured_plane_list): | ||
| dist, angle, transform_cad_to_measured = compute_comparison(plane, CAD_poses[i]) | ||
| o_distances.append(dist) | ||
| o_angles.append(angle) | ||
| o_transforms_cad_to_measured.append(transform_cad_to_measured) | ||
|
|
||
| if bc == 1: | ||
| return o_distances, o_angles, o_transforms_cad_to_measured | ||
| else: | ||
| return th.list_to_tree(o_distances), th.list_to_tree(o_angles), th.list_to_tree(o_transforms_cad_to_measured) | ||
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| { | ||
| "name": "DFPoseComparison", | ||
| "nickname": "DFPoseComparison", | ||
| "category": "diffCheck", | ||
| "subcategory": "Analysis", | ||
| "description": "Compares CAD poses with measured poses to compute errors.", | ||
| "exposure": 4, | ||
| "instanceGuid": "13d76641-6f4f-4e78-a7dd-e64e176ffb2a", | ||
| "ghpython": { | ||
| "hideOutput": true, | ||
| "hideInput": true, | ||
| "isAdvancedMode": true, | ||
| "marshalOutGuids": true, | ||
| "iconDisplay": 2, | ||
| "inputParameters": [ | ||
| { | ||
| "name": "i_assembly", | ||
| "nickname": "i_assembly", | ||
| "description": "The DFAssembly of the structure.", | ||
| "optional": false, | ||
| "allowTreeAccess": true, | ||
| "showTypeHints": true, | ||
| "scriptParamAccess": "item", | ||
| "wireDisplay": "default", | ||
| "sourceCount": 0, | ||
| "typeHintID": "ghdoc" | ||
| }, | ||
| { | ||
| "name": "i_measured_planes", | ||
| "nickname": "i_measured_planes", | ||
| "description": "The measured planes (aka poses) to compare against the CAD planes.", | ||
| "optional": false, | ||
| "allowTreeAccess": true, | ||
| "showTypeHints": true, | ||
| "scriptParamAccess": "tree", | ||
| "wireDisplay": "default", | ||
| "sourceCount": 0 | ||
| } | ||
| ], | ||
| "outputParameters": [ | ||
| { | ||
| "name": "o_distances", | ||
| "nickname": "o_distances", | ||
| "description": "The distances between the CAD pose origins and measured pose origins.", | ||
| "optional": false, | ||
| "sourceCount": 0, | ||
| "graft": false | ||
| }, | ||
| { | ||
| "name": "o_angles", | ||
| "nickname": "o_angles", | ||
| "description": "The angles between the CAD pose orientations and measured pose orientations.", | ||
| "optional": false, | ||
| "sourceCount": 0, | ||
| "graft": false | ||
| }, | ||
| { | ||
| "name": "o_transforms_cad_to_measured", | ||
| "nickname": "o_transforms_cad_to_measured", | ||
| "description": "The transformation matrices from CAD poses to measured poses.", | ||
| "optional": false, | ||
| "sourceCount": 0, | ||
| "graft": false | ||
| } | ||
| ] | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably the bc is not needed here..
bc * [ ] = [ ]Not a problem just confusing :)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If bc > 1, it means the full history has been given to compare with, so each of the N beam we have N poses to compare with. It sems to me we need the
bc * []