RobotWebTools / rosbridge_suite

Server Implementations of the rosbridge v2 Protocol
https://robotwebtools.github.io
BSD 3-Clause "New" or "Revised" License
919 stars 519 forks source link

roslib.js:3210 Uncaught TypeError: Cannot read properties of null (reading 'idCounter') #853

Closed shahbas001 closed 6 months ago

shahbas001 commented 1 year ago

when i connect joystick and try to publish values continuously showing this error

roslib.js:3210 Uncaught TypeError: Cannot read properties of null (reading 'idCounter') at Topic.advertise (roslib.js:3210:63) at Topic.publish (roslib.js:3255:10) at publishGamepadValues (controller.jsx:122:17) at updateGamepadValues (controller.jsx:70:9)

function updateGamepadValues() {
    const gamepad = navigator.getGamepads()[0];

    const newValues = {
        leftStickX: gamepad.axes[0],
        leftStickY: gamepad.axes[1],
        rightStickX: gamepad.axes[2],
        rightStickY: gamepad.axes[3],
        buttonA: gamepad.buttons[0].value,
        buttonB: gamepad.buttons[1].value,
        buttonX: gamepad.buttons[2].value,
        buttonY: gamepad.buttons[3].value,
        leftTrigger: gamepad.buttons[6].value,
        rightTrigger: gamepad.buttons[7].value,
        isConnected: true,
    };
    setGamepadValues(newValues);
    requestAnimationFrame(updateGamepadValues);
    publishGamepadValues(newValues);// publish the new gamepad values

}

function publishGamepadValues(values) {

    const LX = values.leftStickX;
    const RY = values.rightStickY;

    const cmd_vel = new window.ROSLIB.Topic({
        ros: ros,
        name: Config.CMD_VEL_TOPIC,
        messageType: "geometry_msgs/Twist"
    });

    console.log(LX, "LX")
    const twist = new window.ROSLIB.Message({
        linear: {
            x: LX,
            y: 0.0,
            z: 0.0,
        },
        angular: {
            x: 0.0,
            y: 0.0,
            z: RY,
        },
    });
    cmd_vel.publish(twist);
    console.log(twist, "twist");

}
github-actions[bot] commented 7 months ago

This issue has been marked as stale because there has been no activity in the past 12 months. Please add a comment to keep it open.