How to run mavros with gazebo SITL

I was reading the tutorial from http://dev.px4.io/ros-mavros-offboard.html, what I am not sure is where exactly to put the offb_node.cpp, and how to start it. The tutorial says

Create the offb_node.cpp file in your ros package and paste the following inside it:

Is this refering to the kinetic package? In which file?
And how do I start it?

you need to create a package inside a configured catkin work-space and place the source file in it.
configure you makelist to build a node and then catkin_make. launch the node using rosrun or a launch file (dont forget to source devel/setup.bash after building)

Thanks @edigotlieb! I am still quite confused by the CMakelists file. I attempted to learn it from http://wiki.ros.org/ROS/Tutorials/WritingPublisherSubscriber(c%2B%2B). It says to add some dependencies and libraries. I don’t know what to put for this particular one.

Hi @zhahaoyu, judging by this post Interfacing mavros with gazebo SITL I supose you succeeded running mavros with gazebo SITL. I am trying to follow the same tutorial https://dev.px4.io/ros-mavros-offboard.html as you did but I have some questions.

  1. Should I create my catkin work-space within sitl_gazebo? So far I am using a catkin work-space located in my home directory.
  2. I am trying to modify the CMakelists.txt of the package including the offb_node.cpp, specificly I am including:

add_executable(offb_node src/offb_node.cpp)
target_link_libraries(offb_node ${catkin_LIBRARIES})
add_dependencies(offb_node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})

But I don’t know how should I modify the dependencies.