Modifying the package files and compiling the package

To make our package understand action definitions and aid in their usage, we need to modify our package.xml and CMakeLists.txt files. In the package.xml file, ensure the following lines of code are available to call the action package. If not, please add them:

<build_depend>actionlib_msgs</build_depend>
<exec_depend>actionlib_msgs</exec_depend>

In the CMakeLists.txt file, add the action files to the add_action_files() call:

add_action_files(
DIRECTORY action
FILES battery_sim.action
)
They may be commented. You can either uncomment and add them or simply copy and paste these lines into your CMakeLists.txt file.

Indicate the dependencies in the generate_messages() call:

generate_messages(
DEPENDENCIES
actionlib_msgs
std_msgs
)

Indicate the dependencies in the catkin_package() call:

catkin_package(
CATKIN_DEPENDS
actionlib_msgs
)

Now that the package has been configured, let's compile the workspace:

$ cd ~/chapter_4_ws
$ catkin_make

You should see the following list of files:

Compilation of action messages and the list of action files

We will use these files in our code as a message structure. Now, let's define the server and client.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.138.175.180