forked from ros2-dotnet/ros2_dotnet
-
Notifications
You must be signed in to change notification settings - Fork 2
Marshaling using "out" does not work on Windows and breaks BasicType arrays #6
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
samiamlabs
wants to merge
11
commits into
adamdbrw:master
Choose a base branch
from
samiamlabs:master
base: master
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
11 commits
Select commit
Hold shift + click to select a range
793210c
Merge pull request #1 from samiamlabs/merge-upstream
samiamlabs 2caf48e
Add uint8 test to unbounded sequences
samiamlabs a104b0b
:bug: Marshaling using "out" parameters does not work on windows
samiamlabs 76a1729
:fire: Comment out LaserScanPubSub test
samiamlabs 09f490d
Install unity_files to share dir
9cdb352
Change name of Player executable
d2feefa
:fire: Remove slow tests
samiamlabs 8a3af61
:fire: Remove debug comment
samiamlabs e307f6d
Use Sam's ros2_dotnet branch
samiamlabs 8a91644
Update README.md
samiamlabs a10941d
Use sam's .repos
samiamlabs 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
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 was deleted.
Oops, something went wrong.
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,64 @@ | ||
| using NUnit.Framework; | ||
| using System; | ||
| using System.Linq; | ||
|
|
||
| namespace rclcs.Test | ||
| { | ||
| [TestFixture] | ||
| public class LargeMessageTest | ||
| { | ||
| Context pub_context; | ||
| Context sub_context; | ||
| Node pub_node; | ||
| Node sub_node; | ||
|
|
||
| [SetUp] | ||
| public void SetUp() | ||
| { | ||
| pub_context = new Context(); | ||
| sub_context = new Context(); | ||
|
|
||
| Rclcs.Init(pub_context); | ||
| Rclcs.Init(sub_context); | ||
|
|
||
| pub_node = new Node("pub_node", pub_context); | ||
| sub_node = new Node("sub_node", sub_context); | ||
| } | ||
|
|
||
| [TearDown] | ||
| public void TearDown() | ||
| { | ||
| pub_node.Dispose(); | ||
| sub_node.Dispose(); | ||
| Rclcs.Shutdown(pub_context); | ||
| Rclcs.Shutdown(sub_context); | ||
| } | ||
|
|
||
| [Test] | ||
| public void ImagePubSub() | ||
| { | ||
| bool callbackTriggered = false; | ||
|
|
||
| var subscription = sub_node.CreateSubscription<sensor_msgs.msg.Image>( | ||
| "test_topic", (received_msg) => | ||
| { | ||
| callbackTriggered = true; | ||
| Assert.That(received_msg.Data.Length, Is.EqualTo(10)); | ||
| }); | ||
|
|
||
| var publisher = pub_node.CreatePublisher<sensor_msgs.msg.Image>("test_topic"); | ||
| var msg = new sensor_msgs.msg.Image(); | ||
| msg.Data = new byte[10]; | ||
| msg.Data[0] = 1; | ||
| publisher.Publish(msg); | ||
|
|
||
| Rclcs.SpinOnce(sub_node, sub_context, 0.5); | ||
|
|
||
| Assert.That(callbackTriggered, Is.True); | ||
|
|
||
| publisher.Dispose(); | ||
| subscription.Dispose(); | ||
| } | ||
|
|
||
| } | ||
| } |
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 |
|---|---|---|
|
|
@@ -17,86 +17,123 @@ public void CreateMessage() | |
| [Test] | ||
| public void SetBoolData() | ||
| { | ||
| std_msgs.msg.Bool msg = new std_msgs.msg.Bool(); | ||
| var msg = new std_msgs.msg.Bool(); | ||
| var msgCopy = new std_msgs.msg.Bool(); | ||
|
|
||
| msg.ReadNativeMessage(); | ||
| Assert.That(msg.Data, Is.False); | ||
|
|
||
| msg.Data = true; | ||
| Assert.That(msg.Data, Is.True); | ||
| msg.WriteNativeMessage(); | ||
| msgCopy.ReadNativeMessage(msg.Handle); | ||
| Assert.That(msgCopy.Data, Is.True); | ||
|
|
||
| msg.Data = false; | ||
| Assert.That(msg.Data, Is.False); | ||
| msg.WriteNativeMessage(); | ||
| msgCopy.ReadNativeMessage(msg.Handle); | ||
| Assert.That(msgCopy.Data, Is.False); | ||
| } | ||
|
|
||
| [Test] | ||
| public void SetInt64Data() | ||
| { | ||
| std_msgs.msg.Int64 msg = new std_msgs.msg.Int64(); | ||
| var msg = new std_msgs.msg.Int64(); | ||
| var msgCopy = new std_msgs.msg.Int64(); | ||
|
|
||
| Assert.That(msg.Data, Is.EqualTo(0)); | ||
| msg.Data = 12345; | ||
| Assert.That(msg.Data, Is.EqualTo(12345)); | ||
| } | ||
|
|
||
| [Test] | ||
| public void SetStringData() | ||
| { | ||
| std_msgs.msg.String msg = new std_msgs.msg.String(); | ||
| Assert.That(msg.Data, Is.EqualTo("")); | ||
| msg.Data = "Show me what you got!"; | ||
| Assert.That(msg.Data, Is.EqualTo("Show me what you got!")); | ||
| msg.WriteNativeMessage(); | ||
| msgCopy.ReadNativeMessage(msg.Handle); | ||
| Assert.That(msgCopy.Data, Is.EqualTo(12345)); | ||
| } | ||
|
|
||
| [Test] | ||
| public void SetDefaults() | ||
| { | ||
| test_msgs.msg.Defaults msg = new test_msgs.msg.Defaults(); | ||
| var msg = new test_msgs.msg.Defaults(); | ||
| var msgCopy = new test_msgs.msg.Defaults(); | ||
|
|
||
| msg.Int32_value = 24; | ||
| Assert.That(msg.Int32_value, Is.EqualTo(24)); | ||
| msg.WriteNativeMessage(); | ||
| msgCopy.ReadNativeMessage(msg.Handle); | ||
| Assert.That(msgCopy.Int32_value, Is.EqualTo(24)); | ||
|
|
||
| msg.Float32_value = 3.14F; | ||
| Assert.That(msg.Float32_value, Is.EqualTo(3.14F)); | ||
| msg.WriteNativeMessage(); | ||
| msgCopy.ReadNativeMessage(msg.Handle); | ||
| Assert.That(msgCopy.Float32_value, Is.EqualTo(3.14F)); | ||
| } | ||
|
|
||
| [Test] | ||
| public void SetStrings() | ||
| { | ||
| test_msgs.msg.Strings msg = new test_msgs.msg.Strings(); | ||
| var msg = new test_msgs.msg.Strings(); | ||
| var msgCopy = new test_msgs.msg.Strings(); | ||
|
|
||
| msg.ReadNativeMessage(); | ||
| Assert.That(msg.String_value, Is.EqualTo("")); | ||
|
|
||
| msg.String_value = "Turtles all the way down"; | ||
| Assert.That(msg.String_value, Is.EqualTo("Turtles all the way down")); | ||
| msg.WriteNativeMessage(); | ||
| msgCopy.ReadNativeMessage(msg.Handle); | ||
| Assert.That(msgCopy.String_value, Is.EqualTo("Turtles all the way down")); | ||
| } | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch there on not using the same messge |
||
|
|
||
| // NOTE(sam): Bool arrays seem to not work yet | ||
| [Test] | ||
| public void SetUnboundedSequenses() | ||
| public void SetUnboundedSequences() | ||
| { | ||
| test_msgs.msg.UnboundedSequences msg = new test_msgs.msg.UnboundedSequences(); | ||
| test_msgs.msg.UnboundedSequences msgCopy = new test_msgs.msg.UnboundedSequences(); | ||
|
|
||
| bool[] setBoolSequence = new bool[2]; | ||
| setBoolSequence[0] = true; | ||
| setBoolSequence[1] = false; | ||
| msg.Bool_values = setBoolSequence; | ||
|
|
||
| bool[] getBoolSequence = msg.Bool_values; | ||
| Assert.That(getBoolSequence.Length, Is.EqualTo(2)); | ||
| Assert.That(getBoolSequence[0], Is.True); | ||
| Assert.That(getBoolSequence[1], Is.False); | ||
| // msg.WriteNativeMessage(); | ||
| // msg.ReadNativeMessage(); | ||
| // Assert.That(msg.Bool_values_size, Is.EqualTo(2)); | ||
| // msgCopy.ReadNativeMessage(msg.Handle); | ||
|
|
||
| // bool[] getBoolSequence = msg.Bool_values; | ||
| // Assert.That(msg.Bool_values_size, Is.EqualTo(2)); | ||
| // Assert.That(getBoolSequence.Length, Is.EqualTo(2)); | ||
| // Assert.That(getBoolSequence[0], Is.True); | ||
| // Assert.That(getBoolSequence[1], Is.False); | ||
|
|
||
| int[] setIntSequence = new int[2]; | ||
| setIntSequence[0] = 123; | ||
| setIntSequence[1] = 456; | ||
| test_msgs.msg.UnboundedSequences msg2 = new test_msgs.msg.UnboundedSequences(); | ||
| msg2.Int32_values = setIntSequence; | ||
| int[] getIntList = msg2.Int32_values; | ||
| msg.Int32_values = setIntSequence; | ||
| int[] getIntList = msg.Int32_values; | ||
|
|
||
| Assert.That(getIntList.Length, Is.EqualTo(2)); | ||
| Assert.That(getIntList[0], Is.EqualTo(123)); | ||
| Assert.That(getIntList[1], Is.EqualTo(456)); | ||
|
|
||
| string[] setStringSequence = new string[2]; | ||
| setStringSequence[0] = "Hello"; | ||
| setStringSequence[1] = "world"; | ||
| test_msgs.msg.UnboundedSequences msg3 = new test_msgs.msg.UnboundedSequences(); | ||
| msg3.String_values = setStringSequence; | ||
| string[] getStringSequence = msg3.String_values; | ||
| msg.String_values = setStringSequence; | ||
| string[] getStringSequence = msg.String_values; | ||
| Assert.That(getStringSequence.Length, Is.EqualTo(2)); | ||
| Assert.That(getStringSequence[0], Is.EqualTo("Hello")); | ||
| Assert.That(getStringSequence[1], Is.EqualTo("world")); | ||
|
|
||
| Byte[] setUint8Sequence = new Byte[2]; | ||
| setUint8Sequence[0] = 1; | ||
| setUint8Sequence[1] = 2; | ||
| msg.Uint8_values = setUint8Sequence; | ||
| Byte[] getUint8Sequence = msg.Uint8_values; | ||
| Assert.That(getUint8Sequence.Length, Is.EqualTo(2)); | ||
| Assert.That(getUint8Sequence[0], Is.EqualTo(1)); | ||
| Assert.That(getUint8Sequence[1], Is.EqualTo(2)); | ||
| } | ||
|
|
||
|
|
||
| [Test] | ||
| public void SetBoundedSequenses() | ||
| public void SetBoundedSequences() | ||
| { | ||
| test_msgs.msg.BoundedSequences msg = new test_msgs.msg.BoundedSequences(); | ||
| bool[] setBoolSequence = new bool[2]; | ||
|
|
@@ -133,15 +170,16 @@ public void SetBoundedSequenses() | |
| [Test] | ||
| public void SetNested() | ||
| { | ||
| test_msgs.msg.Nested msg = new test_msgs.msg.Nested(); | ||
| test_msgs.msg.BasicTypes basic_types_msg = msg.Basic_types_value; | ||
| Assert.That(basic_types_msg.Int32_value, Is.EqualTo(0)); | ||
| basic_types_msg.Int32_value = 25; | ||
| Assert.That(basic_types_msg.Int32_value, Is.EqualTo(25)); | ||
| test_msgs.msg.BasicTypes basic_types_msg2 = msg.Basic_types_value; | ||
| Assert.That(basic_types_msg2.Int32_value, Is.EqualTo(25)); | ||
| var msg = new test_msgs.msg.Nested(); | ||
| var msgCopy = new test_msgs.msg.Nested(); | ||
| Assert.That(msg.Basic_types_value.Int32_value, Is.EqualTo(0)); | ||
| msg.Basic_types_value.Int32_value = 25; | ||
| msg.WriteNativeMessage(); | ||
| msgCopy.ReadNativeMessage(msg.Handle); | ||
| Assert.That(msgCopy.Basic_types_value.Int32_value, Is.EqualTo(25)); | ||
| } | ||
|
|
||
| // FIXME(sam): use ReadNativeMessage and WriteNativeMessage | ||
| [Test] | ||
| public void SetMultiNested() | ||
| { | ||
|
|
@@ -164,8 +202,29 @@ public void SetMultiNested() | |
| Assert.That(getUnboundedOfUnbounded[0].String_values[1], Is.EqualTo("world")); | ||
| } | ||
|
|
||
| /* | ||
| [Test] | ||
| public void SetImage() | ||
| { | ||
| var msg = new sensor_msgs.msg.Image(); | ||
| var msgCopy = new sensor_msgs.msg.Image(); | ||
|
|
||
| Assert.That(msg.Data.Length, Is.EqualTo(0)); | ||
| msg.Data = new byte[10]; | ||
| msg.WriteNativeMessage(); | ||
| Assert.That(msg.Data.Length, Is.EqualTo(10)); | ||
| msg.Data = new byte[2]; | ||
| msg.ReadNativeMessage(); | ||
| Assert.That(msg.Data.Length, Is.EqualTo(10)); | ||
| msg.Data = new byte[8]; | ||
| // NOTE(sam): Writing twice seems not work | ||
| // msg.WriteNativeMessage(); | ||
| msg.ReadNativeMessage(); | ||
| Assert.That(msg.Data.Length, Is.EqualTo(10)); | ||
| msgCopy.ReadNativeMessage(msg.Handle); | ||
| Assert.That(msgCopy.Data.Length, Is.EqualTo(10)); | ||
| } | ||
|
|
||
| /* | ||
| // NOTE(samiam): does not work yet | ||
| [Test] | ||
| public void SetStaticArrayPrimitives() | ||
|
|
||
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.
Good extension