namgk / node-red-contrib-ros

Node-RED nodes for connecting to ROS bridge
MIT License
15 stars 15 forks source link

ROS2 compatibility #6

Open a-pastore opened 3 years ago

a-pastore commented 3 years ago

Hello,

can anyone confirm the suitability of this module with ROS2 (Foxy)?

aeksiri commented 1 year ago

I use ROS2 Humble, it's work!!

Install nodejs and npm from https://www.digitalocean.com/community/tutorials/how-to-install-node-js-on-ubuntu-22-04

follow the Option 1

Install node-red from https://nodered.org/docs/getting-started/local

$ sudo npm install -g --unsafe-perm node-red

Install ROS2 rosbridge-suite

$ sudo apt install ros-humble-rosbridge-suite

Install node-red-contrib-ros

$ npm install node-red-contrib-ros

Run rosbridge and node-red, respectively

1st Terminal

$ ros2 launch rosbridge_server rosbridge_websocket_launch.xml

2nd Terminal

$ node-red

And below is an example flow [ { "id": "598696206b171029", "type": "tab", "label": "Flow 1", "disabled": false, "info": "", "env": [] }, { "id": "59c16165af4c4926", "type": "ros-subscribe", "z": "598696206b171029", "server": "7e62c774feda5584", "topicname": "/turtle1/pose", "x": 190, "y": 320, "wires": [ [ "6e47ef77ccc43c23" ] ] }, { "id": "6e47ef77ccc43c23", "type": "delay", "z": "598696206b171029", "name": "", "pauseType": "rate", "timeout": "5", "timeoutUnits": "seconds", "rate": "1", "nbRateUnits": "1", "rateUnits": "second", "randomFirst": "1", "randomLast": "5", "randomUnits": "seconds", "drop": false, "allowrate": false, "outputs": 1, "x": 390, "y": 320, "wires": [ [ "80fa6e7f2b7d52b6", "b6d43d685ac9ed20" ] ] }, { "id": "80fa6e7f2b7d52b6", "type": "debug", "z": "598696206b171029", "name": "debug 1", "active": false, "tosidebar": true, "console": false, "tostatus": false, "complete": "false", "statusVal": "", "statusType": "auto", "x": 580, "y": 260, "wires": [] }, { "id": "b6d43d685ac9ed20", "type": "function", "z": "598696206b171029", "name": "filter pose.x", "func": "msg.payload = msg.payload.x\nreturn msg;", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 590, "y": 320, "wires": [ [ "2232058b2ced2faa" ] ] }, { "id": "2232058b2ced2faa", "type": "debug", "z": "598696206b171029", "name": "debug 2", "active": false, "tosidebar": true, "console": false, "tostatus": false, "complete": "false", "statusVal": "", "statusType": "auto", "x": 760, "y": 320, "wires": [] }, { "id": "7e62c774feda5584", "type": "ros-server", "url": "ws://0.0.0.0:9090" } ]

jaimin-lee commented 1 year ago

Thank you for your help.

I did your advice contents. so I did that.

your example has just ros-subscribe.

I want add ros-publish control.

But I can't use ros-publish.

Could you please advice to me how to use ros-publish?

I use ROS2 Humble, it's work!!

Install nodejs and npm from https://www.digitalocean.com/community/tutorials/how-to-install-node-js-on-ubuntu-22-04

follow the Option 1

Install node-red from https://nodered.org/docs/getting-started/local

$ sudo npm install -g --unsafe-perm node-red

Install ROS2 rosbridge-suite

$ sudo apt install ros-humble-rosbridge-suite

Install node-red-contrib-ros

$ npm install node-red-contrib-ros

Run rosbridge and node-red, respectively

1st Terminal

$ ros2 launch rosbridge_server rosbridge_websocket_launch.xml

2nd Terminal

$ node-red

And below is an example flow [ { "id": "598696206b171029", "type": "tab", "label": "Flow 1", "disabled": false, "info": "", "env": [] }, { "id": "59c16165af4c4926", "type": "ros-subscribe", "z": "598696206b171029", "server": "7e62c774feda5584", "topicname": "/turtle1/pose", "x": 190, "y": 320, "wires": [ [ "6e47ef77ccc43c23" ] ] }, { "id": "6e47ef77ccc43c23", "type": "delay", "z": "598696206b171029", "name": "", "pauseType": "rate", "timeout": "5", "timeoutUnits": "seconds", "rate": "1", "nbRateUnits": "1", "rateUnits": "second", "randomFirst": "1", "randomLast": "5", "randomUnits": "seconds", "drop": false, "allowrate": false, "outputs": 1, "x": 390, "y": 320, "wires": [ [ "80fa6e7f2b7d52b6", "b6d43d685ac9ed20" ] ] }, { "id": "80fa6e7f2b7d52b6", "type": "debug", "z": "598696206b171029", "name": "debug 1", "active": false, "tosidebar": true, "console": false, "tostatus": false, "complete": "false", "statusVal": "", "statusType": "auto", "x": 580, "y": 260, "wires": [] }, { "id": "b6d43d685ac9ed20", "type": "function", "z": "598696206b171029", "name": "filter pose.x", "func": "msg.payload = msg.payload.x\nreturn msg;", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 590, "y": 320, "wires": [ [ "2232058b2ced2faa" ] ] }, { "id": "2232058b2ced2faa", "type": "debug", "z": "598696206b171029", "name": "debug 2", "active": false, "tosidebar": true, "console": false, "tostatus": false, "complete": "false", "statusVal": "", "statusType": "auto", "x": 760, "y": 320, "wires": [] }, { "id": "7e62c774feda5584", "type": "ros-server", "url": "ws://0.0.0.0:9090" } ]