-
Notifications
You must be signed in to change notification settings - Fork 5
Fix up loading map files into SCS2 #250
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
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
2ad93b2
Fixed filename loading issues on the MCAPLogFileReader
PotatoPeeler3000 75c2f5a
Fix naming convention issues when trying to open an MCAP log
PotatoPeeler3000 38e41f5
Fixes a few bugs with the joint data not updating because of the stan…
PotatoPeeler3000 d65f9de
Tests and MCAPOdometryManager for reading in all the messages from an…
PotatoPeeler3000 9cc145c
Merge branch 'develop' into feature/loading-mcap
PotatoPeeler3000 f504a07
Add support for static fields with enums, message types that are part…
PotatoPeeler3000 bb64ac4
Update LZ4Frame encoding and decoming to use native libraries.
PotatoPeeler3000 a682fb0
Updated tests to reflect the newest LZ4 library included. Added comme…
PotatoPeeler3000 7542b84
Got the ROS2SchemaParser working with a robot log, better check for e…
PotatoPeeler3000 c8165e7
Replaced Java Concurrency code with this section from Java Concurrenc…
PotatoPeeler3000 7051ad8
Changed to use jros2 where I can for the ROS2SchemaParser
PotatoPeeler3000 41ddf71
Default to use BuiltinTools from jros2 to do some of the behavior
PotatoPeeler3000 9dcd530
Added support for protobuf for mcap files. Added many tests to cover …
PotatoPeeler3000 8e1c7e5
Merge branch 'develop' into feature/loading-mcap
PotatoPeeler3000 2bc8d8e
Keep generate formatting available
PotatoPeeler3000 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
73 changes: 73 additions & 0 deletions
73
scs2-definition/src/test/java/us/ihmc/scs2/definition/robot/sdf/SDFToolsTest.java
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 @@ | ||
| package us.ihmc.scs2.definition.robot.sdf; | ||
|
|
||
| import static org.junit.jupiter.api.Assertions.assertEquals; | ||
| import static org.junit.jupiter.api.Assertions.assertNull; | ||
|
|
||
| import java.io.File; | ||
| import java.io.IOException; | ||
| import java.nio.file.Files; | ||
| import java.util.ArrayList; | ||
| import java.util.Collections; | ||
| import java.util.List; | ||
|
|
||
| import org.junit.jupiter.api.Test; | ||
| import org.junit.jupiter.api.io.TempDir; | ||
|
|
||
| /** | ||
| * Covers {@link SDFTools#tryToConvertToPath}'s last-resort fallback: every earlier strategy in that method assumes | ||
| * the on-disk resource layout mirrors the {@code package://} URI's own path structure (e.g. a resource directory | ||
| * containing a matching {@code robot_description/robots/.../assets/...} tree). The fallback drops that assumption - | ||
| * it strips leading path segments off the URI one at a time and looks for the shrinking suffix directly under each | ||
| * resource directory - so a mesh still resolves even when the on-disk bundle has been flattened relative to the | ||
| * package path declared in the URDF (as happens with some downloaded log bundles). | ||
| * <p> | ||
| * Both tests use JUnit's {@code @TempDir} to fabricate a throwaway directory + a 1-byte placeholder file at test | ||
| * time (not checked into source, deleted automatically afterward) - nothing here depends on any real robot's mesh | ||
| * files or on-disk layout. | ||
| * </p> | ||
| */ | ||
| public class SDFToolsTest | ||
| { | ||
| /** | ||
| * {@code tempDir} holds only {@code assets/merged/test.stl} - no {@code robot_description/robots/version/urdf/} | ||
| * tree at all - while the requested URI is the full {@code package://robot_description/robots/version/urdf/ | ||
| * assets/merged/test.stl}. Every earlier resolution strategy in {@code tryToConvertToPath} would fail to find | ||
| * this (the on-disk layout doesn't match the URI's path), so a successful result here specifically exercises the | ||
| * suffix-stripping fallback - and its "prefer the longest/most-specific matching suffix" behavior, since | ||
| * {@code assets/merged/test.stl} is the first (most specific) suffix that happens to exist under {@code tempDir}. | ||
| */ | ||
| @Test | ||
| public void testTryToConvertToPathWithFlattenedResourceLayout(@TempDir File tempDir) throws IOException | ||
| { | ||
| // Simulates an on-disk resource bundle that has been flattened relative to the ROS package structure | ||
| // declared by the package:// URI, e.g. a downloaded log bundle with "assets/merged/*.stl" directly | ||
| // alongside the URDF, instead of the full "robot_description/robots/version/urdf/assets/merged/" tree. | ||
| File assetsDir = new File(tempDir, "assets/merged"); | ||
| assertEquals(true, assetsDir.mkdirs()); | ||
| File meshFile = new File(assetsDir, "test.stl"); | ||
| Files.write(meshFile.toPath(), new byte[] {0}); | ||
|
|
||
| String filename = "package://robot_description/robots/version/urdf/assets/merged/test.stl"; | ||
| List<String> resourceDirectories = new ArrayList<>(Collections.singletonList(tempDir.getAbsolutePath())); | ||
|
|
||
| String result = SDFTools.tryToConvertToPath(filename, resourceDirectories, getClass().getClassLoader()); | ||
|
|
||
| assertEquals(meshFile.getAbsolutePath(), result); | ||
| } | ||
|
|
||
| /** | ||
| * {@code tempDir} is empty this time - no file exists under any suffix of the requested URI, at any strip | ||
| * length, down to just the bare filename. The fallback (and every strategy before it) must give up gracefully | ||
| * and return {@code null} rather than throwing, so callers can report "mesh not found" instead of crashing. | ||
| */ | ||
| @Test | ||
| public void testTryToConvertToPathReturnsNullWhenUnresolvable(@TempDir File tempDir) | ||
| { | ||
| String filename = "package://robot_description/robots/version/urdf/assets/merged/does_not_exist.stl"; | ||
| List<String> resourceDirectories = new ArrayList<>(Collections.singletonList(tempDir.getAbsolutePath())); | ||
|
|
||
| String result = SDFTools.tryToConvertToPath(filename, resourceDirectories, getClass().getClassLoader()); | ||
|
|
||
| assertNull(result); | ||
| } | ||
| } |
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.
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.
Added lz4 strictly for mcap decoding