mirror of
https://gitlab.com/obbart/universal_robots_ros_driver.git
synced 2026-04-12 11:00:47 +02:00
moved driver to subfolder
This commit is contained in:
48
ur_rtde_driver/src/rtde/control_package_pause.cpp
Normal file
48
ur_rtde_driver/src/rtde/control_package_pause.cpp
Normal file
@@ -0,0 +1,48 @@
|
||||
// this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*-
|
||||
|
||||
// -- BEGIN LICENSE BLOCK ----------------------------------------------
|
||||
// Copyright 2019 FZI Forschungszentrum Informatik
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// -- END LICENSE BLOCK ------------------------------------------------
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
/*!\file
|
||||
*
|
||||
* \author Tristan Schnell schnell@fzi.de
|
||||
* \date 2019-04-09
|
||||
*
|
||||
*/
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
#include "ur_rtde_driver/rtde/control_package_pause.h"
|
||||
|
||||
namespace ur_driver
|
||||
{
|
||||
namespace rtde_interface
|
||||
{
|
||||
bool ControlPackagePause::parseWith(comm::BinParser& bp)
|
||||
{
|
||||
bp.parse(accepted_);
|
||||
|
||||
return true;
|
||||
}
|
||||
std::string ControlPackagePause::toString() const
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << "accepted: " << static_cast<int>(accepted_);
|
||||
|
||||
return ss.str();
|
||||
}
|
||||
} // namespace rtde_interface
|
||||
} // namespace ur_driver
|
||||
50
ur_rtde_driver/src/rtde/control_package_setup_inputs.cpp
Normal file
50
ur_rtde_driver/src/rtde/control_package_setup_inputs.cpp
Normal file
@@ -0,0 +1,50 @@
|
||||
// this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*-
|
||||
|
||||
// -- BEGIN LICENSE BLOCK ----------------------------------------------
|
||||
// Copyright 2019 FZI Forschungszentrum Informatik
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// -- END LICENSE BLOCK ------------------------------------------------
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
/*!\file
|
||||
*
|
||||
* \author Tristan Schnell schnell@fzi.de
|
||||
* \date 2019-04-09
|
||||
*
|
||||
*/
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
#include "ur_rtde_driver/rtde/control_package_setup_inputs.h"
|
||||
|
||||
namespace ur_driver
|
||||
{
|
||||
namespace rtde_interface
|
||||
{
|
||||
bool ControlPackageSetupInputs::parseWith(comm::BinParser& bp)
|
||||
{
|
||||
bp.parse(input_recipe_id_);
|
||||
bp.parseRemainder(variable_types_);
|
||||
|
||||
return true;
|
||||
}
|
||||
std::string ControlPackageSetupInputs::toString() const
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << "input recipe id: " << static_cast<int>(input_recipe_id_) << std::endl;
|
||||
ss << "variable types: " << variable_types_;
|
||||
|
||||
return ss.str();
|
||||
}
|
||||
} // namespace rtde_interface
|
||||
} // namespace ur_driver
|
||||
92
ur_rtde_driver/src/rtde/control_package_setup_outputs.cpp
Normal file
92
ur_rtde_driver/src/rtde/control_package_setup_outputs.cpp
Normal file
@@ -0,0 +1,92 @@
|
||||
// this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*-
|
||||
|
||||
// -- BEGIN LICENSE BLOCK ----------------------------------------------
|
||||
// Copyright 2019 FZI Forschungszentrum Informatik
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// -- END LICENSE BLOCK ------------------------------------------------
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
/*!\file
|
||||
*
|
||||
* \author Tristan Schnell schnell@fzi.de
|
||||
* \date 2019-04-09
|
||||
*
|
||||
*/
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
#include "ur_rtde_driver/rtde/control_package_setup_outputs.h"
|
||||
|
||||
namespace ur_driver
|
||||
{
|
||||
namespace rtde_interface
|
||||
{
|
||||
bool ControlPackageSetupOutputs::parseWith(comm::BinParser& bp)
|
||||
{
|
||||
bp.parse(output_recipe_id_);
|
||||
bp.parseRemainder(variable_types_);
|
||||
|
||||
return true;
|
||||
}
|
||||
std::string ControlPackageSetupOutputs::toString() const
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << "output recipe id: " << static_cast<int>(output_recipe_id_) << std::endl;
|
||||
ss << "variable types: " << variable_types_;
|
||||
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
size_t ControlPackageSetupOutputsRequest::generateSerializedRequest(uint8_t* buffer, double output_frequency,
|
||||
std::vector<std::string> variable_names)
|
||||
{
|
||||
if (variable_names.size() == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
std::string variables;
|
||||
for (const auto& piece : variable_names)
|
||||
variables += (piece + ",");
|
||||
variables.pop_back();
|
||||
uint16_t payload_size = sizeof(double) + variables.size();
|
||||
|
||||
size_t size = 0;
|
||||
size += PackageHeader::serializeHeader(buffer, PACKAGE_TYPE, payload_size);
|
||||
size += comm::PackageSerializer::serialize(buffer + size, output_frequency);
|
||||
size += comm::PackageSerializer::serialize(buffer + size, variables);
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
size_t ControlPackageSetupOutputsRequest::generateSerializedRequest(uint8_t* buffer,
|
||||
std::vector<std::string> variable_names)
|
||||
{
|
||||
if (variable_names.size() == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
std::string variables;
|
||||
for (const auto& piece : variable_names)
|
||||
variables += (piece + ",");
|
||||
variables.pop_back();
|
||||
uint16_t payload_size = sizeof(double) + variables.size();
|
||||
|
||||
size_t size = 0;
|
||||
size += PackageHeader::serializeHeader(buffer, PACKAGE_TYPE, payload_size);
|
||||
size += comm::PackageSerializer::serialize(buffer + size, variables);
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
} // namespace rtde_interface
|
||||
} // namespace ur_driver
|
||||
53
ur_rtde_driver/src/rtde/control_package_start.cpp
Normal file
53
ur_rtde_driver/src/rtde/control_package_start.cpp
Normal file
@@ -0,0 +1,53 @@
|
||||
// this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*-
|
||||
|
||||
// -- BEGIN LICENSE BLOCK ----------------------------------------------
|
||||
// Copyright 2019 FZI Forschungszentrum Informatik
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// -- END LICENSE BLOCK ------------------------------------------------
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
/*!\file
|
||||
*
|
||||
* \author Tristan Schnell schnell@fzi.de
|
||||
* \date 2019-04-09
|
||||
*
|
||||
*/
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
#include "ur_rtde_driver/rtde/control_package_start.h"
|
||||
|
||||
namespace ur_driver
|
||||
{
|
||||
namespace rtde_interface
|
||||
{
|
||||
bool ControlPackageStart::parseWith(comm::BinParser& bp)
|
||||
{
|
||||
bp.parse(accepted_);
|
||||
|
||||
return true;
|
||||
}
|
||||
std::string ControlPackageStart::toString() const
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << "accepted: " << static_cast<int>(accepted_);
|
||||
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
size_t ControlPackageStartRequest::generateSerializedRequest(uint8_t* buffer)
|
||||
{
|
||||
return PackageHeader::serializeHeader(buffer, PACKAGE_TYPE, PAYLOAD_SIZE);
|
||||
}
|
||||
} // namespace rtde_interface
|
||||
} // namespace ur_driver
|
||||
222
ur_rtde_driver/src/rtde/data_package.cpp
Normal file
222
ur_rtde_driver/src/rtde/data_package.cpp
Normal file
@@ -0,0 +1,222 @@
|
||||
// this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*-
|
||||
|
||||
// -- BEGIN LICENSE BLOCK ----------------------------------------------
|
||||
// Copyright 2019 FZI Forschungszentrum Informatik
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// -- END LICENSE BLOCK ------------------------------------------------
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
/*!\file
|
||||
*
|
||||
* \author Felix Mauch mauch@fzi.de
|
||||
* \date 2019-04-10
|
||||
*
|
||||
*/
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
#include "ur_rtde_driver/rtde/data_package.h"
|
||||
namespace ur_driver
|
||||
{
|
||||
namespace rtde_interface
|
||||
{
|
||||
std::unordered_map<std::string, DataPackage::_rtde_type_variant> DataPackage::type_list_{
|
||||
{ "timestamp", double() },
|
||||
{ "target_q", vector6d_t() },
|
||||
{ "target_qd", vector6d_t() },
|
||||
{ "target_qdd", vector6d_t() },
|
||||
{ "target_current", vector6d_t() },
|
||||
{ "target_moment", vector6d_t() },
|
||||
{ "actual_q", vector6d_t() },
|
||||
{ "actual_qd", vector6d_t() },
|
||||
{ "actual_qdd", vector6d_t() },
|
||||
{ "actual_current", vector6d_t() },
|
||||
{ "actual_moment", vector6d_t() },
|
||||
{ "joint_control_output", vector6d_t() },
|
||||
{ "actual_TCP_pose", vector6d_t() },
|
||||
{ "actual_TCP_speed", vector6d_t() },
|
||||
{ "actual_TCP_force", vector6d_t() },
|
||||
{ "target_TCP_pose", vector6d_t() },
|
||||
{ "target_TCP_speed", vector6d_t() },
|
||||
{ "actual_digital_input_bits", uint64_t() },
|
||||
{ "joint_temperatures", vector6d_t() },
|
||||
{ "actual_execution_time", double() },
|
||||
{ "robot_mode", int32_t() },
|
||||
{ "joint_mode", vector6int32_t() },
|
||||
{ "safety_mode", int32_t() },
|
||||
{ "actual_tool_accelerometer", vector3d_t() },
|
||||
{ "speed_scaling", double() },
|
||||
{ "target_speed_fraction", double() },
|
||||
{ "actual_momentum", double() },
|
||||
{ "actial_main_voltage", double() },
|
||||
{ "actual_robot_voltage", double() },
|
||||
{ "actual_robot_current", double() },
|
||||
{ "actual_joint_voltage", vector6d_t() },
|
||||
{ "actual_digital_output_bits", uint64_t() },
|
||||
{ "runtime_state", uint32_t() },
|
||||
{ "elbow_position", vector3d_t() },
|
||||
{ "elbow_velocity", vector3d_t() },
|
||||
{ "robot_status_bits", uint32_t() },
|
||||
{ "safety_status_bits", uint32_t() },
|
||||
{ "analog_io_types", uint32_t() },
|
||||
{ "standard_analog_input0", double() },
|
||||
{ "standard_analog_input1", double() },
|
||||
{ "standard_analog_output0", double() },
|
||||
{ "standard_analog_output1", double() },
|
||||
{ "io_current", double() },
|
||||
{ "euromap67_input_bits", uint32_t() },
|
||||
{ "euromap67_output_bits", uint32_t() },
|
||||
{ "euromap67_24V_voltage", double() },
|
||||
{ "euromap67_24V_current", double() },
|
||||
{ "tool_mode", uint32_t() },
|
||||
{ "tool_analog_input_types", uint32_t() },
|
||||
{ "tool_analog_input0", double() },
|
||||
{ "tool_analog_input1", double() },
|
||||
{ "tool_output_voltage", int32_t() },
|
||||
{ "tool_output_current", double() },
|
||||
{ "tool_temperature", double() },
|
||||
{ "tool_force_scalar", double() },
|
||||
{ "output_bit_registers0_to_31", uint32_t() },
|
||||
{ "output_bit_registers32_to_63", uint32_t() },
|
||||
{ "output_int_register_0", int32_t() },
|
||||
{ "output_int_register_1", int32_t() },
|
||||
{ "output_int_register_2", int32_t() },
|
||||
{ "output_int_register_3", int32_t() },
|
||||
{ "output_int_register_4", int32_t() },
|
||||
{ "output_int_register_5", int32_t() },
|
||||
{ "output_int_register_6", int32_t() },
|
||||
{ "output_int_register_7", int32_t() },
|
||||
{ "output_int_register_8", int32_t() },
|
||||
{ "output_int_register_9", int32_t() },
|
||||
{ "output_int_register_10", int32_t() },
|
||||
{ "output_int_register_11", int32_t() },
|
||||
{ "output_int_register_12", int32_t() },
|
||||
{ "output_int_register_13", int32_t() },
|
||||
{ "output_int_register_14", int32_t() },
|
||||
{ "output_int_register_15", int32_t() },
|
||||
{ "output_int_register_16", int32_t() },
|
||||
{ "output_int_register_17", int32_t() },
|
||||
{ "output_int_register_18", int32_t() },
|
||||
{ "output_int_register_19", int32_t() },
|
||||
{ "output_int_register_20", int32_t() },
|
||||
{ "output_int_register_21", int32_t() },
|
||||
{ "output_int_register_22", int32_t() },
|
||||
{ "output_int_register_23", int32_t() },
|
||||
{ "output_double_register_0", double() },
|
||||
{ "output_double_register_1", double() },
|
||||
{ "output_double_register_2", double() },
|
||||
{ "output_double_register_3", double() },
|
||||
{ "output_double_register_4", double() },
|
||||
{ "output_double_register_5", double() },
|
||||
{ "output_double_register_6", double() },
|
||||
{ "output_double_register_7", double() },
|
||||
{ "output_double_register_8", double() },
|
||||
{ "output_double_register_9", double() },
|
||||
{ "output_double_register_10", double() },
|
||||
{ "output_double_register_11", double() },
|
||||
{ "output_double_register_12", double() },
|
||||
{ "output_double_register_13", double() },
|
||||
{ "output_double_register_14", double() },
|
||||
{ "output_double_register_15", double() },
|
||||
{ "output_double_register_16", double() },
|
||||
{ "output_double_register_17", double() },
|
||||
{ "output_double_register_18", double() },
|
||||
{ "output_double_register_19", double() },
|
||||
{ "output_double_register_20", double() },
|
||||
{ "output_double_register_21", double() },
|
||||
{ "output_double_register_22", double() },
|
||||
{ "output_double_register_23", double() },
|
||||
{ "input_bit_registers0_to_31", uint32_t() },
|
||||
{ "input_bit_registers32_to_63", uint32_t() },
|
||||
{ "input_int_register_0", int32_t() },
|
||||
{ "input_int_register_1", int32_t() },
|
||||
{ "input_int_register_2", int32_t() },
|
||||
{ "input_int_register_3", int32_t() },
|
||||
{ "input_int_register_4", int32_t() },
|
||||
{ "input_int_register_5", int32_t() },
|
||||
{ "input_int_register_6", int32_t() },
|
||||
{ "input_int_register_7", int32_t() },
|
||||
{ "input_int_register_8", int32_t() },
|
||||
{ "input_int_register_9", int32_t() },
|
||||
{ "input_int_register_10", int32_t() },
|
||||
{ "input_int_register_11", int32_t() },
|
||||
{ "input_int_register_12", int32_t() },
|
||||
{ "input_int_register_13", int32_t() },
|
||||
{ "input_int_register_14", int32_t() },
|
||||
{ "input_int_register_15", int32_t() },
|
||||
{ "input_int_register_16", int32_t() },
|
||||
{ "input_int_register_17", int32_t() },
|
||||
{ "input_int_register_18", int32_t() },
|
||||
{ "input_int_register_19", int32_t() },
|
||||
{ "input_int_register_20", int32_t() },
|
||||
{ "input_int_register_21", int32_t() },
|
||||
{ "input_int_register_22", int32_t() },
|
||||
{ "input_int_register_23", int32_t() },
|
||||
{ "input_double_register_0", double() },
|
||||
{ "input_double_register_1", double() },
|
||||
{ "input_double_register_2", double() },
|
||||
{ "input_double_register_3", double() },
|
||||
{ "input_double_register_4", double() },
|
||||
{ "input_double_register_5", double() },
|
||||
{ "input_double_register_6", double() },
|
||||
{ "input_double_register_7", double() },
|
||||
{ "input_double_register_8", double() },
|
||||
{ "input_double_register_9", double() },
|
||||
{ "input_double_register_10", double() },
|
||||
{ "input_double_register_11", double() },
|
||||
{ "input_double_register_12", double() },
|
||||
{ "input_double_register_13", double() },
|
||||
{ "input_double_register_14", double() },
|
||||
{ "input_double_register_15", double() },
|
||||
{ "input_double_register_16", double() },
|
||||
{ "input_double_register_17", double() },
|
||||
{ "input_double_register_18", double() },
|
||||
{ "input_double_register_19", double() },
|
||||
{ "input_double_register_20", double() },
|
||||
{ "input_double_register_21", double() },
|
||||
{ "input_double_register_22", double() },
|
||||
{ "input_double_register_23", double() }
|
||||
};
|
||||
|
||||
bool rtde_interface::DataPackage ::parseWith(comm::BinParser& bp)
|
||||
{
|
||||
bp.parse(recipe_id_);
|
||||
for (auto& item : recipe_)
|
||||
{
|
||||
if (type_list_.find(item) != type_list_.end())
|
||||
{
|
||||
_rtde_type_variant entry = type_list_[item];
|
||||
auto bound_visitor = std::bind(ParseVisitor(), std::placeholders::_1, bp);
|
||||
boost::apply_visitor(bound_visitor, entry);
|
||||
data_[item] = entry;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string rtde_interface::DataPackage::toString() const
|
||||
{
|
||||
std::stringstream ss;
|
||||
for (auto& item : data_)
|
||||
{
|
||||
ss << item.first << ": ";
|
||||
ss << boost::apply_visitor(StringVisitor{}, item.second) << std::endl;
|
||||
}
|
||||
return ss.str();
|
||||
}
|
||||
} // namespace rtde_interface
|
||||
} // namespace ur_driver
|
||||
57
ur_rtde_driver/src/rtde/get_urcontrol_version.cpp
Normal file
57
ur_rtde_driver/src/rtde/get_urcontrol_version.cpp
Normal file
@@ -0,0 +1,57 @@
|
||||
// this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*-
|
||||
|
||||
// -- BEGIN LICENSE BLOCK ----------------------------------------------
|
||||
// Copyright 2019 FZI Forschungszentrum Informatik
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// -- END LICENSE BLOCK ------------------------------------------------
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
/*!\file
|
||||
*
|
||||
* \author Tristan Schnell schnell@fzi.de
|
||||
* \date 2019-04-09
|
||||
*
|
||||
*/
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
#include "ur_rtde_driver/rtde/get_urcontrol_version.h"
|
||||
|
||||
namespace ur_driver
|
||||
{
|
||||
namespace rtde_interface
|
||||
{
|
||||
bool GetUrcontrolVersion::parseWith(comm::BinParser& bp)
|
||||
{
|
||||
bp.parse(major_);
|
||||
bp.parse(minor_);
|
||||
bp.parse(bugfix_);
|
||||
bp.parse(build_);
|
||||
|
||||
return true;
|
||||
}
|
||||
std::string GetUrcontrolVersion::toString() const
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << "version: " << major_ << ".";
|
||||
ss << minor_ << "." << bugfix_ << "." << build_;
|
||||
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
size_t GetUrcontrolVersionRequest::generateSerializedRequest(uint8_t* buffer)
|
||||
{
|
||||
return PackageHeader::serializeHeader(buffer, PACKAGE_TYPE, PAYLOAD_SIZE);
|
||||
}
|
||||
} // namespace rtde_interface
|
||||
} // namespace ur_driver
|
||||
57
ur_rtde_driver/src/rtde/request_protocol_version.cpp
Normal file
57
ur_rtde_driver/src/rtde/request_protocol_version.cpp
Normal file
@@ -0,0 +1,57 @@
|
||||
// this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*-
|
||||
|
||||
// -- BEGIN LICENSE BLOCK ----------------------------------------------
|
||||
// Copyright 2019 FZI Forschungszentrum Informatik
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// -- END LICENSE BLOCK ------------------------------------------------
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
/*!\file
|
||||
*
|
||||
* \author Tristan Schnell schnell@fzi.de
|
||||
* \date 2019-04-09
|
||||
*
|
||||
*/
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
#include "ur_rtde_driver/rtde/request_protocol_version.h"
|
||||
|
||||
namespace ur_driver
|
||||
{
|
||||
namespace rtde_interface
|
||||
{
|
||||
bool RequestProtocolVersion::parseWith(comm::BinParser& bp)
|
||||
{
|
||||
bp.parse(accepted_);
|
||||
|
||||
return true;
|
||||
}
|
||||
std::string RequestProtocolVersion::toString() const
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << "accepted: " << static_cast<int>(accepted_);
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
size_t RequestProtocolVersionRequest::generateSerializedRequest(uint8_t* buffer, uint16_t version)
|
||||
{
|
||||
size_t size = 0;
|
||||
size += PackageHeader::serializeHeader(buffer, PACKAGE_TYPE, PAYLOAD_SIZE);
|
||||
|
||||
size += comm::PackageSerializer::serialize(buffer + size, version);
|
||||
|
||||
return size;
|
||||
}
|
||||
} // namespace rtde_interface
|
||||
} // namespace ur_driver
|
||||
124
ur_rtde_driver/src/rtde/rtde_client.cpp
Normal file
124
ur_rtde_driver/src/rtde/rtde_client.cpp
Normal file
@@ -0,0 +1,124 @@
|
||||
// this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*-
|
||||
|
||||
// -- BEGIN LICENSE BLOCK ----------------------------------------------
|
||||
// Copyright 2019 FZI Forschungszentrum Informatik
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// -- END LICENSE BLOCK ------------------------------------------------
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
/*!\file
|
||||
*
|
||||
* \author Tristan Schnell schnell@fzi.de
|
||||
* \date 2019-04-10
|
||||
*
|
||||
*/
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
#include "ur_rtde_driver/rtde/rtde_client.h"
|
||||
|
||||
namespace ur_driver
|
||||
{
|
||||
namespace rtde_interface
|
||||
{
|
||||
RTDEClient::RTDEClient(std::string ROBOT_IP, comm::INotifier& notifier)
|
||||
: stream_(ROBOT_IP, UR_RTDE_PORT)
|
||||
, parser_(readRecipe())
|
||||
, prod_(stream_, parser_)
|
||||
, pipeline_(prod_, PIPELINE_NAME, notifier)
|
||||
{
|
||||
}
|
||||
|
||||
bool RTDEClient::init()
|
||||
{
|
||||
pipeline_.run();
|
||||
uint8_t buffer[4096];
|
||||
size_t size;
|
||||
size_t written;
|
||||
// negotiate version
|
||||
uint16_t protocol_version = 2;
|
||||
size = RequestProtocolVersionRequest::generateSerializedRequest(buffer, protocol_version);
|
||||
stream_.write(buffer, size, written);
|
||||
std::unique_ptr<comm::URPackage<PackageHeader>> package;
|
||||
pipeline_.getLatestProduct(package, std::chrono::milliseconds(1000));
|
||||
rtde_interface::RequestProtocolVersion* tmp_version =
|
||||
dynamic_cast<rtde_interface::RequestProtocolVersion*>(package.get());
|
||||
if (!tmp_version->accepted_)
|
||||
{
|
||||
protocol_version = 1;
|
||||
size = RequestProtocolVersionRequest::generateSerializedRequest(buffer, protocol_version);
|
||||
stream_.write(buffer, size, written);
|
||||
pipeline_.getLatestProduct(package, std::chrono::milliseconds(1000));
|
||||
tmp_version = dynamic_cast<rtde_interface::RequestProtocolVersion*>(package.get());
|
||||
if (!tmp_version->accepted_)
|
||||
{
|
||||
LOG_ERROR("Could not negotiate protocol version");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// determine maximum frequency from ur-control version
|
||||
double max_frequency = URE_MAX_FREQUENCY;
|
||||
size = GetUrcontrolVersionRequest::generateSerializedRequest(buffer);
|
||||
stream_.write(buffer, size, written);
|
||||
pipeline_.getLatestProduct(package, std::chrono::milliseconds(1000));
|
||||
rtde_interface::GetUrcontrolVersion* tmp_control_version =
|
||||
dynamic_cast<rtde_interface::GetUrcontrolVersion*>(package.get());
|
||||
if (tmp_control_version->major_ < 5)
|
||||
{
|
||||
max_frequency = CB3_MAX_FREQUENCY;
|
||||
}
|
||||
|
||||
// sending output recipe
|
||||
LOG_INFO("Setting up RTDE communication with frequency %f", max_frequency);
|
||||
if (protocol_version == 2)
|
||||
{
|
||||
size = ControlPackageSetupOutputsRequest::generateSerializedRequest(buffer, max_frequency, readRecipe());
|
||||
}
|
||||
else
|
||||
{
|
||||
size = ControlPackageSetupOutputsRequest::generateSerializedRequest(buffer, readRecipe());
|
||||
}
|
||||
stream_.write(buffer, size, written);
|
||||
return pipeline_.getLatestProduct(package, std::chrono::milliseconds(1000));
|
||||
}
|
||||
bool RTDEClient::start()
|
||||
{
|
||||
uint8_t buffer[4096];
|
||||
size_t size;
|
||||
size_t written;
|
||||
size = ControlPackageStartRequest::generateSerializedRequest(buffer);
|
||||
std::unique_ptr<comm::URPackage<PackageHeader>> package;
|
||||
stream_.write(buffer, size, written);
|
||||
pipeline_.getLatestProduct(package, std::chrono::milliseconds(1000));
|
||||
rtde_interface::ControlPackageStart* tmp = dynamic_cast<rtde_interface::ControlPackageStart*>(package.get());
|
||||
return tmp->accepted_;
|
||||
}
|
||||
std::vector<std::string> RTDEClient::readRecipe()
|
||||
{
|
||||
std::vector<std::string> recipe;
|
||||
recipe.push_back("timestamp");
|
||||
recipe.push_back("actual_q");
|
||||
recipe.push_back("actual_qd");
|
||||
recipe.push_back("speed_scaling");
|
||||
recipe.push_back("target_speed_fraction");
|
||||
return recipe;
|
||||
}
|
||||
|
||||
bool RTDEClient::getDataPackage(std::unique_ptr<comm::URPackage<PackageHeader>>& data_package,
|
||||
std::chrono::milliseconds timeout)
|
||||
{
|
||||
return pipeline_.getLatestProduct(data_package, timeout);
|
||||
}
|
||||
} // namespace rtde_interface
|
||||
} // namespace ur_driver
|
||||
53
ur_rtde_driver/src/rtde/rtde_package.cpp
Normal file
53
ur_rtde_driver/src/rtde/rtde_package.cpp
Normal file
@@ -0,0 +1,53 @@
|
||||
// this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*-
|
||||
|
||||
// -- BEGIN LICENSE BLOCK ----------------------------------------------
|
||||
// Copyright 2019 FZI Forschungszentrum Informatik
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// -- END LICENSE BLOCK ------------------------------------------------
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
/*!\file
|
||||
*
|
||||
* \author Felix Mauch mauch@fzi.de
|
||||
* \date 2019-04-10
|
||||
*
|
||||
*/
|
||||
//----------------------------------------------------------------------
|
||||
#include "ur_rtde_driver/rtde/rtde_package.h"
|
||||
|
||||
namespace ur_driver
|
||||
{
|
||||
namespace rtde_interface
|
||||
{
|
||||
bool RTDEPackage::parseWith(comm::BinParser& bp)
|
||||
{
|
||||
bp.rawData(buffer_, buffer_length_);
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string rtde_interface::RTDEPackage ::toString() const
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << "Type: " << static_cast<int>(type_) << std::endl;
|
||||
ss << "Raw byte stream: ";
|
||||
for (size_t i = 0; i < buffer_length_; ++i)
|
||||
{
|
||||
uint8_t* buf = buffer_.get();
|
||||
ss << std::hex << static_cast<int>(buf[i]) << " ";
|
||||
}
|
||||
ss << std::endl;
|
||||
return ss.str();
|
||||
}
|
||||
} // namespace rtde_interface
|
||||
} // namespace ur_driver
|
||||
54
ur_rtde_driver/src/rtde/text_message.cpp
Normal file
54
ur_rtde_driver/src/rtde/text_message.cpp
Normal file
@@ -0,0 +1,54 @@
|
||||
// this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*-
|
||||
|
||||
// -- BEGIN LICENSE BLOCK ----------------------------------------------
|
||||
// Copyright 2019 FZI Forschungszentrum Informatik
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// -- END LICENSE BLOCK ------------------------------------------------
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
/*!\file
|
||||
*
|
||||
* \author Tristan Schnell schnell@fzi.de
|
||||
* \date 2019-04-09
|
||||
*
|
||||
*/
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
#include "ur_rtde_driver/rtde/text_message.h"
|
||||
|
||||
namespace ur_driver
|
||||
{
|
||||
namespace rtde_interface
|
||||
{
|
||||
bool TextMessage::parseWith(comm::BinParser& bp)
|
||||
{
|
||||
bp.parse(message_length_);
|
||||
bp.parse(message_, message_length_);
|
||||
bp.parse(source_length_);
|
||||
bp.parse(source_, source_length_);
|
||||
bp.parse(warning_level_);
|
||||
|
||||
return true;
|
||||
}
|
||||
std::string TextMessage::toString() const
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << "message: " << message_ << std::endl;
|
||||
ss << "source: " << source_ << std::endl;
|
||||
ss << "warning level: " << static_cast<int>(warning_level_);
|
||||
|
||||
return ss.str();
|
||||
}
|
||||
} // namespace rtde_interface
|
||||
} // namespace ur_driver
|
||||
Reference in New Issue
Block a user