Skip to content

Commit

Permalink
Release v2.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
pablogs9 authored Mar 10, 2022
2 parents 91986fa + 08a762d commit 22587ee
Show file tree
Hide file tree
Showing 12 changed files with 170 additions and 36 deletions.
20 changes: 15 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@ option(BUILD_SHARED_LIBS "Control shared/static building." ON)

option(UAGENT_USE_SYSTEM_FASTDDS "Force find and use system installed Fast-DDS." OFF)
option(UAGENT_USE_SYSTEM_FASTCDR "Force find and use system installed Fast-CDR." OFF)
option(UAGENT_USE_SYSTEM_LOGGER "Force find and use system installed spdlog." OFF)
option(UAGENT_FAST_PROFILE "Build FastMiddleware profile." ON)
option(UAGENT_CED_PROFILE "Build CedMiddleware profile." ON)
option(UAGENT_DISCOVERY_PROFILE "Build Discovery profile." ON)
option(UAGENT_P2P_PROFILE "Build P2P discovery profile." ON)
option(UAGENT_SOCKETCAN_PROFILE "Build Agent CAN FD transport." ON)
option(UAGENT_LOGGER_PROFILE "Build logger profile." ON)
option(UAGENT_SECURITY_PROFILE "Build security profile." OFF)
option(UAGENT_BUILD_EXECUTABLE "Build Micro XRCE-DDS Agent provided executable." ON)
Expand All @@ -54,6 +56,10 @@ if((CMAKE_SYSTEM_NAME STREQUAL "") AND (NOT CMAKE_HOST_SYSTEM_NAME STREQUAL "Lin
set(UAGENT_P2P_PROFILE OFF)
endif()

if((CMAKE_SYSTEM_NAME STREQUAL "Darwin") OR (CMAKE_SYSTEM_NAME STREQUAL "Windows"))
set(UAGENT_SOCKETCAN_PROFILE OFF)
endif()

set(UAGENT_CONFIG_RELIABLE_STREAM_DEPTH 16 CACHE STRING "Reliable streams depth.")
set(UAGENT_CONFIG_BEST_EFFORT_STREAM_DEPTH 16 CACHE STRING "Best-effort streams depth.")
set(UAGENT_CONFIG_HEARTBEAT_PERIOD 200 CACHE STRING "Heartbeat period in milliseconds.")
Expand Down Expand Up @@ -97,8 +103,12 @@ if(UAGENT_FAST_PROFILE)
endif()

if(UAGENT_LOGGER_PROFILE)
set(_spdlog_version 1.4.2)
set(_spdlog_tag v1.4.2)
if(UAGENT_USE_SYSTEM_LOGGER)
set(_spdlog_version 1)
else()
set(_spdlog_version 1.9.2)
set(_spdlog_tag v1.9.2)
endif()
list(APPEND _deps "spdlog\;${_spdlog_version}")
endif()

Expand All @@ -107,7 +117,7 @@ endif()
###############################################################################
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules)
if(NOT UAGENT_SUPERBUILD)
project(microxrcedds_agent VERSION "2.1.0" LANGUAGES C CXX)
project(microxrcedds_agent VERSION "2.1.1" LANGUAGES C CXX)
else()
project(uagent_superbuild NONE)
include(${PROJECT_SOURCE_DIR}/cmake/SuperBuild.cmake)
Expand Down Expand Up @@ -147,18 +157,18 @@ endforeach()
# Sources
###############################################################################
# Check platform.
if(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "Android")
if(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "Android" OR CMAKE_SYSTEM_NAME STREQUAL "Darwin")
set(TRANSPORT_SRCS
src/cpp/transport/udp/UDPv4AgentLinux.cpp
src/cpp/transport/udp/UDPv6AgentLinux.cpp
src/cpp/transport/tcp/TCPv4AgentLinux.cpp
src/cpp/transport/tcp/TCPv6AgentLinux.cpp
src/cpp/transport/can/CanAgentLinux.cpp
src/cpp/transport/serial/SerialAgentLinux.cpp
src/cpp/transport/serial/TermiosAgentLinux.cpp
src/cpp/transport/serial/MultiSerialAgentLinux.cpp
src/cpp/transport/serial/MultiTermiosAgentLinux.cpp
src/cpp/transport/serial/PseudoTerminalAgentLinux.cpp
$<$<BOOL:${UAGENT_SOCKETCAN_PROFILE}>:src/cpp/transport/can/CanAgentLinux.cpp>
$<$<BOOL:${UAGENT_DISCOVERY_PROFILE}>:src/cpp/transport/discovery/DiscoveryServerLinux.cpp>
$<$<BOOL:${UAGENT_P2P_PROFILE}>:src/cpp/transport/p2p/AgentDiscovererLinux.cpp>
)
Expand Down
4 changes: 2 additions & 2 deletions cmake/SuperBuild.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ if(UAGENT_FAST_PROFILE AND NOT UAGENT_USE_SYSTEM_FASTDDS)
endif()
endif()

if(UAGENT_LOGGER_PROFILE)
if(UAGENT_LOGGER_PROFILE AND NOT UAGENT_USE_SYSTEM_LOGGER)
# spdlog.
unset(spdlog_DIR CACHE)
find_package(spdlog ${_spdlog_version} EXACT QUIET)
Expand All @@ -172,7 +172,7 @@ if(UAGENT_LOGGER_PROFILE)
CMAKE_CACHE_ARGS
-DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
-DCMAKE_PREFIX_PATH:PATH=${CMAKE_PREFIX_PATH};${CMAKE_INSTALL_PREFIX}
-DBUILD_SHARED_LIBS:BOOL=${BUILD_SHARED_LIBS}
-DBUILD_SHARED_LIBS:BOOL=OFF
-DCMAKE_TOOLCHAIN_FILE:PATH=${CMAKE_TOOLCHAIN_FILE}
${CROSS_CMAKE_ARGS}
-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
Expand Down
1 change: 1 addition & 0 deletions include/uxr/agent/config.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ namespace uxr {
#ifdef UAGENT_CED_PROFILE
#cmakedefine UAGENT_P2P_PROFILE
#endif
#cmakedefine UAGENT_SOCKETCAN_PROFILE
#cmakedefine UAGENT_LOGGER_PROFILE

const uint16_t DISCOVERY_PORT = 7400;
Expand Down
2 changes: 2 additions & 0 deletions include/uxr/agent/transport/serial/baud_rate_table_linux.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ speed_t getBaudRate(const char* baudrate_str)
{
rv = B230400;
}
#ifndef __APPLE__
else if (0 == strcmp(baudrate_str, "460800"))
{
rv = B460800;
Expand Down Expand Up @@ -148,6 +149,7 @@ speed_t getBaudRate(const char* baudrate_str)
{
rv = B4000000;
}
#endif // __APPLE__
else
{
speed_t custom_baud_rate = (speed_t)atoi(baudrate_str);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
#ifdef _WIN32
#include <BaseTsd.h>
typedef SSIZE_T ssize_t;
#else
#include <sys/types.h>
#endif

namespace eprosima {
Expand Down
21 changes: 19 additions & 2 deletions include/uxr/agent/utils/ArgumentParser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <type_traits>
#include <unordered_map>
#include <uxr/agent/transport/Server.hpp>
#include <uxr/agent/config.hpp>

#ifdef _WIN32
#include <uxr/agent/transport/udp/UDPv4AgentWindows.hpp>
Expand All @@ -33,12 +34,15 @@
#include <uxr/agent/transport/udp/UDPv6AgentLinux.hpp>
#include <uxr/agent/transport/tcp/TCPv4AgentLinux.hpp>
#include <uxr/agent/transport/tcp/TCPv6AgentLinux.hpp>
#include <uxr/agent/transport/can/CanAgentLinux.hpp>
#include <uxr/agent/transport/serial/TermiosAgentLinux.hpp>
#include <uxr/agent/transport/serial/MultiTermiosAgentLinux.hpp>
#include <uxr/agent/transport/serial/PseudoTerminalAgentLinux.hpp>
#include <uxr/agent/transport/serial/baud_rate_table_linux.h>

#ifdef UAGENT_SOCKETCAN_PROFILE
#include <uxr/agent/transport/can/CanAgentLinux.hpp>
#endif // UAGENT_SOCKETCAN_PROFILE

#include <termios.h>
#include <fcntl.h>
#include <sys/stat.h>
Expand All @@ -61,7 +65,9 @@ enum class TransportKind
TCP4,
TCP6,
#ifndef _WIN32
#ifdef UAGENT_SOCKETCAN_PROFILE
CAN,
#endif // UAGENT_SOCKETCAN_PROFILE
SERIAL,
MULTISERIAL,
PSEUDOTERMINAL,
Expand Down Expand Up @@ -867,7 +873,7 @@ class MultiSerialArgs : public PseudoTerminalArgs<AgentType>
Argument<std::string> file_;
};


#ifdef UAGENT_SOCKETCAN_PROFILE
/*************************************************************************************************
* Specific arguments for CAN transports
*************************************************************************************************/
Expand Down Expand Up @@ -919,6 +925,7 @@ class CanArgs
Argument<std::string> dev_;
Argument<std::string> can_id_;
};
#endif // UAGENT_SOCKETCAN_PROFILE
#endif // _WIN32

/*************************************************************************************************
Expand All @@ -937,7 +944,9 @@ class ArgumentParser
, common_args_()
, ip_args_()
#ifndef _WIN32
#ifdef UAGENT_SOCKETCAN_PROFILE
, can_args_()
#endif // UAGENT_SOCKETCAN_PROFILE
, serial_args_()
, multiserial_args_()
, pseudoterminal_args_()
Expand Down Expand Up @@ -971,11 +980,13 @@ class ArgumentParser
break;
}
#ifndef _WIN32
#ifdef UAGENT_SOCKETCAN_PROFILE
case TransportKind::CAN:
{
result &= can_args_.parse(argc_, argv_);
break;
}
#endif // UAGENT_SOCKETCAN_PROFILE
case TransportKind::SERIAL:
{
result &= serial_args_.parse(argc_, argv_);
Expand Down Expand Up @@ -1081,8 +1092,10 @@ class ArgumentParser
ss << " * SERIAL (serial, multiserial, pseudoterminal)" << std::endl;
ss << pseudoterminal_args_.get_help();
ss << serial_args_.get_help();
#ifdef UAGENT_SOCKETCAN_PROFILE
ss << " * CAN FD (canfd)" << std::endl;
ss << can_args_.get_help();
#endif // UAGENT_SOCKETCAN_PROFILE
#endif // _WIN32
ss << std::endl;
// TODO(@jamoralp): Once documentation is updated with proper CLI section, add here an hyperlink to that section
Expand All @@ -1095,7 +1108,9 @@ class ArgumentParser
CommonArgs<AgentType> common_args_;
IPvXArgs<AgentType> ip_args_;
#ifndef _WIN32
#ifdef UAGENT_SOCKETCAN_PROFILE
CanArgs<AgentType> can_args_;
#endif // UAGENT_SOCKETCAN_PROFILE
SerialArgs<AgentType> serial_args_;
MultiSerialArgs<AgentType> multiserial_args_;
PseudoTerminalArgs<AgentType> pseudoterminal_args_;
Expand Down Expand Up @@ -1162,6 +1177,7 @@ template<> inline bool ArgumentParser<PseudoTerminalAgent>::launch_agent()
return false;
}

#ifdef UAGENT_SOCKETCAN_PROFILE
template<> inline bool ArgumentParser<CanAgent>::launch_agent()
{
uint32_t can_id = strtoul(can_args_.can_id().c_str(), NULL, 16);
Expand All @@ -1179,6 +1195,7 @@ template<> inline bool ArgumentParser<CanAgent>::launch_agent()

return false;
}
#endif // UAGENT_SOCKETCAN_PROFILE
#endif // _WIN32

} // namespace parser
Expand Down
3 changes: 3 additions & 0 deletions src/cpp/AgentInstance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include <uxr/agent/config.hpp>
#include <uxr/agent/AgentInstance.hpp>
#include <uxr/agent/middleware/utils/Callbacks.hpp>

Expand Down Expand Up @@ -64,11 +65,13 @@ bool AgentInstance::create(
break;
}
#ifndef _WIN32
#ifdef UAGENT_SOCKETCAN_PROFILE
case agent::TransportKind::CAN:
{
agent_thread_ = std::move(agent::create_agent_thread<CanAgent>(argc, argv, exit_signal, valid_transport));
break;
}
#endif // UAGENT_SOCKETCAN_PROFILE
case agent::TransportKind::SERIAL:
{
agent_thread_ = std::move(agent::create_agent_thread<TermiosAgent>(argc, argv, exit_signal, valid_transport));
Expand Down
79 changes: 78 additions & 1 deletion src/cpp/middleware/fastdds/FastDDSEntities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,16 @@ static void set_qos_from_xrce_object(
**********************************************************************************************************************/
FastDDSParticipant::~FastDDSParticipant()
{
factory_->delete_participant(ptr_);
if (ptr_)
{
// TODO: Not available on foxy (Need FastDDS >= 2.2.0 for declaration and FastDDS >= 2.4.1 for implementation)
// if (ptr_->has_active_entities())
{
// ptr_->delete_contained_entities();
}

factory_->delete_participant(ptr_);
}
}

bool FastDDSParticipant::create_by_ref(
Expand Down Expand Up @@ -489,6 +498,35 @@ fastdds::dds::Publisher* FastDDSParticipant::create_publisher(
ReturnCode_t FastDDSParticipant::delete_publisher(
fastdds::dds::Publisher* publisher)
{
if (NULL == publisher)
{
return ReturnCode_t::RETCODE_ALREADY_DELETED;
}

if (publisher->has_datawriters())
{
ReturnCode_t ret = ReturnCode_t::RETCODE_OK;

// TODO: Not available on foxy (Need FastDDS >= 2.2.0 for declaration and FastDDS >= 2.4.1 for implementation)
// ret = publisher->delete_contained_entities();

//if (ReturnCode_t::RETCODE_UNSUPPORTED == ret)
{
std::vector<eprosima::fastdds::dds::DataWriter*> writers;
publisher->get_datawriters(writers);

for (auto datawriter : writers)
{
ret = publisher->delete_datawriter(datawriter);

if (ReturnCode_t::RETCODE_OK != ret)
{
return ret;
}
}
}
}

return ptr_->delete_publisher(publisher);
}

Expand All @@ -503,6 +541,35 @@ fastdds::dds::Subscriber* FastDDSParticipant::create_subscriber(
ReturnCode_t FastDDSParticipant::delete_subscriber(
fastdds::dds::Subscriber* subscriber)
{
if (NULL == subscriber)
{
return ReturnCode_t::RETCODE_ALREADY_DELETED;
}

if (subscriber->has_datareaders())
{
ReturnCode_t ret = ReturnCode_t::RETCODE_OK;

// TODO: Not available on foxy (Need FastDDS >= 2.2.0 for declaration and FastDDS >= 2.4.1 for implementation)
// ret = subscriber->delete_contained_entities();

// if (ReturnCode_t::RETCODE_UNSUPPORTED == ret)
{
std::vector<eprosima::fastdds::dds::DataReader*> readers;
subscriber->get_datareaders(readers);

for (auto datareader : readers)
{
ret = subscriber->delete_datareader(datareader);

if (ReturnCode_t::RETCODE_OK != ret)
{
return ret;
}
}
}
}

return ptr_->delete_subscriber(subscriber);
}

Expand Down Expand Up @@ -750,6 +817,11 @@ fastdds::dds::DataWriter* FastDDSPublisher::create_datawriter(
ReturnCode_t FastDDSPublisher::delete_datawriter(
fastdds::dds::DataWriter* writer)
{
if (NULL == writer)
{
return ReturnCode_t::RETCODE_ALREADY_DELETED;
}

return ptr_->delete_datawriter(writer);
}

Expand Down Expand Up @@ -809,6 +881,11 @@ fastdds::dds::DataReader* FastDDSSubscriber::create_datareader(
ReturnCode_t FastDDSSubscriber::delete_datareader(
fastdds::dds::DataReader* reader)
{
if (NULL == reader)
{
return ReturnCode_t::RETCODE_ALREADY_DELETED;
}

return ptr_->delete_datareader(reader);
}

Expand Down
10 changes: 10 additions & 0 deletions src/cpp/processor/Processor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -781,6 +781,16 @@ bool Processor<EndPoint>::process_get_info_packet(
dds::xrce::ResultStatus result_status = root_.get_info(object_info);
if (dds::xrce::STATUS_OK == result_status.status())
{
uint32_t raw_client_key;
if (server_.get_client_key(input_packet.source, raw_client_key))
{
result_status.implementation_status(1);
}
else
{
result_status.implementation_status(0);
}

dds::xrce::AGENT_ActivityInfo agent_info;
agent_info.availability(1);

Expand Down
Loading

0 comments on commit 22587ee

Please sign in to comment.