I am trying run some ros2 command directly inside Qt, but I don’t know how to set up Qt’s environment or how run the setup.bash file inside Qt?
For example, I tried: system(qPrintable(“. ~/ros2_install/ros2-osx/setup.bash”)); in Qt, and get the error as following:
env: python3: No such file or directory
error: unable to find fallback python3 executable
I know there is one way that I can source the setup.bash file in Terminal and run Qt from this Terminal, but is there a method to run the setup.bash file directly inside Qt?
Hi,what do you mean by running inside Qt ? Building an application that uses Qt and ROS2 or opening a ROS2 package inside the Qt Creator IDE ? In the second case I’d say it is easier to open a bash. Then source the ros2_ws and your own workspace. (See also Trouble opening package in qtcreator)
and then start qtcreator in this terminal.
Hi,
What I meant is just like what wjwwood writes: I need to source a shell script via a system call inside Qt.
Your method of sourcing the terminal and then open qt with this terminal works for sure, but do you have any experience to run the “sourcing command” directly in Qt using system call?
If not, then I guess I’ll ask this in a more generic forum like he said.
My question is still. Do you mean qt or qtcreator? Thats a huge difference. In qtcreator (the ide) there is somewhere at the project tab the possibilty to set a custom build / run environment.
Doing a systemcall for sourcing doesn’t make any sense. But running a qt application together with ros2 without sourcing before is also possible.
The script doesn’t do anything else than setting some environment variables.
You could set the variables by hand using: https://stackoverflow.com/questions/899517/set-local-environment-variables-in-c