User Manual

- 31 -
ros::NodeHandle n;
......
std::stringstream sclient_name;
ros::ServiceClient client =
n.serviceClient<hps_camera::camera>("client_login");
hps_camera::camera srv;
sclient_name<<"camera_client";
printf("send name = %s\n",sclient_name.str().c_str());
srv.request.client_node_name = sclient_name.str();
camera_pub = n.advertise<hps_camera::distance>("camera", 1000);
......
if
(client.call(srv))
{
while
(ros::ok())
{
printf("rev cmd = %s\n",srv.response.control_cmd.c_str());
if
( strcmp(srv.response.control_cmd.c_str(), "start" ) == 0 )
{
break
;
}
}
}
else
{
break
;
}
......
while
(1)
{
ros::spinOnce();
}
return
0;
}
3 In "2.1.3 Using the SDK in User Projects" in this document, point 5 (2) Asynchronous
Measurement 2 Write the observer callback function, and assign the value to the msg message
structure when the value is measured. And released. code show as below:
/*observer callback function*/
void
*
User_Func
(HPS3D_HandleTypeDef *handle, AsyncIObserver_t *event)
{
hps_camera::distance msg;
if
(event->AsyncEvent == ISubject_Event_DataRecvd)
{
switch
(event->RetPacketType)
{