drone_server.cpp
Go to the documentation of this file.
1 
2 /* BSD 2-Clause License
3 
4 Copyright (c) 2019, Simranjeet Singh
5 All rights reserved.
6 
7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions are met:
9 
10 1. Redistributions of source code must retain the above copyright notice, this
11  list of conditions and the following disclaimer.
12 
13 2. Redistributions in binary form must reproduce the above copyright notice,
14  this list of conditions and the following disclaimer in the documentation
15  and/or other materials provided with the distribution.
16 
17 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
21 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
24 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
27 
28 
29 #include <ros/ros.h>
30 #include <edrone_client/edrone_services.h>
31 
32 bool myFunction(edrone_client::edrone_services::Request &req,
33  edrone_client::edrone_services::Response &res)
34 {
35  ROS_INFO("Ax=%f, Ay=%f, Az=%f", req.accX, req.accY, req.accZ);
36  ROS_INFO("Gx=%f, Gy=%f, Gz=%f", req.gyroX, req.gyroY, req.gyroZ);
37  ROS_INFO("Mx=%f, My=%f, Mz=%f", req.magX, req.magY, req.magZ);
38 
39 
40  ROS_INFO("roll=%i, pitch=%i, yaw=%i", req.roll, req.pitch, req.yaw);
41  ROS_INFO("altitiude=%f", req.alt);
42  ROS_INFO("battery=%f rssi=%i", req.battery,req.rssi);
43 
44  res.rcAUX1=1800;
45 
46  ROS_INFO("sending back response: [%ld]", (long int)res.rcAUX1);
47  return true;
48 }
49 
50 int main(int argc, char **argv)
51 {
52  ros::init(argc, argv, "DroneData");
54 
56  printf("Ready to Provide Drone Service\n");
57  ros::spin();
58 
59  return 0;
60 }
edrone_client::edrone_services service
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
int main(int argc, char **argv)
ServiceServer advertiseService(const std::string &service, bool(T::*srv_func)(MReq &, MRes &), T *obj)
ROSCPP_DECL void spin(Spinner &spinner)
#define ROS_INFO(...)
bool myFunction(edrone_client::edrone_services::Request &req, edrone_client::edrone_services::Response &res)


edrone_server
Author(s): Simranjeet Singh
autogenerated on Sun Dec 1 2019 03:30:53