User Manual

- 24 -
Note: If the rospack depends hps_camera is executed, the following error occurs (when the ros*
command is used, an error occurs, it may be that the workspace has failed, it can be re-validated,
or it can be written into the ros environment variable) Go back to the workspace directory and
execute source devel/setup.bash again to make the workspace work, as shown in the following
figure:
2.4.3 Create ROS message msg and service srv
The msg file is a simple text file that describes the fields of messages in ROS and is used to
generate source code for different languages for messages.
The srv file describes a service consisting of two parts, a request and a service.
Tip: A msg file or a srv file is equivalent to a structure, so you can compare the provided api.h.
There are five data types in the depth camera data return package. Each data type is a structure,
that is, When writing msg files, you can nest them.
1
Create ROS message msg
(1) In the created package, create a message msg directory to store the msg file. Enter cd
~/HPS3D_SDK_ROS_Demo/src/hps_camera/ in the terminal, go to the package directory; enter
mkdir msg, create the msg directory; type echo "uint16 distance_average" > msg/distance.msg,
create the distance.msg file, and write the average distance variable. As shown below: