Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[XRCE-DDS] 开发问题记录 #8

Open
kurisaW opened this issue Nov 20, 2023 · 7 comments
Open

[XRCE-DDS] 开发问题记录 #8

kurisaW opened this issue Nov 20, 2023 · 7 comments

Comments

@kurisaW
Copy link
Owner

kurisaW commented Nov 20, 2023

参考链接:

@kurisaW
Copy link
Owner Author

kurisaW commented Nov 20, 2023

问题描述:本地安装agent在最后的make install报错:

oXRCEAgent: error while loading shared libraries: libmicroxrcedds_agent.so.2.4: cannot open shared object file: No such file or directory

解决步骤

根据链接说明,在运行Agent之前需要先添加 /usr/local/lib 到动态加载器链接器目录

sudo ldconfig /usr/local/lib/

image

@kurisaW
Copy link
Owner Author

kurisaW commented Nov 24, 2023

几个必备的准备工作

@kurisaW kurisaW changed the title [XRCE-DDS] 开发记录 [XRCE-DDS] 开发问题记录 Nov 27, 2023
@kurisaW
Copy link
Owner Author

kurisaW commented Nov 27, 2023

Micro XRCE-DDS Gen tool 如何使用

/home/kurisaw/microros_ws/XRCE-DDS/Micro-XRCE-DDS-Gen/scripts/microxrceddsgen ShapeType.idl

它将生成以下头文件及其相应的源代码:

/*!
 * @file ShapeType.h
 * This header file contains the declaration of the described types in the IDL file.
 *
 * This file was generated by the tool gen.
 */

#ifndef _ShapeType_H_
#define _ShapeType_H_

#include <stdint.h>
#include <stdbool.h>

/*!
 * @brief This struct represents the structure ShapeType defined by the user in the IDL file.
 * @ingroup SHAPETYPE
 */
typedef struct ShapeType
{
    char color[255];
    int32_t x;
    int32_t y;
    int32_t shapesize;

} ShapeType;

struct ucdrBuffer;

bool ShapeType_serialize_topic(struct ucdrBuffer* writer, const ShapeType* topic);
bool ShapeType_deserialize_topic(struct ucdrBuffer* reader, ShapeType* topic);
uint32_t ShapeType_size_of_topic(const ShapeType* topic, uint32_t size);

#endif // _ShapeType_H_

eProsima Micro XRCE-DDS Gen还能够通过添加标志来生成与 IDL 文件中指定的主题相关的发布者和订阅者-example源代码示例:

microxrceddsgen -example <file.idl>

客户端库必须使用发布者WRITE_ACCESS_PROFILE选项进行编译,才能使用这些示例和订阅者选项。

READ_ACCESS_PROFILE

@kurisaW
Copy link
Owner Author

kurisaW commented Nov 27, 2023

基于Agent运行一个简单的发布订阅示例

1.运行Agent

sudo ldconfig /usr/local/lib/

cd /usr/local/bin && MicroXRCEAgent udp4 -p 2019

2.发布者应用程序

cd /home/kurisaw/microros_ws/XRCE-DDS/Micro-XRCE-DDS-Client
cd build
cmake .. -DUCLIENT_BUILD_EXAMPLES=ON # 启用-DUCLIENT_BUILD_EXAMPLES表示激活示例的编译
make

/home/kurisaw/microros_ws/XRCE-DDS/Micro-XRCE-DDS-Client/build/examples/PublishHelloWorld/PublishHelloWorldClient 127.0.0.1 2019

3.订阅者应用程序

/home/kurisaw/microros_ws/XRCE-DDS/Micro-XRCE-DDS-Client/build/examples/SubscribeHelloWorld/SubscribeHelloWorldClient 127.0.0.1 2019

image

@kurisaW
Copy link
Owner Author

kurisaW commented Dec 1, 2023

xrce-dds-client链接问题

  • micro-xrce-dds-client branch : foxy-bb
  • micro_rtt_component_packages : foxy-bb

链接信息:

image

@kurisaW
Copy link
Owner Author

kurisaW commented Dec 5, 2023

cmake目录深度过大导致编译存在失败的可能

解决办法:将原本cmake编译所需的包含文件提取出来,放在cmake build文件同级下

D:/Desktop/rt-thread/bsp/stm32/stm32f407-rt-spark/packages/micro_ros_rtthread_component/builder/micro/mcu/src/Micro-XRCE-DDS-Client/src/c/util/time.c: In function 'uxr_nanos':
D:/Desktop/rt-thread/bsp/stm32/stm32f407-rt-spark/packages/micro_ros_rtthread_component/builder/micro/mcu/src/Micro-XRCE-DDS-Client/src/c/util/time.c:62:19: warning: conversion to 'int64_t' {aka 'long long int'} from 'uint64_t' {aka 'long long unsigned int'} may change the sign of the result [-Wsign-conversion]
   62 |     return now_ms * 1000000;
      |            ~~~~~~~^~~~~~~~~
