rq_test_sensor.cpp
Go to the documentation of this file.
1 /* Software License Agreement (BSD License)
2 *
3 * Copyright (c) 2014, Robotiq, Inc.
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above
13 * copyright notice, this list of conditions and the following
14 * disclaimer in the documentation and/or other materials provided
15 * with the distribution.
16 * * Neither the name of Robotiq, Inc. nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 * POSSIBILITY OF SUCH DAMAGE.
32 *
33 * Copyright (c) 2014, Robotiq, Inc
34 */
35 
43 #include "ros/ros.h"
44 #include "std_msgs/String.h"
45 #include "robotiq_ft_sensor/ft_sensor.h"
46 #include "robotiq_ft_sensor/sensor_accessor.h"
47 
48 #include <sstream>
49 
50 /*void receiveCallback(const std_msgs::String::ConstPtr& msg)
51 {
52  ROS_INFO("I heard: [%s]", msg->data.c_str());
53 }*/
54 
55 void reCallback(const robotiq_ft_sensor::ft_sensor& msg)
56 {
57  ROS_INFO("I heard: FX[%f] FY[%f] FZ[%f] MX[%f] MY[%f] MZ[%f]", msg.Fx,msg.Fy,msg.Fz,msg.Mx,msg.My,msg.Mz);
58 }
59 
63 int main(int argc, char **argv)
64 {
65 
66  ros::init(argc, argv, "rq_test_sensor");
67 
68 
70 
71  ros::ServiceClient client = n.serviceClient<robotiq_ft_sensor::sensor_accessor>("robotiq_ft_sensor_acc");
72  ros::Subscriber sub1 = n.subscribe("robotiq_ft_sensor",100,reCallback);
73 
74  robotiq_ft_sensor::sensor_accessor srv;
75 
76  int count = 0;
77  while (ros::ok())
78  {
79  if(count == 10000000){
80 
82  // srv.request.command = "SET ZRO";
83 
85  srv.request.command_id = srv.request.COMMAND_SET_ZERO;
86 
87  if(client.call(srv)){
88  ROS_INFO("ret: %s", srv.response.res.c_str());
89  }
90  count = 0;
91  }
92 
93  ros::spinOnce();
94 
95  ++count;
96  }
97 
98 
99  return 0;
100 }
ServiceClient serviceClient(const std::string &service_name, bool persistent=false, const M_string &header_values=M_string())
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
bool call(MReq &req, MRes &res)
int main(int argc, char **argv)
#define ROS_INFO(...)
ROSCPP_DECL bool ok()
ROSCPP_DECL void spinOnce()
void reCallback(const robotiq_ft_sensor::ft_sensor &msg)


robotiq_ft_sensor
Author(s): Jonathan Savoie
autogenerated on Tue Jun 1 2021 02:30:04