Hey. We have got the REST API working and displaying/updating information. We would like to integrate parts of the data to a web-application we are building, but trying to send a GET request only results in:
“Access to fetch at ‘http://192.168.2.2:4777/mavlink’ from origin ‘http://localhost:4200’ has been blocked by CORS policy: Response to preflight request doesn’t pass access control check: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.”
Seems like this is something that must be allowed server-side.
linkhttps://developer.mozilla.org/en-US/docs/Web/HTTP/CORS
Is this something you are planning to allow? Can’t see any security issues as the web-application we are building must run on the laptop driving the ROV to work anyway.
It is the mavlink2rest executable that hosts the web-server for the api. How can I go about configuring this for a local test here?
I have update mavlink2rest to allow cors.
It’s necessary to replace mavlink2rest to test it:
1- Access the ROV terminal, check our documentation for more information.
2- Run this command: screen -X -S mavlink2rest quit | sudo pkill -9 -f mavlink2rest | wget https://github.com/patrickelectric/mavlink2rest/releases/download/0.7.2/mavlink2rest-armv7-unknown-linux-musleabihf -O ~/companion/tools/mavlink2rest | chmod +x ~/companion/tools/mavlink2rest
These commands will update mavlink2rest to the last version 0.7.2, that has CORS enabled.
After finished, remember to restart companion via the web interface.
Follow-up question: Using mavlink-inspector i can see SERVO_OUTPUT_RAW.servo9_raw. This value (and the higher ones) are missing from the REST-api. Anything I can do to remedy this?
We are interested in reading the camera tilt angle.
You should be able to see the lights and all the servo outputs, I just did a quick test here and it’s working: chan9_raw and and chan10_raw are light1 and light2 with max bright.
For the camera position appears in SERVO_OUTPUT_RAW, but there is a bug in mavlink2rest where only the first 8 channels appears, you can check the status of the issue here:
It’s also possible to fetch position information from MOUNT_STATUS, but there is a problem related to the library used:
Can you try this binary to fix the SERVO_OUTPUT_RAW message (and others) ?
The command: $(screen -X -S mavlink2rest quit | sudo pkill -9 -f mavlink2rest) || wget https://github.com/patrickelectric/mavlink2rest/releases/download/continuous/mavlink2rest-armv7-unknown-linux-musleabihf -O ~/companion/tools/mavlink2rest && chmod +x ~/companion/tools/mavlink2rest
Remember to restart the ROV.