RobotWebTools / rosbridge_suite

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

Service containing bounded array message #899

Open lester-turing opened 6 months ago

lester-turing commented 6 months ago

I use roslibjs to call ros2 services through rosbridge_server on the target software, most of the functions being fine but only the one, containing bounded array, works unexpectedly. I have researched for issue list on roslibjs and rosbridge_suite github but there is no topic discussed about this. If anyone can give me a feedback, it will be very helpful, thanks.

Steps To Reproduce

the javascript part

initializeLocalization = () => {
        const { ros } = this.state;
        const datas = {
            pose: [
                {
                    header: {
                        stamp: {
                            nanosec: 0,
                            sec: 0,
                        },
                        frame_id: "map",
                    },
                    pose: {
                        pose: {
                            position: {
                                y: 73768.390625,
                                x: 3754.39208984375,
                                z: 0.0,
                            },
                            orientation: {
                                y: 0.0,
                                x: 0.0,
                                z: -0.5479397800561485,
                                w: 0.8365177807028489,
                            },
                        },
                        covariance: [
                            0.25, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.25, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
                            0.0, 0.06853891909122467,
                        ],
                    },
                },
            ],
        };
        const request = new ROSLIB.ServiceRequest(datas);

        const service = new ROSLIB.Service({
            ros: ros,
            name: "/api/localization/initialize",
            serviceType: "autoware_adapi_v1_msgs/srv/InitializeLocalization",
        });

        service.callService(request, (result) => {
            console.log("initialize Result: " + result);
        });
    };

The type definition is as blew

geometry_msgs/PoseWithCovarianceStamped[<=1] pose
---
uint16 ERROR_UNSAFE = 1
uint16 ERROR_GNSS_SUPPORT = 2
uint16 ERROR_GNSS = 3
uint16 ERROR_ESTIMATION = 4
autoware_adapi_v1_msgs/ResponseStatus status

ad-api/list/api/localization/initialize/ ad-api/types/autoware_adapi_v1_msgs/srv/InitializeLocalization/

Expected Behavior Success to call the ros2 service and get the response.

Actual Behavior Got the wrong type included because the wrong type parsing, I guess. The right type is PoseWithCovarianceStamped, but server uses "PoseWithCovarianceStamped, 1" while running the code.

[rosbridge_websocket-1] [ERROR] [1703146503.535621124] [rosbridge_websocket]: [Client 41bcd064-4da8-40ca-8cf5-dde4dfe46cf8] [id: call_service:/api/localization/initialize:67] call_service InvalidClassException: Unable to import msg class PoseWithCovarianceStamped, 1 from package geometry_msgs. Caused by module 'geometry_msgs.msg' has no attribute 'PoseWithCovarianceStamped, 1'
teyssieuman commented 1 month ago

I'm also impactec by this problem.

My service is :

---
string<=255[<=100]