1
0
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:
Felix Mauch
2019-04-08 10:15:01 +02:00
parent f7c51bae87
commit 3c61cbeb35
5 changed files with 61 additions and 39 deletions

View 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

View File

@@ -36,7 +36,7 @@
namespace ur_driver
{
namespace primary
namespace primary_interface
{
enum class message_type : int8_t
{
@@ -77,7 +77,6 @@ enum class robot_message_type : uint8_t
ROBOT_MESSAGE_RUNTIME_EXCEPTION = 10
};
class Header
{
public:
@@ -87,18 +86,11 @@ public:
using _package_size_type = int32_t;
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:
int32_t package_size_;
_package_size_type package_size_;
int8_t package_type_;
};
} // namespace primary_interface

View File

@@ -29,25 +29,22 @@
#define UR_RTDE_DRIVER_PRIMARY_PACKAGE_H_INCLUDED
#include "ur_rtde_driver/primary/primary_header.h"
#include "ur_rtde_driver/comm/package.h"
namespace ur_driver
{
namespace primary_interface
{
class PrimaryPackage
class PrimaryPackage : comm::URPackage<Header>
{
private:
uint8_t* data_buffer_;
public:
PrimaryPackage() = default;
virtual ~PrimaryPackage() = default;
private:
uint8_t* data_buffer_;
};
} // namespace primary_interface
} // namespace ur_driver

View File

@@ -20,13 +20,10 @@
#include <endian.h>
#include "ur_rtde_driver/types.h"
namespace ur_driver
{
namespace rtde_interface
{
enum class PackageType
{
RTDE_REQUEST_PROTOCOL_VERSION = 86, // ascii V
@@ -39,30 +36,23 @@ enum class PackageType
RTDE_CONTROL_PACKAGE_PAUSE = 80 // ascii P
};
class Header
{
public:
Header() = default;
virtual ~Header() = default;
using _package_size_type = uint16_t;
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:
uint16_t package_size_;
_package_size_type package_size_;
PackageType package_type_;
};
} // namespace rtde_interface
} // namespace ur_driver

View File

@@ -25,28 +25,23 @@
*/
//----------------------------------------------------------------------
#ifndef 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/comm/package.h"
namespace ur_driver
{
namespace rtde_interface
{
class RTDEPackage
class RTDEPackage : comm::URPackage<Header>
{
public:
RTDEPackage() = default;
virtual ~RTDEPackage() = default;
};
} // namespace rtde_interface
} // namespace ur_driver