I dont know what I have to do to compile this program with ROS. I tried to create a ROS package with catkin_init, paste the example in the src directory and modify the CMakeList.txt adding the dependys as follow (using the ROS tutorials):
-Create the workspace for catkin:
$ mkdir -p ~/catkin_ws/src
$ cd ~/catkin_ws/src
$ cd ~/catkin_ws/
$ catkin_make
$ source devel/setup.bash
-Creating a catkin package:
$ cd ~/catkin_ws/src
catkin_create_pkg drone_control std_msgs rospy roscpp
$ cd ~/catkin_ws
$ catkin_make
$ . ~/catkin_ws/devel/setup.bash
-Writing the publisher node:
In the source directory i create a cpp archive: offb_node.cpp and I paste the code into it.
Add the following lines to the CMakeLists.txt:
Your structure of the catkin workspace has to be different. You are building your packages, for example a package for your offb_node.cpp, into your src folder of your workspace. In this packages you need again a src folder where you will have your offb_node.cpp. Also in this package there have to be a package.xml and a CMakeLists.txt. I recommend you to do the beginner tutorial for ROS about packages:
I would also appreaciate a walkthrough, in linux 16.04. The ROS tutorial page does not really help.
On one hand on page https://dev.px4.io/en/ros/mavros_installation.html
“catkin build” is used, whereas in some of the examples they mention “catkin_make”, which does not work.
“catkin_make_isolated” works, but then from https://dev.px4.io/en/simulation/ros_interface.html
the command
roslaunch mavros px4.launch fcu_url:=“udp://:14540@192.168.1.36:14557”
does not work.
It would be really nice to have a minimal working example.
Hi @Jaeyoung-Lim,
Thanks for the prompt response. I had forgotten to update my progress. My problem was that I was trying to make the offboard example work from this page MAVROS Offboard Example · PX4 Developer Guide . However I found the following at first very confusing:
“Create the offb_node.cpp file in your ROS package (by also adding it to your CMakeList.txt so it is compiled), and paste the following inside it”
So I started to create a ROS package etc, and then I started to ruin into weird build issues. What I do now is that I added “offb_node.cpp” to "/home//catkin_ws/src/mavros/mavros/src/ " and then
to CMakelists.txt in "/home//catkin_ws/src/mavros/mavros/ ". Finally I do “catkin build”. And then I am able to start things by first launching PX4 + simulator, then in a separate console
And now everything works fine (although little Mavros learning material, but that is another issue… )
If I am doing something wrong, please let me know!