RobotWebTools / roslibjs

The Standard ROS JavaScript Library
https://robotwebtools.github.io/roslibjs
Other
660 stars 372 forks source link

Add ROS 2 action support #645

Closed sea-bass closed 6 months ago

sea-bass commented 8 months ago

Public API Changes This PR adds new ROS 2 functionality for actions, without touching any of the existing ROS 1 APIs.

This, plus the fact that CI currently is not running on any ROS 2 distros, does beg the question on what we should do with ROS 2... but I'll raise a different issue for this.

Description This PR builds on the ROSBridge protocol updates in https://github.com/RobotWebTools/rosbridge_suite/pull/886, to add official action support for ROS 2.

Notably, this doesn't rely on any hidden topics/services or extra logic on the roslibjs side. Instead, rosbridge_suite is directly using the rlcpy.actions module which is way cleaner in my opinion.

The examples have been updated to also work with ROS 2, though I haven't done anything with the unit tests / CI yet. I think the state of testing is such that we'd need a host of separate PRs to address this. including actually running CI on ROS 2.

Testing Instructions

sea-bass commented 7 months ago

I've tested this along with https://github.com/RobotWebTools/rosbridge_suite/pull/886 and https://github.com/DefinitelyTyped/DefinitelyTyped/pull/67407 in our UI and all seems to work in order.

Inclined to merge this soon, as it looks ready to go now!

sea-bass commented 7 months ago
  • The ROS2 example, doesn't contain setting parameters. Is this still possible? In case it is, could we add it to the example?

I think it's still possible though the rosapi_node executable in rosbridge. Not something I've tried before, but let me do that right now.

  • The changes in the rosbridge_server aren't released yet, correct? Therefore we can merge this one, but we shouldn't release it yet. Correct?
  • This is not really a breaking change, but it only works with the ROS2 rosbridge_server correct? So therefore a major version bump might be needed. If that is the case, we should combine multiple breaking changes at once. (Releasing, not this PR)

Correct -- nothing is released yet, so we should wait until it's all merged in together for ROS 2.


BTW for those using TypeScript, like ourselves, I also had to add these changes in support of this PR: https://github.com/DefinitelyTyped/DefinitelyTyped/pull/67407

How does this play with having separate releases/branches between master and ros2?

sea-bass commented 7 months ago

Update: Params did work, and I've added an example into the ros2_simple.html demo.

MatthijsBurgh commented 7 months ago

@sea-bass I think I want to make one final release for v1.X. I will rename the master branch to v1. I will also create a v2 branch, which acts as the release branch for all future v2.x releases.

After which we should rebase this PR on the current develop branch. As the ros2 branch is just behind the develop branch. So we should also merge this PR into the develop branch.

sea-bass commented 7 months ago

@sea-bass I think I want to make one final release for v1.X. I will rename the master branch to v1. I will also create a v2 branch, which acts as the release branch for all future v2.x releases.

After which we should rebase this PR on the current develop branch. As the ros2 branch is just behind the develop branch. So we should also merge this PR into the develop branch.

@MatthijsBurgh Seems like @EzraBrooks got https://github.com/RobotWebTools/roslibjs/pull/649 to pass -- do you want that to possibly be the first PR of this v2, and then I'll rebase this branch on that + make sure it's TypeScript compliant?

EzraBrooks commented 6 months ago

Can we move 8b83120 and f77ef8a to a different branch so we can squash this and not have this commit make seemingly-unrelated changes?

sea-bass commented 6 months ago

Can we move 8b83120 and f77ef8a to a different branch so we can squash this and not have this commit make seemingly-unrelated changes?

Done!

sea-bass commented 6 months ago

@MatthijsBurgh would you like to give this another look before we merge?

All seems to work great for us, except that since we got rid of the build output a few days ago we can't pnpm install directly from this git branch and need to cut an actual release soon.

MatthijsBurgh commented 6 months ago

Before creating a release, I suggest we figure out whether we want to provide compiled files attached to the release, etc. I will create an issue to discuss.

tall1 commented 3 months ago

I'm trying to run the ros2_action_server.html and I'm runnning into this: Uncaught ReferenceError: Buffer is not defined

Any idea how to solve this issue? It has something to do with RosLib.umd.cjs but I'm not sure how to fix this.

sea-bass commented 3 months ago

I'm trying to run the ros2_action_server.html and I'm runnning into this: Uncaught ReferenceError: Buffer is not defined

Any idea how to solve this issue? It has something to do with RosLib.umd.cjs but I'm not sure how to fix this.

I think I ran into this at some point and resolved it with https://github.com/RobotWebTools/roslibjs/pull/692. Are you on a version of roslibjs with that commit?

tall1 commented 3 months ago

Yes I am.

tall1 commented 3 months ago

I tried a few more things in adjusting the package but it fails to run. Is there a working example I can use of this module?

I'm on Humble btw.

sea-bass commented 3 months ago

I think with these questions going forward, it's best to open a new issue instead of jumping into a closed PR's discussion thread. And if you do, it might be helpful to provide more details on what you've tried and what error(s) you may be getting. It's a bit challenging to help otherwise.

Setup should be done as in https://github.com/RobotWebTools/roslibjs?tab=readme-ov-file#usage. Basically just running npm install in this repo root.

Then, there are several examples in this folder: https://github.com/RobotWebTools/roslibjs/tree/develop/examples -- specifically, the ones prefixed with ros2_.

When you open those HTML files in a browser, they display instructions for how to start rosbridge in the background and start up certain ROS executables in the background to communicate with the example.