Sequence Type
hakuturu583 opened this issue · 6 comments
hakuturu583 commented
I want to use Sequence Type in ros2_dotnet and I succeed to publish sequence type of Basic Type in my fork.
hakuturu583 commented
But, when subscribing Sequence Type of the Basic Type, the size of the sequence is too huge.
I want help.
hakuturu583 commented
My fork is here.
https://github.com/OUXT-Polaris/ros2_dotnet/tree/sequence_type
hakuturu583 commented
and my test code of publishing and subscribing Sequence Type is here.
hakuturu583 commented
Listener
using System;
using System.Reflection;
using System.Runtime;
using System.Runtime.InteropServices;
//using System.Threading;
using ROS2;
using ROS2.Utils;
namespace ConsoleApplication {
public class RCLDotnetListener {
public static void Main (string[] args) {
try
{
RCLdotnet.Init ();
INode node = RCLdotnet.CreateNode ("listener");
ISubscription<std_msgs.msg.Float32MultiArray> chatter_sub = node.CreateSubscription<std_msgs.msg.Float32MultiArray> (
"chatter", msg => Console.WriteLine ("I heard: [" + msg.Data.Count + "]"));
RCLdotnet.Spin (node);
}
catch(Exception ex)
{
Console.WriteLine( "\nMessage ---\n{0}", ex.Message );
Console.WriteLine(
"\nHelpLink ---\n{0}", ex.HelpLink );
Console.WriteLine( "\nSource ---\n{0}", ex.Source );
Console.WriteLine(
"\nStackTrace ---\n{0}", ex.StackTrace );
Console.WriteLine(
"\nTargetSite ---\n{0}", ex.TargetSite );
}
}
}
}
hakuturu583 commented
Talker
using System;
using System.Reflection;
using System.Runtime;
using System.Runtime.InteropServices;
using System.Threading;
using System.Collections.Generic;
using ROS2;
using ROS2.Utils;
namespace ConsoleApplication {
public class RCLDotnetTalker {
public static void Main (string[] args) {
RCLdotnet.Init ();
INode node = RCLdotnet.CreateNode ("talker");
try
{
std_msgs.msg.Float32MultiArray msg = new std_msgs.msg.Float32MultiArray();
IPublisher<std_msgs.msg.Float32MultiArray> chatter_pub = node.CreatePublisher<std_msgs.msg.Float32MultiArray> ("chatter");
int i = 1;
while (RCLdotnet.Ok ()) {
msg.Data = new List<float>{0.1f,0.2f};
i++;
//Console.WriteLine ("Publishing: \"" + msg.Data + "\"");
chatter_pub.Publish (msg);
// Sleep a little bit between each message
Thread.Sleep (1000);
}
}
catch(Exception ex)
{
Console.WriteLine( "\nMessage ---\n{0}", ex.Message );
Console.WriteLine(
"\nHelpLink ---\n{0}", ex.HelpLink );
Console.WriteLine( "\nSource ---\n{0}", ex.Source );
Console.WriteLine(
"\nStackTrace ---\n{0}", ex.StackTrace );
Console.WriteLine(
"\nTargetSite ---\n{0}", ex.TargetSite );
}
/*
int i = 1;
while (RCLdotnet.Ok ()) {
msg.Data = new List<float>{0.1f,0.2f};
i++;
//Console.WriteLine ("Publishing: \"" + msg.Data + "\"");
chatter_pub.Publish (msg);
// Sleep a little bit between each message
Thread.Sleep (1000);
}
*/
}
}
}
hakuturu583 commented
I succeed to solve this issue.