Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add HTTP client #55

Open
wants to merge 5 commits into
base: noetic-devel
Choose a base branch
from

Conversation

yassiezar
Copy link
Contributor

@yassiezar yassiezar commented May 11, 2022

I've made a client base that to make asynchronous HTTP requests. It follows the same principle as the ROS subscriber client, where a callback function is made available to client behaviours and is assigned to receive the HTTP response for processing. Only HTTP GET and POST requests are included right now, but its trivial to add others.

Note that the client base is dependent on the CPR library (C++ Requests, a high-level wrapper around libcurl). I've added an example which showcases the functionality and how the dependency can be resolved (sm_atomic_http). The CPR devs enabled CMake's FetchContent API so its quite portable and easy to integrate.

I understand this opens up the question of which dependencies to include in the SMACC library and how they should be handled. Using raw CURL will be more portable, but I found it quite hard to work with. CPR presented me a good balance of usability and portability. However, I'm open to suggestions for alternative approaches.

┆Issue is synchronized with this Jira Task by Unito
┆Link To Issue: https://robosoft-ai.atlassian.net/browse/SMACC1-5

@pabloinigoblasco
Copy link
Collaborator

I have to analyze this in detail but I think it would be nice to add this functionality.

@pabloinigoblasco
Copy link
Collaborator

This PR cannot be accepted in the state it is right now, one main reason (among others):

  • CPR is not and should not be a dependency of the "smacc" core package. We only should depend in ros standard packages and c++ std pkgs or boost.

I guess we could integrate this concept if it was part of one of the client_packages.

@yassiezar
Copy link
Contributor Author

@pabloinigoblasco That's a fair point and its bothered me as well tbh.

I've been thinking of rewriting this client using the Boost.Beast module instead, which should be available on your repos if you can install ROS Noetic. The reason I didn't use it from the start is that we're using Ubuntu 18.04, which is stuck on Boost v1.65 and I think the Beast module was only added the Boost libraries in v1.68 and is available on Ubuntu 20.04, and will therefore only be available for Noetic. We were working on Melodic and are migrating to Noetic now, hence me only recently coming across Beast.

Would this be a better way forward? I do think a web client would be useful in SMACC to allow communication with remote machines through standard web requests or sockets, I guess the question is just how that should be implemented

@pabloinigoblasco
Copy link
Collaborator

using Boost.Beast sounds good.
It is available in Ubuntu 20.04 and also in Ubuntu 22.04.

Besides that refactoring to Boot.Beast
I still would introduce the following changes:

  • Using a new "client library package" instead of using the core "smacc package"
  • I would move the code to a cpp file always it is possible (excluding template methods)

From my side, we can go forward with this work.

@brettpac
Copy link
Collaborator

I agree that this would be a valuable addition to the client library, with numerous use cases. I also like the idea of developing it in noetic. We plan on making noetic the master branch quite soon (currently melodic).

@yassiezar
Copy link
Contributor Author

@pabloinigoblasco Fair points. I'll start porting it over as soon as I have some spare time and we've fully completed our migration to Noetic

@yassiezar yassiezar changed the base branch from melodic-devel to noetic-devel February 23, 2023 16:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants