robot_configurator.cpp
Go to the documentation of this file.
1 /*********************************************************************
2 * FSRobo-R Package BSDL
3 * ---------
4 * Copyright (C) 2019 FUJISOFT. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without modification,
7 * are permitted provided that the following conditions are met:
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation and/or
12 * other materials provided with the distribution.
13 * 3. Neither the name of the copyright holder nor the names of its contributors
14 * may be used to endorse or promote products derived from this software without
15 * specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
21 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 * 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 
37 #include "ros/ros.h"
39 
40 
41 
54 
55 namespace fsrobo_r_driver
56 {
57 namespace robot_configurator
58 {
59 
61 {
62  connection_ = connection;
63  return true;
64 }
65 
66 bool RobotConfigurator::setPosture(shared_int posture, bool &result)
67 {
68  if (!sendAndReceiveSetPostureMsg(posture, result))
69  {
70  ROS_ERROR("Failed to send SET_POSTURE command");
71  return false;
72  }
73 
74  return true;
75 }
76 
78 {
79  SimpleMessage req, rep;
80  Posture req_body;
81  SetPostureMessage req_msg;
82  SetPostureReplyMessage rep_msg;
83 
84  req_body.init(posture);
85  req_msg.init(req_body);
86  req_msg.toRequest(req);
87 
88  if (!this->connection_->sendAndReceiveMsg(req, rep))
89  {
90  ROS_ERROR("Failed to send SET_POSTURE message");
91  return false;
92  }
93 
94  rep_msg.init(rep);
95  result = (rep.getReplyCode() == ReplyType::SUCCESS);
96 
97  return true;
98 }
99 
100 bool RobotConfigurator::getPosture(shared_int &posture, bool &result)
101 {
102  if (!sendAndReceiveGetPostureMsg(posture, result))
103  {
104  ROS_ERROR("Failed to send GET_POSTURE command");
105  return false;
106  }
107 
108  return true;
109 }
110 
112 {
113  SimpleMessage req, rep;
114  Posture rep_body;
115  GetPostureMessage req_msg;
116  GetPostureReplyMessage rep_msg;
117 
118  rep_body.init();
119  req_msg.init(rep_body);
120  req_msg.toRequest(req);
121 
122  if (!this->connection_->sendAndReceiveMsg(req, rep))
123  {
124  ROS_ERROR("Failed to send GET_POSTURE message");
125  return false;
126  }
127 
128  rep_msg.init(rep);
129  posture = rep_msg.reply_.getPosture();
130  result = (rep.getReplyCode() == ReplyType::SUCCESS);
131 
132  return true;
133 }
134 
136 {
137  if (!sendAndReceiveSetToolOffsetMsg(x, y, z, rz, ry, rx, result))
138  {
139  ROS_ERROR("Failed to send SET_TOOL_OFFSET command");
140  return false;
141  }
142 
143  return true;
144 }
145 
147 {
148  SimpleMessage req, rep;
149  SetToolOffset req_body;
150  SetToolOffsetMessage req_msg;
152 
153  req_body.init(x, y, z, rz, ry, rx);
154  req_msg.init(req_body);
155  req_msg.toRequest(req);
156 
157  if (!this->connection_->sendAndReceiveMsg(req, rep))
158  {
159  ROS_ERROR("Failed to send SET_TOOL_OFFSET message");
160  return false;
161  }
162 
163  rep_msg.init(rep);
164  result = (rep.getReplyCode() == ReplyType::SUCCESS);
165 
166  return true;
167 }
168 
169 }
170 }
bool init(industrial::simple_message::SimpleMessage &msg)
Initializes message from a simple message.
bool getPosture(industrial::shared_types::shared_int &posture, bool &result)
Get posture on the controller.
ReplyTypes::ReplyType ReplyType
Class encapsulated FSRobo-R set posture reply message generation methods (either to or from a industr...
Class encapsulated tool offset data. FSRobo-R specific interface to set tool offset on the controller...
virtual bool toRequest(industrial::simple_message::SimpleMessage &msg)
bool sendAndReceiveSetToolOffsetMsg(industrial::shared_types::shared_real x, industrial::shared_types::shared_real y, industrial::shared_types::shared_real z, industrial::shared_types::shared_real rz, industrial::shared_types::shared_real ry, industrial::shared_types::shared_real rx, bool &result)
industrial::shared_types::shared_int getPosture()
Returns the posture.
Definition: posture.h:102
Class encapsulated posture data. FSRobo-R specific interface to posture on the controller.
Definition: posture.h:58
bool setToolOffset(industrial::shared_types::shared_real x, industrial::shared_types::shared_real y, industrial::shared_types::shared_real z, industrial::shared_types::shared_real rz, industrial::shared_types::shared_real ry, industrial::shared_types::shared_real rx, bool &result)
Set tool offset on the controller.
bool init(industrial::simple_message::SimpleMessage &msg)
Initializes message from a simple message.
bool sendAndReceiveMsg(industrial::simple_message::SimpleMessage &send, industrial::simple_message::SimpleMessage &recv, bool verbose=false)
Class encapsulated FSRobo-R set tool offset message generation methods (either to or from a industria...
Class encapsulated FSRobo-R set io reply message generation methods (either to or from a industrial::...
bool init(industrial::simple_message::SimpleMessage &msg)
Initializes message from a simple message.
bool init(industrial::simple_message::SimpleMessage &msg)
Initializes message from a simple message.
void init()
Initializes a empty set tool offset command.
Class encapsulated FSRobo-R set posture message generation methods (either to or from a industrial::s...
Class encapsulated FSRobo-R get posture message generation methods (either to or from a industrial::s...
void init()
Initializes a empty posture command.
Definition: posture.cpp:52
bool setPosture(industrial::shared_types::shared_int posture, bool &result)
Set posture on the controller.
bool init(industrial::simple_message::SimpleMessage &msg)
Initializes message from a simple message.
bool sendAndReceiveSetPostureMsg(industrial::shared_types::shared_int posture, bool &result)
bool init(industrial::simple_message::SimpleMessage &msg)
Initializes message from a simple message.
Class encapsulated FSRobo-R get posture reply message generation methods (either to or from a industr...
#define ROS_ERROR(...)
bool sendAndReceiveGetPostureMsg(industrial::shared_types::shared_int &posture, bool &result)


fsrobo_r_driver
Author(s): F-ROSROBO
autogenerated on Sun Feb 9 2020 03:58:29