include
ur_client_library
rtde
rtde/package_header.h
Go to the documentation of this file.
1
2
// this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*-
3
4
// -- BEGIN LICENSE BLOCK ----------------------------------------------
5
// Copyright 2019 FZI Forschungszentrum Informatik
6
// Created on behalf of Universal Robots A/S
7
//
8
// Licensed under the Apache License, Version 2.0 (the "License");
9
// you may not use this file except in compliance with the License.
10
// You may obtain a copy of the License at
11
//
12
// http://www.apache.org/licenses/LICENSE-2.0
13
//
14
// Unless required by applicable law or agreed to in writing, software
15
// distributed under the License is distributed on an "AS IS" BASIS,
16
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
// See the License for the specific language governing permissions and
18
// limitations under the License.
19
// -- END LICENSE BLOCK ------------------------------------------------
20
21
//----------------------------------------------------------------------
28
//----------------------------------------------------------------------
29
30
#ifndef UR_CLIENT_LIBRARY_RTDE__HEADER_H_INCLUDED
31
#define UR_CLIENT_LIBRARY_RTDE__HEADER_H_INCLUDED
32
33
#include <cstddef>
34
#include <endian.h>
35
#include "
ur_client_library/types.h
"
36
#include "
ur_client_library/comm/package_serializer.h
"
37
38
namespace
urcl
39
{
40
namespace
rtde_interface
41
{
45
enum class
PackageType
: uint8_t
46
{
47
RTDE_REQUEST_PROTOCOL_VERSION
= 86,
// ascii V
48
RTDE_GET_URCONTROL_VERSION
= 118,
// ascii v
49
RTDE_TEXT_MESSAGE
= 77,
// ascii M
50
RTDE_DATA_PACKAGE
= 85,
// ascii U
51
RTDE_CONTROL_PACKAGE_SETUP_OUTPUTS
= 79,
// ascii O
52
RTDE_CONTROL_PACKAGE_SETUP_INPUTS
= 73,
// ascii I
53
RTDE_CONTROL_PACKAGE_START
= 83,
// ascii S
54
RTDE_CONTROL_PACKAGE_PAUSE
= 80
// ascii P
55
};
56
60
class
PackageHeader
61
{
62
public
:
63
PackageHeader
() =
default
;
64
virtual
~
PackageHeader
() =
default
;
65
using
_package_size_type
= uint16_t;
66
74
static
size_t
getPackageLength
(uint8_t* buf)
75
{
76
return
be16toh(*(reinterpret_cast<_package_size_type*>(buf)));
77
}
78
88
static
size_t
serializeHeader
(uint8_t* buffer,
PackageType
package_type, uint16_t payload_length)
89
{
90
uint16_t header_size =
sizeof
(
_package_size_type
) +
sizeof
(
PackageType
);
91
uint16_t size = header_size + payload_length;
92
comm::PackageSerializer::serialize
(buffer, size);
93
comm::PackageSerializer::serialize
(buffer +
sizeof
(size), package_type);
94
return
header_size;
95
}
96
};
97
98
}
// namespace rtde_interface
99
}
// namespace urcl
100
101
#endif // #ifndef UR_CLIENT_LIBRARY_RTDE__HEADER_H_INCLUDED
types.h
urcl::rtde_interface::PackageHeader::_package_size_type
uint16_t _package_size_type
Definition:
rtde/package_header.h:65
urcl::rtde_interface::PackageType::RTDE_CONTROL_PACKAGE_SETUP_OUTPUTS
urcl::rtde_interface::PackageType::RTDE_CONTROL_PACKAGE_START
urcl::rtde_interface::PackageType::RTDE_REQUEST_PROTOCOL_VERSION
urcl::rtde_interface::PackageType::RTDE_CONTROL_PACKAGE_SETUP_INPUTS
urcl::rtde_interface::PackageType
PackageType
Possible package types.
Definition:
rtde/package_header.h:45
urcl::rtde_interface::PackageHeader::getPackageLength
static size_t getPackageLength(uint8_t *buf)
Reads a buffer, interpreting the next bytes as the size of the contained package. ...
Definition:
rtde/package_header.h:74
urcl::rtde_interface::PackageHeader
This class represents the header for RTDE packages.
Definition:
rtde/package_header.h:60
urcl::rtde_interface::PackageType::RTDE_GET_URCONTROL_VERSION
urcl::rtde_interface::PackageType::RTDE_DATA_PACKAGE
urcl::rtde_interface::PackageType::RTDE_CONTROL_PACKAGE_PAUSE
urcl
Definition:
bin_parser.h:36
urcl::comm::PackageSerializer::serialize
static size_t serialize(uint8_t *buffer, T val)
A generalized serialization method for arbitrary datatypes.
Definition:
package_serializer.h:56
package_serializer.h
urcl::rtde_interface::PackageType::RTDE_TEXT_MESSAGE
urcl::rtde_interface::PackageHeader::serializeHeader
static size_t serializeHeader(uint8_t *buffer, PackageType package_type, uint16_t payload_length)
Creates a serialization of a header based on given values.
Definition:
rtde/package_header.h:88
ur_client_library
Author(s): Thomas Timm Andersen, Simon Rasmussen, Felix Exner, Lea Steffen, Tristan Schnell
autogenerated on Tue Jul 4 2023 02:09:47