D:/Desktop/rt-thread/bsp/stm32/stm32f407-rt-spark/packages/micro_ros_rtthread_component/builder/micro/mcu/src/Micro-XRCE-DDS-Client/src/c/profile/transport/ip/udp/udp_transport_rtthread.c: In function 'uxr_init_udp_platform':
D:/Desktop/rt-thread/bsp/stm32/stm32f407-rt-spark/packages/micro_ros_rtthread_component/builder/micro/mcu/src/Micro-XRCE-DDS-Client/src/c/profile/transport/ip/udp/udp_transport_rtthread.c:41:38: warning: conversion to 'long unsigned int' from 'int' may change the sign of the result [-Wsign-conversion]
   41 |     platform->server_addr.sin_port = htons(atoi(port));
      |                                      ^~~~~
D:/Desktop/rt-thread/bsp/stm32/stm32f407-rt-spark/packages/micro_ros_rtthread_component/builder/micro/mcu/src/Micro-XRCE-DDS-Client/src/c/profile/transport/ip/udp/udp_transport_rtthread.c:41:38: warning: conversion to 'long unsigned int' from 'int' may change the sign of the result [-Wsign-conversion]
D:/Desktop/rt-thread/bsp/stm32/stm32f407-rt-spark/packages/micro_ros_rtthread_component/builder/micro/mcu/src/Micro-XRCE-DDS-Client/src/c/profile/transport/ip/udp/udp_transport_rtthread.c:42:40: warning: cast increases required alignment of target type [-Wcast-align]
   42 |     platform->server_addr.sin_addr = *((struct in_addr *)host->h_addr);
      |                                        ^
D:/Desktop/rt-thread/bsp/stm32/stm32f407-rt-spark/packages/micro_ros_rtthread_component/builder/micro/mcu/src/Micro-XRCE-DDS-Client/src/c/profile/transport/ip/udp/udp_transport_rtthread.c: In function 'uxr_read_udp_data_platform':
D:/Desktop/rt-thread/bsp/stm32/stm32f407-rt-spark/packages/micro_ros_rtthread_component/builder/micro/mcu/src/Micro-XRCE-DDS-Client/src/c/profile/transport/ip/udp/udp_transport_rtthread.c:106:5: warning: conversion to 'unsigned int' from 'int' may change the sign of the result [-Wsign-conversion]
  106 |     FD_SET(platform->sock, &readset);
      |     ^~~~~~
D:/Desktop/rt-thread/bsp/stm32/stm32f407-rt-spark/packages/micro_ros_rtthread_component/builder/micro/mcu/src/Micro-XRCE-DDS-Client/src/c/profile/transport/ip/udp/udp_transport_rtthread.c:106:5: warning: conversion to 'unsigned int' from 'int' may change the sign of the result [-Wsign-conversion]
In file included from D:/Desktop/rt-thread/components/net/netdev/include/arpa/inet.h:14,
                 from D:/Desktop/rt-thread/bsp/stm32/stm32f407-rt-spark/packages/micro_ros_rtthread_component/builder/micro/mcu/src/Micro-XRCE-DDS-Client/src/c/profile/transport/ip/ip_rtthread.c:4:
D:/Desktop/rt-thread/bsp/stm32/stm32f407-rt-spark/packages/micro_ros_rtthread_component/builder/micro/mcu/src/Micro-XRCE-DDS-Client/src/c/profile/transport/ip/ip_rtthread.c: In function 'uxr_locator_to_ip':
D:/Desktop/rt-thread/bsp/stm32/stm32f407-rt-spark/packages/micro_ros_rtthread_component/builder/micro/mcu/src/Micro-XRCE-DDS-Client/src/c/profile/transport/ip/ip_rtthread.c:45:89: warning: conversion to 'int32_t' {aka 'long int'} from 'long unsigned int' may change the sign of the result [-Wsign-conversion]
   45 |             result = (NULL != inet_ntop(AF_INET, locator->_.medium_locator.address, ip, (socklen_t)size));
      |                                                                                         ^~~~~~~~~~~~~~~
D:/Desktop/rt-thread/bsp/stm32/stm32f407-rt-spark/packages/micro_ros_rtthread_component/builder/micro/mcu/src/Micro-XRCE-DDS-Client/src/c/profile/transport/ip/ip_rtthread.c:50:89: warning: conversion to 'int32_t' {aka 'long int'} from 'long unsigned int' may change the sign of the result [-Wsign-conversion]
   50 |             result = (NULL != inet_ntop(AF_INET6, locator->_.large_locator.address, ip, (socklen_t)size));
      |

@kurisaW
Copy link
Owner Author

kurisaW commented Apr 11, 2024

lang@desktop:~/Desktop/microros_ws$ ros2 run micro_ros_setup build_firmware.sh
Compiling for host environment: not cleaning path
Building firmware for host platform generic
Package 'rosidl_typesupport_microxrcedds_c' specified with --packages-up-to was not found
lang@desktop:~/Desktop/microros_ws$ sudo apt install ros-foxy-rosidl-typesupport-microxrcedds-c
正在读取软件包列表... 完成
正在分析软件包的依赖关系树
正在读取状态信息... 完成
E: 无法定位软件包 ros-foxy-rosidl-typesupport-microxrcedds-c

如果遇到上述问题可参考该方式:https://blog.csdn.net/qq_43006346/article/details/135479183

然后回到工作区,执行如下命令:

sudo rm -r firmware/

colcon build
source install/local_setup.bash
ros2 run micro_ros_setup create_firmware_ws.sh host

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant