@@ -142,7 +142,25 @@ void RTDEClient::setupOutputs(const uint16_t protocol_version)
142142 if (!stream_.write (buffer, size, written))
143143 throw UrException (" Could not send RTDE output recipe to robot." );
144144 if (!pipeline_.getLatestProduct (package, std::chrono::milliseconds (1000 )))
145+ {
145146 throw UrException (" Did not receive confirmation on RTDE output recipe." );
147+ }
148+
149+ rtde_interface::ControlPackageSetupOutputs* tmp_output =
150+ dynamic_cast <rtde_interface::ControlPackageSetupOutputs*>(package.get ());
151+
152+ std::vector<std::string> variable_types = splitVariableTypes (tmp_output->variable_types_ );
153+ assert (output_recipe_.size () == variable_types.size ());
154+ for (std::size_t i = 0 ; i < variable_types.size (); ++i)
155+ {
156+ LOG_DEBUG (" %s confirmed as datatype: %s" , output_recipe_[i].c_str (), variable_types[i].c_str ());
157+ if (variable_types[i] == " NOT_FOUND" )
158+ {
159+ std::string message = " Variable '" + output_recipe_[i] +
160+ " ' not recognized by the robot. Probably your output recipe contains errors" ;
161+ throw UrException (message);
162+ }
163+ }
146164}
147165
148166void RTDEClient::setupInputs ()
@@ -163,6 +181,26 @@ void RTDEClient::setupInputs()
163181 throw UrException (" Could not setup RTDE inputs." );
164182 }
165183
184+ std::vector<std::string> variable_types = splitVariableTypes (tmp_input->variable_types_ );
185+ assert (input_recipe_.size () == variable_types.size ());
186+ for (std::size_t i = 0 ; i < variable_types.size (); ++i)
187+ {
188+ LOG_DEBUG (" %s confirmed as datatype: %s" , input_recipe_[i].c_str (), variable_types[i].c_str ());
189+ if (variable_types[i] == " NOT_FOUND" )
190+ {
191+ std::string message =
192+ " Variable '" + input_recipe_[i] + " ' not recognized by the robot. Probably your input recipe contains errors" ;
193+ throw UrException (message);
194+ }
195+ else if (variable_types[i] == " IN_USE" )
196+ {
197+ std::string message = " Variable '" + input_recipe_[i] +
198+ " ' is currently controlled by another RTDE client. The input recipe can't be used as "
199+ " configured" ;
200+ throw UrException (message);
201+ }
202+ }
203+
166204 writer_.init (tmp_input->input_recipe_id_ );
167205}
168206
@@ -177,7 +215,8 @@ bool RTDEClient::start()
177215 if (!stream_.write (buffer, size, written))
178216 throw UrException (" Sending RTDE start command failed!" );
179217 if (!pipeline_.getLatestProduct (package, std::chrono::milliseconds (1000 )))
180- throw UrException (" Could not get response to RTDE communication start request from robot. This should not happen!" );
218+ throw UrException (" Could not get response to RTDE communication start request from robot. This should not "
219+ " happen!" );
181220 rtde_interface::ControlPackageStart* tmp = dynamic_cast <rtde_interface::ControlPackageStart*>(package.get ());
182221 return tmp->accepted_ ;
183222}
@@ -217,5 +256,17 @@ RTDEWriter& RTDEClient::getWriter()
217256{
218257 return writer_;
219258}
259+
260+ std::vector<std::string> RTDEClient::splitVariableTypes (const std::string& variable_types) const
261+ {
262+ std::vector<std::string> result;
263+ std::stringstream ss (variable_types);
264+ std::string substr = " " ;
265+ while (getline (ss, substr, ' ,' ))
266+ {
267+ result.push_back (substr);
268+ }
269+ return result;
270+ }
220271} // namespace rtde_interface
221272} // namespace ur_driver
0 commit comments