[x] I am at the right place and my issue is directly related to ROS#. General technical questions I would post e.g. at ROS Answers or Stack Overflow. For library-specific questions I would look for help in the corresponding library forums.
[x] I have thoroughly read the Contributing Guideline and writing this issue is the right thing to do in my case.
I have a question!
[x] I searched the Wiki, open and closed issues for an answer. I tried my best to find the answer by myself without success. I believe that the discussion we will have in this issue, and the solutions we might find, will help me, and likely other community members who have a similar problem.
Here is my question:
I am trying to connect to and subscribe to Topics on ROSbridge. It works fine if i specify the Type of message upon subscribing as per the code example in the Test Client:
however I wish to be able to specify the topic and type by string and find that type and call the subscribe method.
I know I can do it with an exhaustive Switch e.g.:
public static string Subscribe(string type, string topic)
{
switch (type)
{
case "sensor_msgs/JointState":
return rosSocket.Subscribe<JointState>(topic, SubscriptionHandler);
break;
case "actionlib_msgs/GoalID":
return rosSocket.Subscribe<GoalID>(topic, SubscriptionHandler);
break;
}
return "";
}
But this will get pretty long and unmanageable especially if i add new Message types for different robots. I have therefore spent some time trying to use reflection to get the type to invoke the Subscribe call, but I seem to be falling over when trying to pass in the Subscription handler. Has anyone done similar, or provide an example of how to do this - many thanks.
I have a question!
Here is my question: I am trying to connect to and subscribe to Topics on ROSbridge. It works fine if i specify the Type of message upon subscribing as per the code example in the Test Client:
however I wish to be able to specify the topic and type by string and find that type and call the subscribe method.
I know I can do it with an exhaustive Switch e.g.:
But this will get pretty long and unmanageable especially if i add new Message types for different robots. I have therefore spent some time trying to use reflection to get the type to invoke the Subscribe call, but I seem to be falling over when trying to pass in the Subscription handler. Has anyone done similar, or provide an example of how to do this - many thanks.