joint_feedback_message.cpp
Go to the documentation of this file.
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2013, Southwest Research Institute
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  * * 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 copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  * * Neither the name of the Southwest Research Institute, nor the names
16  * of its contributors may be used to endorse or promote products derived
17  * from this software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29  * POSSIBILITY OF SUCH DAMAGE.
30  */
31 #ifndef FLATHEADERS
36 #else
37 #include "joint_feedback_message.h"
38 #include "joint_data.h"
39 #include "byte_array.h"
40 #include "log_wrapper.h"
41 #endif
42 
43 using namespace industrial::shared_types;
44 using namespace industrial::byte_array;
45 using namespace industrial::simple_message;
46 using namespace industrial::joint_feedback;
47 
48 namespace industrial
49 {
50 namespace joint_feedback_message
51 {
52 
53 JointFeedbackMessage::JointFeedbackMessage(void)
54 {
55  this->init();
56 }
57 
58 JointFeedbackMessage::~JointFeedbackMessage(void)
59 {
60 
61 }
62 
63 bool JointFeedbackMessage::init(industrial::simple_message::SimpleMessage & msg)
64 {
65  bool rtn = false;
66  ByteArray data = msg.getData();
67  this->init();
68 
69  if (data.unload(this->data_))
70  {
71  rtn = true;
72  }
73  else
74  {
75  LOG_ERROR("Failed to unload joint feedback message data");
76  }
77  return rtn;
78 }
79 
80 void JointFeedbackMessage::init(industrial::joint_feedback::JointFeedback & data)
81 {
82  this->init();
83  this->data_.copyFrom(data);
84 }
85 
86 void JointFeedbackMessage::init()
87 {
88  this->setMessageType(StandardMsgTypes::JOINT_FEEDBACK);
89  this->data_.init();
90 }
91 
92 bool JointFeedbackMessage::load(ByteArray *buffer)
93 {
94  bool rtn = false;
95  LOG_COMM("Executing joint feedback message load");
96  if (buffer->load(this->data_))
97  {
98  rtn = true;
99  }
100  else
101  {
102  rtn = false;
103  LOG_ERROR("Failed to load joint feedback message data");
104  }
105  return rtn;
106 }
107 
108 bool JointFeedbackMessage::unload(ByteArray *buffer)
109 {
110  bool rtn = false;
111  LOG_COMM("Executing joint feedback message unload");
112 
113  if (buffer->unload(this->data_))
114  {
115  rtn = true;
116  }
117  else
118  {
119  rtn = false;
120  LOG_ERROR("Failed to unload joint feedback message data");
121  }
122  return rtn;
123 }
124 
125 }
126 }
127 
industrial::joint_feedback::JointFeedback
Class encapsulated joint feedback data. This data represents the current state of each robot joint,...
Definition: joint_feedback.h:83
joint_feedback_message.h
industrial::shared_types
Contains platform specific type definitions that guarantee the size of primitive data types.
Definition: shared_types.h:52
industrial
Definition: byte_array.h:45
industrial::byte_array::ByteArray::unload
bool unload(industrial::shared_types::shared_bool &value)
unloads a boolean value from the byte array
Definition: byte_array.cpp:233
industrial::simple_message::SimpleMessage::getData
industrial::byte_array::ByteArray & getData()
Returns a reference to the internal data member.
Definition: simple_message.h:274
byte_array.h
LOG_ERROR
#define LOG_ERROR(format,...)
Definition: log_wrapper.h:134
industrial::simple_message::StandardMsgTypes::JOINT_FEEDBACK
@ JOINT_FEEDBACK
Definition: simple_message.h:74
industrial::simple_message::SimpleMessage
This class defines a simple messaging protocol for communicating with an industrial robot controller.
Definition: simple_message.h:164
industrial::byte_array::ByteArray
The byte array wraps a dynamic array of bytes (i.e. char).
Definition: byte_array.h:80
LOG_COMM
#define LOG_COMM(format,...)
Definition: log_wrapper.h:130
industrial::simple_message
Definition: simple_message.h:49
log_wrapper.h
industrial::byte_array
Definition: byte_array.h:56
industrial::byte_array::ByteArray::load
bool load(industrial::shared_types::shared_bool value)
loads a boolean into the byte array
Definition: byte_array.cpp:142
industrial::joint_feedback
Definition: joint_feedback.h:49
joint_data.h
init
void init(const M_string &remappings)


simple_message
Author(s): Shaun Edwards
autogenerated on Wed Mar 2 2022 00:24:53