mirror of
https://gitlab.com/obbart/universal_robots_ros_driver.git
synced 2026-04-10 10:00:48 +02:00
Added a common package ancestor
This commit is contained in:
48
include/ur_rtde_driver/comm/package.h
Normal file
48
include/ur_rtde_driver/comm/package.h
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 Felix Mauch mauch@fzi.de
|
||||||
|
* \date 2019-04-08
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
#ifndef UR_RTDE_DRIVER_PACKAGE_H_INCLUDED
|
||||||
|
#define UR_RTDE_DRIVER_PACKAGE_H_INCLUDED
|
||||||
|
|
||||||
|
namespace ur_driver
|
||||||
|
{
|
||||||
|
namespace comm
|
||||||
|
{
|
||||||
|
template <typename HeaderT>
|
||||||
|
class URPackage
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
URPackage();
|
||||||
|
virtual ~URPackage();
|
||||||
|
|
||||||
|
using _header_type = HeaderT;
|
||||||
|
|
||||||
|
private:
|
||||||
|
HeaderT header_;
|
||||||
|
};
|
||||||
|
} // namespace comm
|
||||||
|
} // namespace ur_rtde_driver
|
||||||
|
#endif // ifndef UR_RTDE_DRIVER_PACKAGE_H_INCLUDED
|
||||||
@@ -36,7 +36,7 @@
|
|||||||
|
|
||||||
namespace ur_driver
|
namespace ur_driver
|
||||||
{
|
{
|
||||||
namespace primary
|
namespace primary_interface
|
||||||
{
|
{
|
||||||
enum class message_type : int8_t
|
enum class message_type : int8_t
|
||||||
{
|
{
|
||||||
@@ -77,7 +77,6 @@ enum class robot_message_type : uint8_t
|
|||||||
ROBOT_MESSAGE_RUNTIME_EXCEPTION = 10
|
ROBOT_MESSAGE_RUNTIME_EXCEPTION = 10
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class Header
|
class Header
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -87,18 +86,11 @@ public:
|
|||||||
using _package_size_type = int32_t;
|
using _package_size_type = int32_t;
|
||||||
static size_t getPackageLength(uint8_t* buf)
|
static size_t getPackageLength(uint8_t* buf)
|
||||||
{
|
{
|
||||||
return be32toh(*(reinterpret_cast<int32_t*>(buf)));
|
return be32toh(*(reinterpret_cast<_package_size_type*>(buf)));
|
||||||
}
|
}
|
||||||
|
|
||||||
static size_t getPackageSize()
|
|
||||||
{
|
|
||||||
return sizeof(package_size_);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int32_t package_size_;
|
_package_size_type package_size_;
|
||||||
int8_t package_type_;
|
int8_t package_type_;
|
||||||
};
|
};
|
||||||
} // namespace primary_interface
|
} // namespace primary_interface
|
||||||
|
|||||||
@@ -29,25 +29,22 @@
|
|||||||
#define UR_RTDE_DRIVER_PRIMARY_PACKAGE_H_INCLUDED
|
#define UR_RTDE_DRIVER_PRIMARY_PACKAGE_H_INCLUDED
|
||||||
|
|
||||||
#include "ur_rtde_driver/primary/primary_header.h"
|
#include "ur_rtde_driver/primary/primary_header.h"
|
||||||
|
#include "ur_rtde_driver/comm/package.h"
|
||||||
|
|
||||||
namespace ur_driver
|
namespace ur_driver
|
||||||
{
|
{
|
||||||
namespace primary_interface
|
namespace primary_interface
|
||||||
{
|
{
|
||||||
|
class PrimaryPackage : comm::URPackage<Header>
|
||||||
|
|
||||||
class PrimaryPackage
|
|
||||||
{
|
{
|
||||||
private:
|
|
||||||
uint8_t* data_buffer_;
|
|
||||||
public:
|
public:
|
||||||
PrimaryPackage() = default;
|
PrimaryPackage() = default;
|
||||||
virtual ~PrimaryPackage() = default;
|
virtual ~PrimaryPackage() = default;
|
||||||
|
|
||||||
|
private:
|
||||||
|
uint8_t* data_buffer_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace primary_interface
|
} // namespace primary_interface
|
||||||
} // namespace ur_driver
|
} // namespace ur_driver
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
|
|
||||||
// this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*-
|
// this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*-
|
||||||
|
|
||||||
// -- BEGIN LICENSE BLOCK ----------------------------------------------
|
// -- BEGIN LICENSE BLOCK ----------------------------------------------
|
||||||
@@ -20,13 +20,10 @@
|
|||||||
#include <endian.h>
|
#include <endian.h>
|
||||||
#include "ur_rtde_driver/types.h"
|
#include "ur_rtde_driver/types.h"
|
||||||
|
|
||||||
|
|
||||||
namespace ur_driver
|
namespace ur_driver
|
||||||
{
|
{
|
||||||
namespace rtde_interface
|
namespace rtde_interface
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
enum class PackageType
|
enum class PackageType
|
||||||
{
|
{
|
||||||
RTDE_REQUEST_PROTOCOL_VERSION = 86, // ascii V
|
RTDE_REQUEST_PROTOCOL_VERSION = 86, // ascii V
|
||||||
@@ -39,30 +36,23 @@ enum class PackageType
|
|||||||
RTDE_CONTROL_PACKAGE_PAUSE = 80 // ascii P
|
RTDE_CONTROL_PACKAGE_PAUSE = 80 // ascii P
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class Header
|
class Header
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Header() = default;
|
Header() = default;
|
||||||
virtual ~Header() = default;
|
virtual ~Header() = default;
|
||||||
|
using _package_size_type = uint16_t;
|
||||||
|
|
||||||
static size_t getPackageLength(uint8_t* buf)
|
static size_t getPackageLength(uint8_t* buf)
|
||||||
{
|
{
|
||||||
return be16toh(*(reinterpret_cast<uint16_t*>(buf)));
|
return be16toh(*(reinterpret_cast<_package_size_type*>(buf)));
|
||||||
}
|
}
|
||||||
|
|
||||||
static size_t getPackageSize()
|
|
||||||
{
|
|
||||||
return sizeof(package_size_);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint16_t package_size_;
|
_package_size_type package_size_;
|
||||||
PackageType package_type_;
|
PackageType package_type_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace rtde_interface
|
} // namespace rtde_interface
|
||||||
} // namespace ur_driver
|
} // namespace ur_driver
|
||||||
|
|
||||||
|
|||||||
@@ -25,28 +25,23 @@
|
|||||||
*/
|
*/
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
#ifndef UR_RTDE_DRIVER_RTDE_PACKAGE_H_INCLUDED
|
#ifndef UR_RTDE_DRIVER_RTDE_PACKAGE_H_INCLUDED
|
||||||
#define UR_RTDE_DRIVER_RTDE_PACKAGE_H_INCLUDED
|
#define UR_RTDE_DRIVER_RTDE_PACKAGE_H_INCLUDED
|
||||||
|
|
||||||
#include "ur_rtde_driver/rtde/rtde_header.h"
|
#include "ur_rtde_driver/rtde/rtde_header.h"
|
||||||
|
#include "ur_rtde_driver/comm/package.h"
|
||||||
|
|
||||||
namespace ur_driver
|
namespace ur_driver
|
||||||
{
|
{
|
||||||
namespace rtde_interface
|
namespace rtde_interface
|
||||||
{
|
{
|
||||||
|
class RTDEPackage : comm::URPackage<Header>
|
||||||
|
|
||||||
class RTDEPackage
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RTDEPackage() = default;
|
RTDEPackage() = default;
|
||||||
virtual ~RTDEPackage() = default;
|
virtual ~RTDEPackage() = default;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace rtde_interface
|
} // namespace rtde_interface
|
||||||
} // namespace ur_driver
|
} // namespace ur_driver
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user