コード例 #1
0
    public bool Connect()
    {
        if (!this.rosClient.SetupSocket())
        {
            Logger.Log("Failed to set up socket");
            return(false);
        }
        string eventPubMessage = RosbridgeUtilities.GetROSJsonAdvertiseMsg(
            Constants.STORYBOOK_EVENT_TOPIC, Constants.STORYBOOK_EVENT_MESSAGE_TYPE);
        string pageInfoPubMessage = RosbridgeUtilities.GetROSJsonAdvertiseMsg(
            Constants.STORYBOOK_PAGE_INFO_TOPIC, Constants.STORYBOOK_PAGE_INFO_MESSAGE_TYPE);
        string statePubMessage = RosbridgeUtilities.GetROSJsonAdvertiseMsg(
            Constants.STORYBOOK_STATE_TOPIC, Constants.STORYBOOK_STATE_MESSAGE_TYPE);
        string subMessage = RosbridgeUtilities.GetROSJsonSubscribeMsg(
            Constants.STORYBOOK_COMMAND_TOPIC, Constants.STORYBOOK_COMMAND_MESSAGE_TYPE);

        // Send all advertisements to publish and subscribe to appropriate channels.
        this.connected = this.rosClient.SendMessage(eventPubMessage) &&
                         this.rosClient.SendMessage(pageInfoPubMessage) &&
                         this.rosClient.SendMessage(statePubMessage) &&
                         this.rosClient.SendMessage(subMessage);

        // If connection successful, begin sending state messages.
        if (this.connected)
        {
            Logger.Log("Starting to send state messages");
            this.publishStateTimer.Elapsed += this.sendStorybookState;
            this.publishStateTimer.Start();
        }

        return(this.connected);
    }
コード例 #2
0
    private void setupPubSub()
    {
        Logger.Log("-- Setup Pub/Sub for Ros Manager --");
        string eventPubMessage = RosbridgeUtilities.GetROSJsonAdvertiseMsg(
            Constants.STORYBOOK_EVENT_TOPIC, Constants.STORYBOOK_EVENT_MESSAGE_TYPE);
        string pageInfoPubMessage = RosbridgeUtilities.GetROSJsonAdvertiseMsg(
            Constants.STORYBOOK_PAGE_INFO_TOPIC, Constants.STORYBOOK_PAGE_INFO_MESSAGE_TYPE);
        string statePubMessage = RosbridgeUtilities.GetROSJsonAdvertiseMsg(
            Constants.STORYBOOK_STATE_TOPIC, Constants.STORYBOOK_STATE_MESSAGE_TYPE);
        string subMessage = RosbridgeUtilities.GetROSJsonSubscribeMsg(
            Constants.STORYBOOK_COMMAND_TOPIC, Constants.STORYBOOK_COMMAND_MESSAGE_TYPE);

        // Send all advertisements to publish and subscribe to appropriate channels.
        this.connected = this.rosClient.SendMessage(eventPubMessage) &&
                         this.rosClient.SendMessage(pageInfoPubMessage) &&
                         this.rosClient.SendMessage(statePubMessage) &&
                         this.rosClient.SendMessage(subMessage);
    }