diff --git a/.gitignore b/.gitignore index 1e69c9f..820cab7 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,5 @@ cmake_install.cmake install_manifest.txt *~ .idea +.directory +.vscode \ No newline at end of file diff --git a/include/ur_rtde_driver/primary/kinematics_info.h b/include/ur_rtde_driver/primary/kinematics_info.h new file mode 100644 index 0000000..f42c491 --- /dev/null +++ b/include/ur_rtde_driver/primary/kinematics_info.h @@ -0,0 +1,51 @@ +// 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 Lea Steffen steffen@fzi.de + * \date 2019-04-01 + * + */ +//---------------------------------------------------------------------- + +#ifndef UR_RTDE_DRIVER_KINEMATICS_INFO_H_INCLUDED +#define UR_RTDE_DRIVER_KINEMATICS_INFO_H_INCLUDED + +#include "ur_rtde_driver/primary/primary_package.h" +#include "ur_rtde_driver/primary/robot_state.h" + +namespace ur_driver +{ +namespace primary_interface +{ +class KinematicsInfo : PrimaryPackage +{ +private: + RobotState robot_state_; + +public: + KinematicsInfo() = default; + virtual ~KinematicsInfo() = default; +}; + +} // namespace primary_interface +} // namespace ur_driver + +#endif /* UR_RTDE_DRIVER_KINEMATICS_INFO_H_INCLUDED */ \ No newline at end of file diff --git a/include/ur_rtde_driver/primary/primary_header.h b/include/ur_rtde_driver/primary/primary_header.h new file mode 100644 index 0000000..4aa1ee0 --- /dev/null +++ b/include/ur_rtde_driver/primary/primary_header.h @@ -0,0 +1,107 @@ +// 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 + * \author Lea Steffen steffen@fzi.de + * \date 2019-04-01 + * + */ +//---------------------------------------------------------------------- + +#ifndef UR_RTDE_DRIVER_PRIMARY_INTERFACE_H_INCLUDED +#define UR_RTDE_DRIVER_PRIMARY_INTERFACE_H_INCLUDED + +#include +#include +#include +#include "ur_rtde_driver/types.h" + +namespace ur_driver +{ +namespace primary +{ +enum class message_type : int8_t +{ + DISCONNECT = -1, + ROBOT_STATE = 16, + ROBOT_MESSAGE = 20, + HMC_MESSAGE = 22, + MODBUS_INFO_MESSAGE = 5, + SAFETY_SETUP_BROADCAST_MESSAGE = 23, + SAFETY_COMPLIANCE_TOLERANCES_MESSAGE = 24, + PROGRAM_STATE_MESSAGE = 25 +}; + +enum class robot_state_type : uint8_t +{ + ROBOT_MODE_DATA = 0, + JOINT_DATA = 1, + TOOL_DATA = 2, + MASTERBOARD_DATA = 3, + CARTESIAN_INFO = 4, + KINEMATICS_INFO = 5, + CONFIGURATION_DATA = 6, + FORCE_MODE_DATA = 7, + ADDITIONAL_INFO = 8, + CALIBRATION_DATA = 9 +}; + +enum class robot_message_type : uint8_t +{ + ROBOT_MESSAGE_TEXT = 0, + ROBOT_MESSAGE_PROGRAM_LABEL = 1, + PROGRAM_STATE_MESSAGE_VARIABLE_UPDATE = 2, + ROBOT_MESSAGE_VERSION = 3, + ROBOT_MESSAGE_SAFETY_MODE = 5, + ROBOT_MESSAGE_ERROR_CODE = 6, + ROBOT_MESSAGE_KEY = 7, + ROBOT_MESSAGE_REQUEST_VALUE = 9, + ROBOT_MESSAGE_RUNTIME_EXCEPTION = 10 +}; + + +class Header +{ +public: + Header() = default; + virtual ~Header() = default; + + using _package_size_type = int32_t; + static size_t getPackageLength(uint8_t* buf) + { + return be32toh(*(reinterpret_cast(buf))); + } + + static size_t getPackageSize() + { + return sizeof(package_size_); + } + + + +private: + int32_t package_size_; + int8_t package_type_; +}; +} // namespace primary_interface +} // namespace ur_driver + +#endif // ifndef UR_RTDE_DRIVER_PRIMARY_INTERFACE_H_INCLUDED diff --git a/include/ur_rtde_driver/primary/primary_package.h b/include/ur_rtde_driver/primary/primary_package.h new file mode 100644 index 0000000..8dba991 --- /dev/null +++ b/include/ur_rtde_driver/primary/primary_package.h @@ -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 Lea Steffen steffen@fzi.de + * \date 2019-04-01 + * + */ +//---------------------------------------------------------------------- + +#ifndef UR_RTDE_DRIVER_PRIMARY_PACKAGE_H_INCLUDED +#define UR_RTDE_DRIVER_PRIMARY_PACKAGE_H_INCLUDED + +#include "ur_rtde_driver/primary/primary_header.h" + +namespace ur_driver +{ +namespace primary_interface +{ + + +class PrimaryPackage +{ +private: + uint8_t* data_buffer_; +public: + PrimaryPackage() = default; + virtual ~PrimaryPackage() = default; + + +}; + + +} // namespace primary_interface +} // namespace ur_driver + +#endif /* UR_RTDE_DRIVER_PRIMARY_PACKAGE_H_INCLUDED */ diff --git a/include/ur_rtde_driver/primary/robot_message.h b/include/ur_rtde_driver/primary/robot_message.h new file mode 100644 index 0000000..73352aa --- /dev/null +++ b/include/ur_rtde_driver/primary/robot_message.h @@ -0,0 +1,47 @@ +// 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 Lea Steffen steffen@fzi.de + * \date 2019-04-01 + * + */ +//---------------------------------------------------------------------- + +#ifndef UR_RTDE_DRIVER_ROBOT_MESSAGE_H_INCLUDED +#define UR_RTDE_DRIVER_ROBOT_MESSAGE_H_INCLUDED + +#include "ur_rtde_driver/primary/primary_package.h" + +namespace ur_driver +{ +namespace primary_interface +{ +class RobotMessage : PrimaryPackage +{ +public: + RobotMessage() = default; + virtual ~RobotMessage() = default; +}; + +} // namespace primary_interface +} // namespace ur_driver + +#endif /* UR_RTDE_DRIVER_ROBOT_MESSAGE_H_INCLUDED */ diff --git a/include/ur_rtde_driver/primary/robot_mode_data.h b/include/ur_rtde_driver/primary/robot_mode_data.h new file mode 100644 index 0000000..974c93a --- /dev/null +++ b/include/ur_rtde_driver/primary/robot_mode_data.h @@ -0,0 +1,51 @@ +// 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 Lea Steffen steffen@fzi.de + * \date 2019-04-01 + * + */ +//---------------------------------------------------------------------- + +#ifndef UR_RTDE_DRIVER_ROBOT_MODE_DATA_H_INCLUDED +#define UR_RTDE_DRIVER_ROBOT_MODE_DATA_H_INCLUDED + +#include "ur_rtde_driver/primary/primary_package.h" +#include "ur_rtde_driver/primary/robot_state.h" + +namespace ur_driver +{ +namespace primary_interface +{ +class RobotModeData : PrimaryPackage +{ +private: + RobotState robot_state_; + +public: + RobotModeData() = default; + virtual ~RobotModeData() = default; +}; + +} // namespace primary_interface +} // namespace ur_driver + +#endif /* UR_RTDE_DRIVER_ROBOT_MODE_DATA_H_INCLUDED */ diff --git a/include/ur_rtde_driver/primary/robot_state.h b/include/ur_rtde_driver/primary/robot_state.h new file mode 100644 index 0000000..6645ba5 --- /dev/null +++ b/include/ur_rtde_driver/primary/robot_state.h @@ -0,0 +1,117 @@ +// 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 Lea Steffen steffen@fzi.de + * \date 2019-04-01 + * + */ +//---------------------------------------------------------------------- + +#ifndef UR_RTDE_DRIVER_ROBOT_STATE_H_INCLUDED +#define UR_RTDE_DRIVER_ROBOT_STATE_H_INCLUDED + +#include +#include + +#include "ur_rtde_driver/primary/primary_package.h" +#include "ur_rtde_driver/primary/primary_header.h" + +namespace ur_driver +{ +namespace primary_interface +{ +struct version_message +{ + uint64_t timestamp; + int8_t source; + int8_t robot_message_type; + int8_t project_name_size; + char project_name[15]; + uint8_t major_version; + uint8_t minor_version; + int svn_revision; + char build_date[25]; +}; + +struct masterboard_data +{ + int digitalInputBits; + int digitalOutputBits; + char analogInputRange0; + char analogInputRange1; + double analogInput0; + double analogInput1; + char analogOutputDomain0; + char analogOutputDomain1; + double analogOutput0; + double analogOutput1; + float masterBoardTemperature; + float robotVoltage48V; + float robotCurrent; + float masterIOCurrent; + unsigned char safetyMode; + unsigned char masterOnOffState; + char euromap67InterfaceInstalled; + int euromapInputBits; + int euromapOutputBits; + float euromapVoltage; + float euromapCurrent; +}; + +struct robot_mode_data +{ + uint64_t timestamp; + bool isRobotConnected; + bool isRealRobotEnabled; + bool isPowerOnRobot; + bool isEmergencyStopped; + bool isProtectiveStopped; + bool isProgramRunning; + bool isProgramPaused; + unsigned char robotMode; + unsigned char controlMode; + double targetSpeedFraction; + double speedScaling; +}; + +class RobotState : PrimaryPackage +{ +private: + robot_state_type robot_state_; + /* + version_message version_msg_; + masterboard_data mb_data_; + robot_mode_data robot_mode_; + std::recursive_mutex val_lock_; // Locks the variables while unpack parses data; + std::condition_variable* pMsg_cond_; //Signals that new vars are available + bool new_data_available_; //to avoid spurious wakes + unsigned char robot_mode_running_; + double ntohd(uint64_t nf); */ + +public: + RobotState() = default; + virtual ~RobotState() = default; +}; + +} // namespace primary_interface +} // namespace ur_driver + +#endif /* UR_RTDE_DRIVER_ROBOT_STATE_H_INCLUDED */ \ No newline at end of file diff --git a/include/ur_rtde_driver/rtde/data_package.h b/include/ur_rtde_driver/rtde/data_package.h new file mode 100644 index 0000000..0151329 --- /dev/null +++ b/include/ur_rtde_driver/rtde/data_package.h @@ -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 Lea Steffen steffen@fzi.de + * \date 2019-04-01 + * + */ +//---------------------------------------------------------------------- + +#ifndef UR_RTDE_DRIVER_DATA_PACKAGE_H_INCLUDED +#define UR_RTDE_DRIVER_DATA_PACKAGE_H_INCLUDED + +#include "ur_rtde_driver/rtde/rtde_package.h" + +namespace ur_driver +{ +namespace rtde_interface +{ +class DataPackage : RTDEPackage +{ +private: + uint8_t recipe_id_; + +public: + DataPackage() = default; + virtual ~DataPackage() = default; +}; + +} // namespace rtde_interface +} // namespace ur_driver + +#endif // ifndef UR_RTDE_DRIVER_DATA_PACKAGE_H_INCLUDED diff --git a/include/ur_rtde_driver/rtde/rtde_header.h b/include/ur_rtde_driver/rtde/rtde_header.h new file mode 100644 index 0000000..1022c4c --- /dev/null +++ b/include/ur_rtde_driver/rtde/rtde_header.h @@ -0,0 +1,69 @@ + +// this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*- + +// -- BEGIN LICENSE BLOCK ---------------------------------------------- +// -- END LICENSE BLOCK ------------------------------------------------ + +//---------------------------------------------------------------------- +/*!\file + * + * \author Lea Steffen steffen@fzi.de + * \date 2019-04-01 + * + */ +//---------------------------------------------------------------------- + +#ifndef UR_RTDE_DRIVER_RTDE__HEADER_H_INCLUDED +#define UR_RTDE_DRIVER_RTDE__HEADER_H_INCLUDED + +#include +#include +#include "ur_rtde_driver/types.h" + + +namespace ur_driver +{ +namespace rtde_interface +{ + + +enum class PackageType +{ + RTDE_REQUEST_PROTOCOL_VERSION = 86, // ascii V + RTDE_GET_URCONTROL_VERSION = 118, // ascii v + RTDE_TEXT_MESSAGE = 77, // ascii M + RTDE_DATA_PACKAGE = 85, // ascii U + RTDE_CONTROL_PACKAGE_SETUP_OUTPUTS = 79, // ascii O + RTDE_CONTROL_PACKAGE_SETUP_INPUTS = 73, // ascii I + RTDE_CONTROL_PACKAGE_START = 83, // ascii S + RTDE_CONTROL_PACKAGE_PAUSE = 80 // ascii P +}; + + +class Header +{ +public: + Header() = default; + virtual ~Header() = default; + + static size_t getPackageLength(uint8_t* buf) + { + return be16toh(*(reinterpret_cast(buf))); + } + + static size_t getPackageSize() + { + return sizeof(package_size_); + } + + +private: + uint16_t package_size_; + PackageType package_type_; +}; + + +} // namespace rtde_interface +} // namespace ur_driver + +#endif // #ifndef UR_RTDE_DRIVER_RTDE__HEADER_H_INCLUDED diff --git a/include/ur_rtde_driver/rtde/rtde_package.h b/include/ur_rtde_driver/rtde/rtde_package.h new file mode 100644 index 0000000..dbe6008 --- /dev/null +++ b/include/ur_rtde_driver/rtde/rtde_package.h @@ -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 Lea Steffen steffen@fzi.de + * \date 2019-04-01 + * + */ +//---------------------------------------------------------------------- + + +#ifndef UR_RTDE_DRIVER_RTDE_PACKAGE_H_INCLUDED +#define UR_RTDE_DRIVER_RTDE_PACKAGE_H_INCLUDED + +#include "ur_rtde_driver/rtde/rtde_header.h" + +namespace ur_driver +{ +namespace rtde_interface +{ + + +class RTDEPackage +{ +public: + RTDEPackage() = default; + virtual ~RTDEPackage() = default; + + +}; + + +} // namespace rtde_interface +} // namespace ur_driver + +#endif // UR_RTDE_DRIVER_RTDE_PACKAGE_H_INCLUDED diff --git a/include/ur_rtde_driver/rtde/text_message.h b/include/ur_rtde_driver/rtde/text_message.h new file mode 100644 index 0000000..b09262f --- /dev/null +++ b/include/ur_rtde_driver/rtde/text_message.h @@ -0,0 +1,47 @@ +// 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 Lea Steffen steffen@fzi.de + * \date 2019-04-01 + * + */ +//---------------------------------------------------------------------- + +#ifndef UR_RTDE_DRIVER_TEXT_MESSAGE_H_INCLUDED +#define UR_RTDE_DRIVER_TEXT_MESSAGE_H_INCLUDED + +#include "ur_rtde_driver/rtde/rtde_package.h" + +namespace ur_driver +{ +namespace rtde_interface +{ +class TextMessage : RTDEPackage +{ +public: + TextMessage() = default; + virtual ~TextMessage() = default; +}; + +} // namespace rtde_interface +} // namespace ur_driver + +#endif // UR_RTDE_DRIVER_TEXT_MESSAGE_H_INCLUDED \ No newline at end of file