How to make rosparams set in GUI available when run as Docker container?

asked 2021-01-30 11:10:44 -0500

Py gravatar image

updated 2021-02-01 02:29:23 -0500

I have a GUI running in a ROS package, which does various things including setting some important custom parameters to do with my robot use case.

When I run this GUI using roslaunch it works fine and all user set parameters are set correctly. However, I have also containerised this GUI using Docker. This all works well in that all topics can be subscribed and published to and it visually looks correct. However, when run as a Docker container, the GUI does not set the custom parameters even though the main.js code (and all other code) is the same.

This logically suggests that there is a difference between the host computer and container environment but what could this be to stop the following main.js snippet from working?

new Vue({
    el: '#vueApp',

    data:{
        ros: null,
        connected: false,
        pubInterval: null,
        paramA: 0.0,
        paramB: 0.0,
        paramC: 0.0
    },

    methods:{

        // Connection
        connect: function () {

            // ROSBridge Connection Object
            this.ros = new ROSLIB.Ros({
                   url: 'ws://' + window.location.hostname + ':9090'
            })

            // ROSBridge Connection Object Callbacks
            this.ros.on('connection', () => {
                this.connected = true
                console.log('Connection to ROSBridge established')
                this.pubInterval = setInterval(this.publish, 100)
            })
            this.ros.on('error', (error) => {
                console.log('Something went wrong when trying to connect')
                console.log(error)
            })
            this.ros.on('close', () => {
                this.connected = false
                console.log('Connection to ROSBridge was closed')
                clearInterval(this.pubInterval)
            })

            // Setup
            this.setCustomParams();

        },

        // Set Params

        setParamA: function(a) {
            let paramA = new ROSLIB.Param({
                ros : this.ros,
                name : ‘param_a’
            });
            paramA.set(a);
        },

        setParamB: function(b) {
            let paramB = new ROSLIB.Param({
                ros : this.ros,
                name : ‘param_b’
            });
            paramB.set(b);
        },

        setParamC: function(c) {
            let paramC = new ROSLIB.Param({
                ros : this.ros,
                name : ‘param_c’
            });
            paramA.set(c);
        },

        setCustomParams: function(){
            setParamA(String(this.paramA))
            setParamA(String(this.paramA))
            setParamA(String(this.paramA))
        },

    }
})
edit retag flag offensive close merge delete