wrench.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 
32 
33 using namespace industrial::shared_types;
34 
35 namespace fsrobo_r_driver
36 {
37 namespace simple_message
38 {
39 namespace wrench
40 {
41 
42 Wrench::Wrench(void)
43 {
44  this->init();
45 }
46 
47 Wrench::~Wrench(void)
48 {
49 
50 }
51 
52 void Wrench::init()
53 {
54  this->setForce(0, 0);
55  this->setForce(1, 0);
56  this->setForce(2, 0);
57  this->setTorque(0, 0);
58  this->setTorque(1, 0);
59  this->setTorque(2, 0);
60 }
61 
62 void Wrench::copyFrom(Wrench &src)
63 {
64  this->setForce(0, src.getForce(0));
65  this->setForce(1, src.getForce(1));
66  this->setForce(2, src.getForce(2));
67  this->setTorque(0, src.getTorque(0));
68  this->setTorque(1, src.getTorque(1));
69  this->setTorque(2, src.getTorque(2));
70 }
71 
72 bool Wrench::operator==(Wrench &rhs)
73 {
74  return this->force_[0] == rhs.force_[0] && this->force_[1] == rhs.force_[1] && this->force_[2] == rhs.force_[2]
75  && this->torque_[0] == rhs.torque_[0] && this->torque_[1] == rhs.torque_[1] && this->torque_[2] == rhs.torque_[2];
76 }
77 
78 bool Wrench::load(industrial::byte_array::ByteArray *buffer)
79 {
80  bool rtn = false;
81 
82  LOG_COMM("Executing wrench state load");
83 
84  if (buffer->load(this->force_[0]) && buffer->load(this->force_[1]) && buffer->load(this->force_[2])
85  && buffer->load(this->torque_[0]) && buffer->load(this->torque_[1]) && buffer->load(this->torque_[2]))
86  {
87 
88  LOG_COMM("wrench state successfully loaded");
89  rtn = true;
90  }
91  else
92  {
93  LOG_COMM("wrench state not loaded");
94  rtn = false;
95  }
96 
97  return rtn;
98 }
99 
100 bool Wrench::unload(industrial::byte_array::ByteArray *buffer)
101 {
102  bool rtn = false;
103 
104  LOG_COMM("Executing wrench state unload");
105  if (buffer->unload(this->torque_[2]) && buffer->unload(this->torque_[1]) && buffer->unload(this->torque_[0])
106  && buffer->unload(this->force_[2]) && buffer->unload(this->force_[1]) && buffer->unload(this->force_[0]))
107  {
108  rtn = true;
109  LOG_COMM("wrench state successfully unloaded");
110  }
111 
112  else
113  {
114  LOG_ERROR("Failed to unload wrench state");
115  rtn = false;
116  }
117 
118  return rtn;
119 }
120 
121 } // namespace wrench
122 } // namespace simple_message
123 } // namespace fsrobo_r_driver
industrial::shared_types::shared_real force_[3]
Force.
Definition: wrench.h:146
Class encapsulated robot status data. The robot status data is meant to mirror the industrial_msgs/Ro...
Definition: wrench.h:70
#define LOG_COMM(format,...)
bool load(industrial::shared_types::shared_bool value)
#define LOG_ERROR(format,...)
industrial::shared_types::shared_real getForce(int idx)
Initializes a full robot status message.
Definition: wrench.h:100
industrial::shared_types::shared_real torque_[3]
Torque.
Definition: wrench.h:151
bool unload(industrial::shared_types::shared_bool &value)
industrial::shared_types::shared_real getTorque(int idx)
Definition: wrench.h:105


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