uml-robotics / ROS.NET

ROS.NET: ROS Client Library for Windows Development in C#
BSD 2-Clause "Simplified" License
93 stars 52 forks source link

Unable to publish a GoalId without stamp. #52

Closed BascoDLowell closed 5 years ago

BascoDLowell commented 5 years ago

I am trying to cancel all goals by sending a GoalId message with empty id and stamp, as was mentioned at ROS wiki. roswiki

So far I tried publishing goal like:

Messages.actionlib_msgs.GoalID goal = new Messages.actionlib_msgs.GoalID
            {
                id = "",
                stamp = null
            };

But it would throw an exception as:

Info: System.NullReferenceException at Messages.actionlib_msgs.GoalID.Serialize(Boolean) at Messages.IRosMessage.Serialize() at Ros_CSharp.TransportSubscriberLink.startMessageWrite(Boolean) at Ros_CSharp.TransportSubscriberLink.enqueueMessage(Ros_CSharp.MessageAndSerializerFunc) at Ros_CSharp.Publication.EnqueueMessage(Ros_CSharp.MessageAndSerializerFunc) at Ros_CSharp.Publication.processPublishQueue() at Ros_CSharp.Poll_Signal.threadFunc() at System.Threading.ThreadHelper.ThreadStart_Context(System.Object) at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object) at System.Threading.ThreadHelper.ThreadStart()

I'm quite sure, the problem is with the stamp as I was able to publish successfully with same empty id and a filled-up stamp.

nuclearmistake commented 5 years ago

Have you tried setting the stamp to 0,0? Or .now?

BascoDLowell commented 5 years ago

I'll try and get back to this.

nuclearmistake commented 5 years ago

Thanks

BascoDLowell commented 5 years ago

Hi @nuclearmistake ! My publisher is on one computer while my subscriber/Ros master is on another computer. I specifically need to get the .now of the Ros master. May I know how could I do it? I saw you have a function Ros_CSharp.ROS.GetTime() without argument. May I know what this is doing?

nuclearmistake commented 5 years ago

GetTime() should be synced to either wall time or Ros time if it's available... If I recall

nuclearmistake commented 5 years ago

///

/// Gets the current time as secs/nsecs /// /// public static m.Time GetTime() { return GetTime(DateTime.Now); }

It's in ROS_Comm/_init.cs

nuclearmistake commented 5 years ago

Usually NTP and windows network time are advised, as Ros /time is usually more of bag / stage / gazebo thing

BascoDLowell commented 5 years ago

hmm, I see. So I really just have to find a way to set stamp to null. Is it possible with this library?

nuclearmistake commented 5 years ago

You could publish a goalid from a regular linux Ros node with a "null" stamp, and watch what is actually sent in rostopic echo... Then emulate that behavior manually in ros.net.

I guarantee transmitting a null stamp on rospy or roscpp does actually send something... Make your ros.net code send that

That should behave like you want, although you're not literally using a null stamp

BascoDLowell commented 5 years ago

Ok, will try that. Thanks for the help!

nuclearmistake commented 5 years ago

You're welcome

BascoDLowell commented 5 years ago

This solves the issue:

Messages.actionlib_msgs.GoalID goal = new Messages.actionlib_msgs.GoalID
            {
                id = "",
                stamp = new Messages.std_msgs.Time
                        ( 
                            new Messages.TimeData
                            {
                                sec = 0,
                                nsec = 0
                            }
                        )

            };

Thanks @nuclearmistake ! You may now close this issue!

nuclearmistake commented 5 years ago

Glad to hear that you got it working.