Ejemplo n.º 1
0
    public RosPublisher(String nodeName,
                        String rosTopic,
                        float rate    = 20,
                        int queueSize = 10)
    {
        connected = false;
        name      = nodeName;
        RosTopic  = rosTopic;
        RosType   = typeof(T).ToString();
        RosType   = RosType.Substring(4, RosType.Length - 4).Replace(".", "/");
        QueueSize = queueSize;
        SendQueue = new Queue <T>();

#if !UNITY_EDITOR
        RosMessenger.Instance.Advertise(RosTopic, RosType);
        Debug.Log("[" + name + "] Advertised successfully");
#endif
        connected = true;
    }
Ejemplo n.º 2
0
    public RosSubscriber(String nodeName,
                         String rosTopic,
                         int queueSize = 10)
    {
        // During instantiation, it is assumed that the RosManager instance is ready and connected
        name      = nodeName;
        RosTopic  = rosTopic;
        RosType   = typeof(T).ToString();
        RosType   = RosType.Substring(4, RosType.Length - 4).Replace(".", "/");
        QueueSize = queueSize;
        MsgQueue  = new Queue <T>();

#if !UNITY_EDITOR
        RosMessenger.Instance.Subscribe(RosTopic, RosType);
        buffer = RosMessenger.Instance.topicBuffer[RosTopic];

        Debug.Log("[" + name + "] Subscribed successfully, message type: " + RosType);
#endif
    }