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

How to create a ros2 node written in c++ to co-simulate with webots?? #626

Closed
SenHe524 opened this issue Feb 14, 2023 · 9 comments
Closed
Assignees

Comments

@SenHe524
Copy link

I am trying to create a ros2 node written in c++ to co-emulate with webots. Although I have checked a lot of materials, I still have no success. I wonder if the official can write relevant tutorials?

@ygoumaz
Copy link
Contributor

ygoumaz commented Feb 14, 2023

You can create your own package for your simulations and own plugins (in C++ and Python) to extend the interface between the package and Webots. There are tutorials located in the wiki to help you:

I am not sure to understand what your exact needs are, but in case you are looking for a more simpler node that processes data, publishes and subscribes to existing topics, you can take a look at the following tutorial on the official ROS 2 documentation: https://docs.ros.org/en/foxy/Tutorials/Beginner-Client-Libraries/Writing-A-Simple-Cpp-Publisher-And-Subscriber.html.

@SenHe524
Copy link
Author

You can create your own package for your simulations and own plugins (in C++ and Python) to extend the interface between the package and Webots. There are tutorials located in the wiki to help you:

I am not sure to understand what your exact needs are, but in case you are looking for a more simpler node that processes data, publishes and subscribes to existing topics, you can take a look at the following tutorial on the official ROS 2 documentation: https://docs.ros.org/en/foxy/Tutorials/Beginner-Client-Libraries/Writing-A-Simple-Cpp-Publisher-And-Subscriber.html.

First, thank you for your reply. I have read both of the two links you provided. The first link uses python language, and the webots_ros2 function package used in the second link seems to be out of date, or I don't understand the meaning of the second function package. May I ask if there are more in-depth examples? Thanks!

@ygoumaz
Copy link
Contributor

ygoumaz commented Feb 14, 2023

In my knowledge, there is no other example based on C++.

Concerning the tutorial on the C++ plugin, what exactly do you mean by "out of date"? Is something not working anymore? Could you give a pointer to the part that is deprecated, so I can update it?

@SenHe524
Copy link
Author

In my knowledge, there is no other example based on C++.

Concerning the tutorial on the C++ plugin, what exactly do you mean by "out of date"? Is something not working anymore? Could you give a pointer to the part that is deprecated, so I can update it?

image
I tried the second linked tutorial and it reported the error shown in the image

@ygoumaz
Copy link
Contributor

ygoumaz commented Feb 14, 2023

You are right, the tutorial was broken when we switched the controller API from C++ to C in webots_ros2_driver (#508).

I will fix it and let you know once it is done.

@SenHe524
Copy link
Author

You are right, the tutorial was broken when we switched the controller API from C++ to C in webots_ros2_driver (#508).

I will fix it and let you know once it is done.

Ok, thank you very much. Since I am in a hurry to implement the function shown in the problem, would you mind telling me an approximate repair time, or could you give a routine under the current code framework?

@ygoumaz
Copy link
Contributor

ygoumaz commented Feb 14, 2023

This is it, the tutorial is now up-to-date and fixed. I also added additional information to make it clearer. Don't hesitate if you have any additional suggestions. Since #508, it is not possible anymore to use the C++ API from plugins. Exclusively the C API should now be used.

@SenHe524
Copy link
Author

This is it, the tutorial is now up-to-date and fixed. I also added additional information to make it clearer. Don't hesitate if you have any additional suggestions. Since #508, it is not possible anymore to use the C++ API from plugins. Exclusively the C API should now be used.

Oh, thank you very much. I will follow the tutorial and try to write my own code. If there is any problem, I hope to wait for your help. Thank you again.

@omichel
Copy link
Member

omichel commented Feb 15, 2023

I assume we can now close this issue. Feel free to re-open it if needed.

@omichel omichel closed this as completed Feb 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants