rsi_state.h
Go to the documentation of this file.
1 /*********************************************************************
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2014 Norwegian University of Science and Technology
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
9  * are met:
10  *
11  * * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * * Redistributions in binary form must reproduce the above
14  * copyright notice, this list of conditions and the following
15  * disclaimer in the documentation and/or other materials provided
16  * with the distribution.
17  * * Neither the name of the Univ of CO, Boulder nor the names of its
18  * contributors may be used to endorse or promote products derived
19  * from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32  * POSSIBILITY OF SUCH DAMAGE.
33  *********************************************************************/
34 
35 /*
36  * Author: Lars Tingelstad <lars.tingelstad@ntnu.no>
37 */
38 
39 #ifndef KUKA_RSI_HW_INTERFACE_RSI_STATE_
40 #define KUKA_RSI_HW_INTERFACE_RSI_STATE_
41 
42 #include <string>
43 #include <tinyxml.h>
44 
45 namespace kuka_rsi_hw_interface
46 {
47 
48 class RSIState
49 {
50 
51 private:
52  std::string xml_doc_;
53 
54 public:
56  positions(6, 0.0),
57  initial_positions(6, 0.0),
58  cart_position(6, 0.0),
59  initial_cart_position(6, 0.0)
60  {
61  xml_doc_.resize(1024);
62  }
63 
64  RSIState(std::string xml_doc);
65  // AIPOS
66  std::vector<double> positions;
67  // ASPos
68  std::vector<double> initial_positions;
69  // RIst
70  std::vector<double> cart_position;
71  // RSol
72  std::vector<double> initial_cart_position;
73  // IPOC
74  unsigned long long ipoc;
75 
76 };
77 
78 RSIState::RSIState(std::string xml_doc) :
79  xml_doc_(xml_doc),
80  positions(6, 0.0),
81  initial_positions(6, 0.0),
82  cart_position(6, 0.0),
83  initial_cart_position(6, 0.0)
84 {
85  // Parse message from robot
86  TiXmlDocument bufferdoc;
87  bufferdoc.Parse(xml_doc_.c_str());
88  // Get the Rob node:
89  TiXmlElement* rob = bufferdoc.FirstChildElement("Rob");
90  // Extract axis specific actual position
91  TiXmlElement* AIPos_el = rob->FirstChildElement("AIPos");
92  AIPos_el->Attribute("A1", &positions[0]);
93  AIPos_el->Attribute("A2", &positions[1]);
94  AIPos_el->Attribute("A3", &positions[2]);
95  AIPos_el->Attribute("A4", &positions[3]);
96  AIPos_el->Attribute("A5", &positions[4]);
97  AIPos_el->Attribute("A6", &positions[5]);
98  // Extract axis specific setpoint position
99  TiXmlElement* ASPos_el = rob->FirstChildElement("ASPos");
100  ASPos_el->Attribute("A1", &initial_positions[0]);
101  ASPos_el->Attribute("A2", &initial_positions[1]);
102  ASPos_el->Attribute("A3", &initial_positions[2]);
103  ASPos_el->Attribute("A4", &initial_positions[3]);
104  ASPos_el->Attribute("A5", &initial_positions[4]);
105  ASPos_el->Attribute("A6", &initial_positions[5]);
106  // Extract cartesian actual position
107  TiXmlElement* RIst_el = rob->FirstChildElement("RIst");
108  RIst_el->Attribute("X", &cart_position[0]);
109  RIst_el->Attribute("Y", &cart_position[1]);
110  RIst_el->Attribute("Z", &cart_position[2]);
111  RIst_el->Attribute("A", &cart_position[3]);
112  RIst_el->Attribute("B", &cart_position[4]);
113  RIst_el->Attribute("C", &cart_position[5]);
114  // Extract cartesian actual position
115  TiXmlElement* RSol_el = rob->FirstChildElement("RSol");
116  RSol_el->Attribute("X", &initial_cart_position[0]);
117  RSol_el->Attribute("Y", &initial_cart_position[1]);
118  RSol_el->Attribute("Z", &initial_cart_position[2]);
119  RSol_el->Attribute("A", &initial_cart_position[3]);
120  RSol_el->Attribute("B", &initial_cart_position[4]);
121  RSol_el->Attribute("C", &initial_cart_position[5]);
122  // Get the IPOC timestamp
123  TiXmlElement* ipoc_el = rob->FirstChildElement("IPOC");
124  ipoc = std::stoull(ipoc_el->FirstChild()->Value());
125 }
126 
127 } // namespace kuka_rsi_hw_interface
128 
129 #endif
std::vector< double > positions
Definition: rsi_state.h:66
std::vector< double > initial_cart_position
Definition: rsi_state.h:72
std::vector< double > cart_position
Definition: rsi_state.h:70
unsigned long long ipoc
Definition: rsi_state.h:74
std::vector< double > initial_positions
Definition: rsi_state.h:68


kuka_rsi_hw_interface
Author(s): Lars Tingelstad
autogenerated on Tue Oct 15 2019 03:33:54