changed clock to be rosgraph
This commit is contained in:
parent
fe185f0fc2
commit
b6e16802f2
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "carla/ros2/types/TimePubSubTypes.h"
|
#include "carla/ros2/types/ClockPubSubTypes.h"
|
||||||
#include "carla/ros2/listeners/CarlaListener.h"
|
#include "carla/ros2/listeners/CarlaListener.h"
|
||||||
|
|
||||||
#include <fastdds/dds/domain/DomainParticipant.hpp>
|
#include <fastdds/dds/domain/DomainParticipant.hpp>
|
||||||
|
@ -34,9 +34,9 @@ namespace ros2 {
|
||||||
efd::Publisher* _publisher { nullptr };
|
efd::Publisher* _publisher { nullptr };
|
||||||
efd::Topic* _topic { nullptr };
|
efd::Topic* _topic { nullptr };
|
||||||
efd::DataWriter* _datawriter { nullptr };
|
efd::DataWriter* _datawriter { nullptr };
|
||||||
efd::TypeSupport _type { new builtin_interfaces::msg::TimePubSubType() };
|
efd::TypeSupport _type { new rosgraph::msg::ClockPubSubType() };
|
||||||
CarlaListener _listener {};
|
CarlaListener _listener {};
|
||||||
builtin_interfaces::msg::Time _time {};
|
rosgraph::msg::Clock _clock {};
|
||||||
};
|
};
|
||||||
|
|
||||||
bool CarlaClockPublisher::Init() {
|
bool CarlaClockPublisher::Init() {
|
||||||
|
@ -82,7 +82,7 @@ namespace ros2 {
|
||||||
|
|
||||||
bool CarlaClockPublisher::Publish() {
|
bool CarlaClockPublisher::Publish() {
|
||||||
eprosima::fastrtps::rtps::InstanceHandle_t instance_handle;
|
eprosima::fastrtps::rtps::InstanceHandle_t instance_handle;
|
||||||
eprosima::fastrtps::types::ReturnCode_t rcode = _impl->_datawriter->write(&_impl->_time, instance_handle);
|
eprosima::fastrtps::types::ReturnCode_t rcode = _impl->_datawriter->write(&_impl->_clock, instance_handle);
|
||||||
if (rcode == erc::ReturnCodeValue::RETCODE_OK) {
|
if (rcode == erc::ReturnCodeValue::RETCODE_OK) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -143,8 +143,8 @@ namespace ros2 {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CarlaClockPublisher::SetData(int32_t sec, uint32_t nanosec) {
|
void CarlaClockPublisher::SetData(int32_t sec, uint32_t nanosec) {
|
||||||
_impl->_time.sec(sec);
|
_impl->_clock.clock().sec(sec);
|
||||||
_impl->_time.nanosec(nanosec);
|
_impl->_clock.clock().nanosec(nanosec);
|
||||||
}
|
}
|
||||||
|
|
||||||
CarlaClockPublisher::CarlaClockPublisher(const char* ros_name, const char* parent) :
|
CarlaClockPublisher::CarlaClockPublisher(const char* ros_name, const char* parent) :
|
||||||
|
|
|
@ -0,0 +1,174 @@
|
||||||
|
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima).
|
||||||
|
//
|
||||||
|
// 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.
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @file Clock.cpp
|
||||||
|
* This source file contains the definition of the described types in the IDL file.
|
||||||
|
*
|
||||||
|
* This file was generated by the tool gen.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
// Remove linker warning LNK4221 on Visual Studio
|
||||||
|
namespace {
|
||||||
|
char dummy;
|
||||||
|
} // namespace
|
||||||
|
#endif // _WIN32
|
||||||
|
|
||||||
|
#include "Clock.h"
|
||||||
|
#include <fastcdr/Cdr.h>
|
||||||
|
|
||||||
|
#include <fastcdr/exceptions/BadParamException.h>
|
||||||
|
using namespace eprosima::fastcdr::exception;
|
||||||
|
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
|
#define Time_max_cdr_typesize 0ULL;
|
||||||
|
#define rosgraph_msg_Clock_max_cdr_typesize 0ULL;
|
||||||
|
#define Time_max_key_cdr_typesize 0ULL;
|
||||||
|
#define rosgraph_msg_Clock_max_key_cdr_typesize 0ULL;
|
||||||
|
|
||||||
|
rosgraph::msg::Clock::Clock()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
rosgraph::msg::Clock::~Clock()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
rosgraph::msg::Clock::Clock(
|
||||||
|
const rosgraph::msg::Clock& x)
|
||||||
|
{
|
||||||
|
m_clock = x.m_clock;
|
||||||
|
}
|
||||||
|
|
||||||
|
rosgraph::msg::Clock::Clock(
|
||||||
|
rosgraph::msg::Clock&& x) noexcept
|
||||||
|
{
|
||||||
|
m_clock = x.m_clock;
|
||||||
|
}
|
||||||
|
|
||||||
|
rosgraph::msg::Clock& rosgraph::msg::Clock::operator =(
|
||||||
|
const rosgraph::msg::Clock& x)
|
||||||
|
{
|
||||||
|
m_clock = x.m_clock;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
rosgraph::msg::Clock& rosgraph::msg::Clock::operator =(
|
||||||
|
rosgraph::msg::Clock&& x) noexcept
|
||||||
|
{
|
||||||
|
m_clock = x.m_clock;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool rosgraph::msg::Clock::operator ==(
|
||||||
|
const Clock& x) const
|
||||||
|
{
|
||||||
|
return (m_clock == x.m_clock);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool rosgraph::msg::Clock::operator !=(
|
||||||
|
const Clock& x) const
|
||||||
|
{
|
||||||
|
return !(*this == x);
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t rosgraph::msg::Clock::getMaxCdrSerializedSize(
|
||||||
|
size_t current_alignment)
|
||||||
|
{
|
||||||
|
static_cast<void>(current_alignment);
|
||||||
|
return rosgraph_msg_Clock_max_cdr_typesize;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t rosgraph::msg::Clock::getCdrSerializedSize(
|
||||||
|
const rosgraph::msg::Clock& data,
|
||||||
|
size_t current_alignment)
|
||||||
|
{
|
||||||
|
(void)data;
|
||||||
|
size_t initial_alignment = current_alignment;
|
||||||
|
|
||||||
|
|
||||||
|
current_alignment += builtin_interfaces::msg::Time::getCdrSerializedSize(data.clock(), current_alignment);
|
||||||
|
|
||||||
|
return current_alignment - initial_alignment;
|
||||||
|
}
|
||||||
|
|
||||||
|
void rosgraph::msg::Clock::serialize(
|
||||||
|
eprosima::fastcdr::Cdr& scdr) const
|
||||||
|
{
|
||||||
|
scdr << m_clock;
|
||||||
|
}
|
||||||
|
|
||||||
|
void rosgraph::msg::Clock::deserialize(
|
||||||
|
eprosima::fastcdr::Cdr& dcdr)
|
||||||
|
{
|
||||||
|
dcdr >> m_clock;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief This function copies the value in member clock
|
||||||
|
* @param _clock New value to be copied in member clock
|
||||||
|
*/
|
||||||
|
void rosgraph::msg::Clock::clock(
|
||||||
|
const builtin_interfaces::msg::Time& _clock)
|
||||||
|
{
|
||||||
|
m_clock = _clock;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief This function moves the value in member clock
|
||||||
|
* @param _clock New value to be moved in member clock
|
||||||
|
*/
|
||||||
|
void rosgraph::msg::Clock::clock(
|
||||||
|
builtin_interfaces::msg::Time&& _clock)
|
||||||
|
{
|
||||||
|
m_clock = std::move(_clock);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief This function returns a constant reference to member clock
|
||||||
|
* @return Constant reference to member clock
|
||||||
|
*/
|
||||||
|
const builtin_interfaces::msg::Time& rosgraph::msg::Clock::clock() const
|
||||||
|
{
|
||||||
|
return m_clock;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief This function returns a reference to member clock
|
||||||
|
* @return Reference to member clock
|
||||||
|
*/
|
||||||
|
builtin_interfaces::msg::Time& rosgraph::msg::Clock::clock()
|
||||||
|
{
|
||||||
|
return m_clock;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t rosgraph::msg::Clock::getKeyMaxCdrSerializedSize(
|
||||||
|
size_t current_alignment)
|
||||||
|
{
|
||||||
|
static_cast<void>(current_alignment);
|
||||||
|
return rosgraph_msg_Clock_max_key_cdr_typesize;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool rosgraph::msg::Clock::isKeyDefined()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void rosgraph::msg::Clock::serializeKey(
|
||||||
|
eprosima::fastcdr::Cdr& scdr) const
|
||||||
|
{
|
||||||
|
(void) scdr;
|
||||||
|
}
|
|
@ -0,0 +1,214 @@
|
||||||
|
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima).
|
||||||
|
//
|
||||||
|
// 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.
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @file Clock.h
|
||||||
|
* This header file contains the declaration of the described types in the IDL file.
|
||||||
|
*
|
||||||
|
* This file was generated by the tool gen.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _FAST_DDS_GENERATED_ROSGRAPH_MSG_CLOCK_H_
|
||||||
|
#define _FAST_DDS_GENERATED_ROSGRAPH_MSG_CLOCK_H_
|
||||||
|
|
||||||
|
#include "Time.h"
|
||||||
|
|
||||||
|
#include <fastrtps/utils/fixed_size_string.hpp>
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <array>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
#include <map>
|
||||||
|
#include <bitset>
|
||||||
|
|
||||||
|
#if defined(_WIN32)
|
||||||
|
#if defined(EPROSIMA_USER_DLL_EXPORT)
|
||||||
|
#define eProsima_user_DllExport __declspec( dllexport )
|
||||||
|
#else
|
||||||
|
#define eProsima_user_DllExport
|
||||||
|
#endif // EPROSIMA_USER_DLL_EXPORT
|
||||||
|
#else
|
||||||
|
#define eProsima_user_DllExport
|
||||||
|
#endif // _WIN32
|
||||||
|
|
||||||
|
#if defined(_WIN32)
|
||||||
|
#if defined(EPROSIMA_USER_DLL_EXPORT)
|
||||||
|
#if defined(CLOCK_SOURCE)
|
||||||
|
#define CLOCK_DllAPI __declspec( dllexport )
|
||||||
|
#else
|
||||||
|
#define CLOCK_DllAPI __declspec( dllimport )
|
||||||
|
#endif // CLOCK_SOURCE
|
||||||
|
#else
|
||||||
|
#define CLOCK_DllAPI
|
||||||
|
#endif // EPROSIMA_USER_DLL_EXPORT
|
||||||
|
#else
|
||||||
|
#define CLOCK_DllAPI
|
||||||
|
#endif // _WIN32
|
||||||
|
|
||||||
|
namespace eprosima {
|
||||||
|
namespace fastcdr {
|
||||||
|
class Cdr;
|
||||||
|
} // namespace fastcdr
|
||||||
|
} // namespace eprosima
|
||||||
|
|
||||||
|
namespace rosgraph {
|
||||||
|
namespace msg {
|
||||||
|
/*!
|
||||||
|
* @brief This class represents the structure Clock defined by the user in the IDL file.
|
||||||
|
* @ingroup Clock
|
||||||
|
*/
|
||||||
|
class Clock
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Default constructor.
|
||||||
|
*/
|
||||||
|
eProsima_user_DllExport Clock();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Default destructor.
|
||||||
|
*/
|
||||||
|
eProsima_user_DllExport ~Clock();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Copy constructor.
|
||||||
|
* @param x Reference to the object rosgraph::msg::Clock that will be copied.
|
||||||
|
*/
|
||||||
|
eProsima_user_DllExport Clock(
|
||||||
|
const Clock& x);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Move constructor.
|
||||||
|
* @param x Reference to the object rosgraph::msg::Clock that will be copied.
|
||||||
|
*/
|
||||||
|
eProsima_user_DllExport Clock(
|
||||||
|
Clock&& x) noexcept;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Copy assignment.
|
||||||
|
* @param x Reference to the object rosgraph::msg::Clock that will be copied.
|
||||||
|
*/
|
||||||
|
eProsima_user_DllExport Clock& operator =(
|
||||||
|
const Clock& x);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Move assignment.
|
||||||
|
* @param x Reference to the object rosgraph::msg::Clock that will be copied.
|
||||||
|
*/
|
||||||
|
eProsima_user_DllExport Clock& operator =(
|
||||||
|
Clock&& x) noexcept;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Comparison operator.
|
||||||
|
* @param x rosgraph::msg::Clock object to compare.
|
||||||
|
*/
|
||||||
|
eProsima_user_DllExport bool operator ==(
|
||||||
|
const Clock& x) const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Comparison operator.
|
||||||
|
* @param x rosgraph::msg::Clock object to compare.
|
||||||
|
*/
|
||||||
|
eProsima_user_DllExport bool operator !=(
|
||||||
|
const Clock& x) const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief This function copies the value in member clock
|
||||||
|
* @param _clock New value to be copied in member clock
|
||||||
|
*/
|
||||||
|
eProsima_user_DllExport void clock(
|
||||||
|
const builtin_interfaces::msg::Time& _clock);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief This function moves the value in member clock
|
||||||
|
* @param _clock New value to be moved in member clock
|
||||||
|
*/
|
||||||
|
eProsima_user_DllExport void clock(
|
||||||
|
builtin_interfaces::msg::Time&& _clock);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief This function returns a constant reference to member clock
|
||||||
|
* @return Constant reference to member clock
|
||||||
|
*/
|
||||||
|
eProsima_user_DllExport const builtin_interfaces::msg::Time& clock() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief This function returns a reference to member clock
|
||||||
|
* @return Reference to member clock
|
||||||
|
*/
|
||||||
|
eProsima_user_DllExport builtin_interfaces::msg::Time& clock();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief This function returns the maximum serialized size of an object
|
||||||
|
* depending on the buffer alignment.
|
||||||
|
* @param current_alignment Buffer alignment.
|
||||||
|
* @return Maximum serialized size.
|
||||||
|
*/
|
||||||
|
eProsima_user_DllExport static size_t getMaxCdrSerializedSize(
|
||||||
|
size_t current_alignment = 0);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief This function returns the serialized size of a data depending on the buffer alignment.
|
||||||
|
* @param data Data which is calculated its serialized size.
|
||||||
|
* @param current_alignment Buffer alignment.
|
||||||
|
* @return Serialized size.
|
||||||
|
*/
|
||||||
|
eProsima_user_DllExport static size_t getCdrSerializedSize(
|
||||||
|
const rosgraph::msg::Clock& data,
|
||||||
|
size_t current_alignment = 0);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief This function serializes an object using CDR serialization.
|
||||||
|
* @param cdr CDR serialization object.
|
||||||
|
*/
|
||||||
|
eProsima_user_DllExport void serialize(
|
||||||
|
eprosima::fastcdr::Cdr& cdr) const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief This function deserializes an object using CDR serialization.
|
||||||
|
* @param cdr CDR serialization object.
|
||||||
|
*/
|
||||||
|
eProsima_user_DllExport void deserialize(
|
||||||
|
eprosima::fastcdr::Cdr& cdr);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief This function returns the maximum serialized size of the Key of an object
|
||||||
|
* depending on the buffer alignment.
|
||||||
|
* @param current_alignment Buffer alignment.
|
||||||
|
* @return Maximum serialized size.
|
||||||
|
*/
|
||||||
|
eProsima_user_DllExport static size_t getKeyMaxCdrSerializedSize(
|
||||||
|
size_t current_alignment = 0);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief This function tells you if the Key has been defined for this type
|
||||||
|
*/
|
||||||
|
eProsima_user_DllExport static bool isKeyDefined();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief This function serializes the key members of an object using CDR serialization.
|
||||||
|
* @param cdr CDR serialization object.
|
||||||
|
*/
|
||||||
|
eProsima_user_DllExport void serializeKey(
|
||||||
|
eprosima::fastcdr::Cdr& cdr) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
builtin_interfaces::msg::Time m_clock;
|
||||||
|
};
|
||||||
|
} // namespace msg
|
||||||
|
} // namespace rosgraph
|
||||||
|
|
||||||
|
#endif // _FAST_DDS_GENERATED_ROSGRAPH_MSG_CLOCK_H_
|
|
@ -0,0 +1,172 @@
|
||||||
|
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima).
|
||||||
|
//
|
||||||
|
// 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.
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @file ClockPubSubTypes.cpp
|
||||||
|
* This header file contains the implementation of the serialization functions.
|
||||||
|
*
|
||||||
|
* This file was generated by the tool fastcdrgen.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <fastcdr/FastBuffer.h>
|
||||||
|
#include <fastcdr/Cdr.h>
|
||||||
|
|
||||||
|
#include "ClockPubSubTypes.h"
|
||||||
|
|
||||||
|
using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t;
|
||||||
|
using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t;
|
||||||
|
|
||||||
|
namespace rosgraph {
|
||||||
|
namespace msg {
|
||||||
|
ClockPubSubType::ClockPubSubType()
|
||||||
|
{
|
||||||
|
setName("rosgraph::msg::dds_::Clock_");
|
||||||
|
auto type_size = Clock::getMaxCdrSerializedSize();
|
||||||
|
type_size += eprosima::fastcdr::Cdr::alignment(type_size, 4); /* possible submessage alignment */
|
||||||
|
m_typeSize = static_cast<uint32_t>(type_size) + 4; /*encapsulation*/
|
||||||
|
m_isGetKeyDefined = Clock::isKeyDefined();
|
||||||
|
size_t keyLength = Clock::getKeyMaxCdrSerializedSize() > 16 ?
|
||||||
|
Clock::getKeyMaxCdrSerializedSize() : 16;
|
||||||
|
m_keyBuffer = reinterpret_cast<unsigned char*>(malloc(keyLength));
|
||||||
|
memset(m_keyBuffer, 0, keyLength);
|
||||||
|
}
|
||||||
|
|
||||||
|
ClockPubSubType::~ClockPubSubType()
|
||||||
|
{
|
||||||
|
if (m_keyBuffer != nullptr)
|
||||||
|
{
|
||||||
|
free(m_keyBuffer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ClockPubSubType::serialize(
|
||||||
|
void* data,
|
||||||
|
SerializedPayload_t* payload)
|
||||||
|
{
|
||||||
|
Clock* p_type = static_cast<Clock*>(data);
|
||||||
|
|
||||||
|
// Object that manages the raw buffer.
|
||||||
|
eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(payload->data), payload->max_size);
|
||||||
|
// Object that serializes the data.
|
||||||
|
eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, eprosima::fastcdr::Cdr::DDS_CDR);
|
||||||
|
payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Serialize encapsulation
|
||||||
|
ser.serialize_encapsulation();
|
||||||
|
// Serialize the object.
|
||||||
|
p_type->serialize(ser);
|
||||||
|
}
|
||||||
|
catch (eprosima::fastcdr::exception::Exception& /*exception*/)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the serialized length
|
||||||
|
payload->length = static_cast<uint32_t>(ser.getSerializedDataLength());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ClockPubSubType::deserialize(
|
||||||
|
SerializedPayload_t* payload,
|
||||||
|
void* data)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Convert DATA to pointer of your type
|
||||||
|
Clock* p_type = static_cast<Clock*>(data);
|
||||||
|
|
||||||
|
// Object that manages the raw buffer.
|
||||||
|
eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(payload->data), payload->length);
|
||||||
|
|
||||||
|
// Object that deserializes the data.
|
||||||
|
eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, eprosima::fastcdr::Cdr::DDS_CDR);
|
||||||
|
|
||||||
|
// Deserialize encapsulation.
|
||||||
|
deser.read_encapsulation();
|
||||||
|
payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE;
|
||||||
|
|
||||||
|
// Deserialize the object.
|
||||||
|
p_type->deserialize(deser);
|
||||||
|
}
|
||||||
|
catch (eprosima::fastcdr::exception::Exception& /*exception*/)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::function<uint32_t()> ClockPubSubType::getSerializedSizeProvider(
|
||||||
|
void* data)
|
||||||
|
{
|
||||||
|
return [data]() -> uint32_t
|
||||||
|
{
|
||||||
|
return static_cast<uint32_t>(type::getCdrSerializedSize(*static_cast<Clock*>(data))) +
|
||||||
|
4u /*encapsulation*/;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
void* ClockPubSubType::createData()
|
||||||
|
{
|
||||||
|
return reinterpret_cast<void*>(new Clock());
|
||||||
|
}
|
||||||
|
|
||||||
|
void ClockPubSubType::deleteData(
|
||||||
|
void* data)
|
||||||
|
{
|
||||||
|
delete(reinterpret_cast<Clock*>(data));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ClockPubSubType::getKey(
|
||||||
|
void* data,
|
||||||
|
InstanceHandle_t* handle,
|
||||||
|
bool force_md5)
|
||||||
|
{
|
||||||
|
if (!m_isGetKeyDefined)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Clock* p_type = static_cast<Clock*>(data);
|
||||||
|
|
||||||
|
// Object that manages the raw buffer.
|
||||||
|
eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(m_keyBuffer),
|
||||||
|
Clock::getKeyMaxCdrSerializedSize());
|
||||||
|
|
||||||
|
// Object that serializes the data.
|
||||||
|
eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS);
|
||||||
|
p_type->serializeKey(ser);
|
||||||
|
if (force_md5 || Clock::getKeyMaxCdrSerializedSize() > 16)
|
||||||
|
{
|
||||||
|
m_md5.init();
|
||||||
|
m_md5.update(m_keyBuffer, static_cast<unsigned int>(ser.getSerializedDataLength()));
|
||||||
|
m_md5.finalize();
|
||||||
|
for (uint8_t i = 0; i < 16; ++i)
|
||||||
|
{
|
||||||
|
handle->value[i] = m_md5.digest[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (uint8_t i = 0; i < 16; ++i)
|
||||||
|
{
|
||||||
|
handle->value[i] = m_keyBuffer[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} //End of namespace msg
|
||||||
|
} //End of namespace rosgraph
|
|
@ -0,0 +1,105 @@
|
||||||
|
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima).
|
||||||
|
//
|
||||||
|
// 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.
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @file ClockPubSubTypes.h
|
||||||
|
* This header file contains the declaration of the serialization functions.
|
||||||
|
*
|
||||||
|
* This file was generated by the tool fastcdrgen.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _FAST_DDS_GENERATED_ROSGRAPH_MSG_CLOCK_PUBSUBTYPES_H_
|
||||||
|
#define _FAST_DDS_GENERATED_ROSGRAPH_MSG_CLOCK_PUBSUBTYPES_H_
|
||||||
|
|
||||||
|
#include <fastdds/dds/topic/TopicDataType.hpp>
|
||||||
|
#include <fastrtps/utils/md5.h>
|
||||||
|
|
||||||
|
#include "Clock.h"
|
||||||
|
|
||||||
|
#if !defined(GEN_API_VER) || (GEN_API_VER != 1)
|
||||||
|
#error \
|
||||||
|
Generated Clock is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen.
|
||||||
|
#endif // GEN_API_VER
|
||||||
|
|
||||||
|
namespace rosgraph
|
||||||
|
{
|
||||||
|
namespace msg
|
||||||
|
{
|
||||||
|
/*!
|
||||||
|
* @brief This class represents the TopicDataType of the type Clock defined by the user in the IDL file.
|
||||||
|
* @ingroup Clock
|
||||||
|
*/
|
||||||
|
class ClockPubSubType : public eprosima::fastdds::dds::TopicDataType
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
typedef Clock type;
|
||||||
|
|
||||||
|
eProsima_user_DllExport ClockPubSubType();
|
||||||
|
|
||||||
|
eProsima_user_DllExport virtual ~ClockPubSubType() override;
|
||||||
|
|
||||||
|
eProsima_user_DllExport virtual bool serialize(
|
||||||
|
void* data,
|
||||||
|
eprosima::fastrtps::rtps::SerializedPayload_t* payload) override;
|
||||||
|
|
||||||
|
eProsima_user_DllExport virtual bool deserialize(
|
||||||
|
eprosima::fastrtps::rtps::SerializedPayload_t* payload,
|
||||||
|
void* data) override;
|
||||||
|
|
||||||
|
eProsima_user_DllExport virtual std::function<uint32_t()> getSerializedSizeProvider(
|
||||||
|
void* data) override;
|
||||||
|
|
||||||
|
eProsima_user_DllExport virtual bool getKey(
|
||||||
|
void* data,
|
||||||
|
eprosima::fastrtps::rtps::InstanceHandle_t* ihandle,
|
||||||
|
bool force_md5 = false) override;
|
||||||
|
|
||||||
|
eProsima_user_DllExport virtual void* createData() override;
|
||||||
|
|
||||||
|
eProsima_user_DllExport virtual void deleteData(
|
||||||
|
void* data) override;
|
||||||
|
|
||||||
|
#ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED
|
||||||
|
eProsima_user_DllExport inline bool is_bounded() const override
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED
|
||||||
|
|
||||||
|
#ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN
|
||||||
|
eProsima_user_DllExport inline bool is_plain() const override
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // TOPIC_DATA_TYPE_API_HAS_IS_PLAIN
|
||||||
|
|
||||||
|
#ifdef TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE
|
||||||
|
eProsima_user_DllExport inline bool construct_sample(
|
||||||
|
void* memory) const override
|
||||||
|
{
|
||||||
|
(void)memory;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE
|
||||||
|
MD5 m_md5;
|
||||||
|
unsigned char* m_keyBuffer;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // _FAST_DDS_GENERATED_ROSGRAPH_MSG_CLOCK_PUBSUBTYPES_H_
|
Loading…
Reference in New Issue