@小鱼 大佬,为什么我用移动起来那个激光点都对不上,老是跟着动
重要提示
提问前必看的发帖注意事项—— 提问前必看!不符合要求的问题拒绝回答!!
社区使用指南—如何添加标签修改密码
842145248 发布的帖子
-
RE: 实时速度计算-运动学正解,减速比和脉冲比计算问题
@小鱼 大佬,没看到呀,只看到
per_pulse_distance
和speed_factor
怎么计算的typedef struct { uint8_t id; // 电机编号 uint16_t reducation_ratio; // 减速器减速比,轮子转一圈,电机需要转的圈数 uint16_t pulse_ration; // 脉冲比,电机转一圈所产生的脉冲数 float wheel_diameter; // 轮子的外直径,单位mm float per_pulse_distance; // 无需配置,单个脉冲轮子前进的距离,单位mm,设置时自动计算 // 单个脉冲距离=轮子转一圈所行进的距离/轮子转一圈所产生的脉冲数 // per_pulse_distance= (wheel_diameter*3.1415926)/(pulse_ration*reducation_ratio) uint32_t speed_factor; // 无需配置,计算速度时使用的速度因子,设置时自动计算,speed_factor计算方式如下 // 设 dt(单位us,1s=1000ms=10^6us)时间内的脉冲数为dtick // 速度speed = per_pulse_distance*dtick/(dt/1000/1000)=(per_pulse_distance*1000*1000)*dtic/dt // 记 speed_factor = (per_pulse_distance*1000*1000) int16_t motor_speed; // 无需配置,当前电机速度mm/s,计算时使用 int64_t last_encoder_tick; // 无需配置,上次电机的编码器读数 uint64_t last_update_time; // 无需配置,上次更新数据的时间,单位us } motor_param_t;
设置和取值,也都是配置的默认值
float FishBotConfig::kinematics_reducation_ration() { return preferences.getString("reducate_ration", CONFIG_DEFAULT_MOTOR0_PARAM_REDUCATION_RATIO).toFloat(); } preferences.putString("reducate_ration", CONFIG_DEFAULT_MOTOR0_PARAM_REDUCATION_RATIO);
还有个问题,WIFI设置是这样吗,为什么日志输出的对不上
/*=========================================默认值定义=====================================*/ #define CONFIG_DEFAULT_TRANSPORT_MODE_WIFI_SERVER_IP "192.168.1.16" // 默认UDP服务端IP #define CONFIG_DEFAULT_TRANSPORT_MODE_WIFI_SERVER_PORT "8888" // 默认UDP服务端端口号 #define CONFIG_DEFAULT_TRANSPORT_MODE "udp_client" // 默认传输模式-udp_client模式 #define CONFIG_DEFAULT_SERIAL_ID "0" // 可选使用0或者2,使用2则需要使用GPIO16和17作为RXTX #define CONFIG_DEFAULT_TRANSPORT_SERIAL_BAUD "921600" //------------------------------------WIFI SSID----------------------------------------- #define CONFIG_DEFAULT_WIFI_STA_SSID "ChinaNet-403" #define CONFIG_DEFAULT_WIFI_STA_PSWK "15601885530@"
串口输出如下
[695649][E][WiFiUdp.cpp:185] endPacket(): could not send data: 118 ets Jul 29 2019 12:21:46 rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT) configsip: 0, SPIWP:0xee clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00 mode:DIO, clock div:1 load:0x3fff0030,len:1184 load:0x40078000,len:13260 load:0x40080400,len:3028 entry 0x400805e4 [54]@53>D:first_startup=0 ================================================= wwww.fishros.com fishbot-motion-control-v1.0.0 ================================================= [66]@53>D:first_startup=0 $first_startup=0 $serial_baud=921600 $serial_id=0 $wifi_ssid=m5 $wifi_pswd=88888888 $wifi_ap_ssid=FISHBOT_9CF4 $wifi_ap_pswd= $microros_mode=udp_client $udpserver_ip=192.168.2.105 $udpserver_port=8888 $ros2_nodename=fishbot_motion_control $ros2_namespace= $odom_topic=odom $odom_frameid=odom $odom_c_frameid=base_link $twist_topic=cmd_vel $odom_pub_period=50 $reducate_ration=40.50 $pulse_ration=44 $wheel_diameter=65 $wheel_distance=172.75 $pid_kp=0.62 $pid_ki=0.13 $pid_kd=0.00 $pid_outlimit=100.00 $board=motion_board $version=v1.1.0 [ 180][E][Wire.cpp:499] requestFrom(): i2cWriteReadNonStop returned Error -1 init motor param 0: 0.114592=65.000000*PI/(0*1078214656) speed_factor=44 init motor param 1: 0.114592=65.000000*PI/(0*1078214656) speed_factor=44 WIFI EVENT! ---- Closed serial port /dev/ttyUSB0 due to disconnection from the machine ---- ---- Reopened serial port /dev/ttyUSB0 ---- wifi connected failed! WIFI EVENT! [ 2834][E][WiFiUdp.cpp:185] endPacket(): could not send data: 118 ---- Closed the serial port /dev/ttyUSB0 ----
-
实时速度计算-运动学正解,减速比和脉冲比计算问题
@小鱼 大佬,实时速度计算-运动学正解中的
uint16_t reducation_ratio; // 减速器减速比,轮子转一圈,电机需要转的圈数 uint16_t pulse_ration; // 脉冲比,电机转一圈所产生的脉冲数
这两个值45,44是怎么计算得来的,按之前章节的脉冲测量与校准也对不上啊,没明白。
-
RE: 动手学ros2第5章进阶篇-控制OLED-自定义消息接口
@小鱼
显示的python3.10
刚刚我又卸载了一遍,卸载成功了,之前还剩个
python3.6-minimal
没卸载掉,显示的可执行文件是/usr/bin/python3.6m
, 疑惑我半天,卸载的时候没用通配符,我还以为系统自带的卸载不了。终于可以正常编译了跑起来了 ,非常感谢大佬的支持
-
RE: 动手学ros2第5章进阶篇-控制OLED-自定义消息接口
果然,我编译出来的是
*cpython-36m-x86_64-*.so
大佬,你系统里面还有python3.6吗,我尝试卸载,卸不干净 ,为什么会编python3.6啊,humble明明自带的python3.10total 136 drwxr-xr-x 4 nzb nzb 4096 10月 15 13:40 ./ drwxrwxr-x 4 nzb nzb 4096 10月 15 13:40 ../ -rw-r--r-- 1 nzb nzb 11776 10月 15 13:40 _fishbot_interfaces_s.ep.rosidl_typesupport_c.c -rw-r--r-- 1 nzb nzb 11785 10月 15 13:40 _fishbot_interfaces_s.ep.rosidl_typesupport_fastrtps_c.c -rw-r--r-- 1 nzb nzb 11790 10月 15 13:40 _fishbot_interfaces_s.ep.rosidl_typesupport_introspection_c.c -rw-r--r-- 1 nzb nzb 17632 10月 15 13:40 fishbot_interfaces_s__rosidl_typesupport_c.cpython-36m-x86_64-linux-gnu.so -rw-r--r-- 1 nzb nzb 17648 10月 15 13:40 fishbot_interfaces_s__rosidl_typesupport_fastrtps_c.cpython-36m-x86_64-linux-gnu.so -rw-r--r-- 1 nzb nzb 17664 10月 15 13:40 fishbot_interfaces_s__rosidl_typesupport_introspection_c.cpython-36m-x86_64-linux-gnu.so -rw-r--r-- 1 nzb nzb 0 10月 15 13:40 __init__.py -rw-r--r-- 1 nzb nzb 21392 10月 15 13:40 libfishbot_interfaces__rosidl_generator_py.so drwxrwxr-x 2 nzb nzb 4096 10月 15 13:40 __pycache__/ drwxr-xr-x 3 nzb nzb 4096 10月 15 13:40 srv/
-
RE: 动手学ros2第5章进阶篇-控制OLED-自定义消息接口
@小鱼
大佬,你电脑编完后的这个目录下的文件能截个图给我吗
extra_packages/install/fishbot_interfaces/local/lib/python3.10/dist-packages/fishbot_interfaces
-
RE: 动手学ros2第5章进阶篇-控制OLED-自定义消息接口
@小鱼
嗯嗯,我再找找看,非常感谢大佬的支持No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 22.04.3 LTS Release: 22.04 Codename: jammy Linux lenovo 5.15.0-82-generic #91-Ubuntu SMP Mon Aug 14 14:14:14 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
-
RE: 动手学ros2第5章进阶篇-控制OLED-自定义消息接口
@小鱼
rm -rf build install log && colcon build --packages-up-to fishbot_interfaces && source install/setup.bash
[0.467s] WARNING:colcon.colcon_ros.prefix_path.ament:The path '/home/nzb/vscode_project/cplus_demo/ros2_demo/chat13/example14_custom_interfaces/extra_packages/install/fishbot_interfaces' in the environment variable AMENT_PREFIX_PATH doesn't exist [0.468s] WARNING:colcon.colcon_ros.prefix_path.catkin:The path '/home/nzb/vscode_project/cplus_demo/ros2_demo/chat13/example14_custom_interfaces/extra_packages/install/fishbot_interfaces' in the environment variable CMAKE_PREFIX_PATH doesn't exist Starting >>> fishbot_interfaces Finished <<< fishbot_interfaces [5.13s] Summary: 1 package finished [5.37s]
ros2 service list && ros2 interface list | grep fish
/oled_control fishbot_interfaces/srv/OledControl
ros2 service call /oled_control fishbot_interfaces/srv/OledControl "{px: 0, py: 0, data: 'nihao'}"
Traceback (most recent call last): File "/opt/ros/humble/local/lib/python3.10/dist-packages/rosidl_generator_py/import_type_support_impl.py", line 46, in import_type_support return importlib.import_module(module_name, package=pkg_name) File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1050, in _gcd_import File "<frozen importlib._bootstrap>", line 1027, in _find_and_load File "<frozen importlib._bootstrap>", line 1004, in _find_and_load_unlocked ModuleNotFoundError: No module named 'fishbot_interfaces.fishbot_interfaces_s__rosidl_typesupport_c' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/opt/ros/humble/bin/ros2", line 33, in <module> sys.exit(load_entry_point('ros2cli==0.18.7', 'console_scripts', 'ros2')()) File "/opt/ros/humble/lib/python3.10/site-packages/ros2cli/cli.py", line 89, in main rc = extension.main(parser=parser, args=args) File "/opt/ros/humble/lib/python3.10/site-packages/ros2service/command/service.py", line 41, in main return extension.main(args=args) File "/opt/ros/humble/lib/python3.10/site-packages/ros2service/verb/call.py", line 58, in main return requester( File "/opt/ros/humble/lib/python3.10/site-packages/ros2service/verb/call.py", line 86, in requester cli = node.create_client(srv_module, service_name) File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/node.py", line 1413, in create_client check_is_valid_srv_type(srv_type) File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/type_support.py", line 51, in check_is_valid_srv_type check_for_type_support(srv_type) File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/type_support.py", line 29, in check_for_type_support msg_or_srv_type.__class__.__import_type_support__() File "/home/nzb/vscode_project/cplus_demo/ros2_demo/chat13/example14_custom_interfaces/extra_packages/install/fishbot_interfaces/local/lib/python3.10/dist-packages/fishbot_interfaces/srv/_oled_control.py", line 303, in __import_type_support__ module = import_type_support('fishbot_interfaces') File "/opt/ros/humble/local/lib/python3.10/dist-packages/rosidl_generator_py/import_type_support_impl.py", line 48, in import_type_support raise UnsupportedTypeSupport(pkg_name) rosidl_generator_py.import_type_support_impl.UnsupportedTypeSupport: Could not import 'rosidl_typesupport_c' for package 'fishbot_interfaces'
-
RE: 动手学ros2第5章进阶篇-控制OLED-自定义消息接口
@小鱼 鱼哥,还是不行 ,
libmicroros
删除了,重新编译,终端打印编译过程没报错,也通过了,但是中间报这种影响吗?看
libmicroros
目录下也有那个fishbot_interfaces
了
执行
ros2 service call /oled_control fishbot_interfaces/srv/OledControl "{px: 0, py: 0, data: 'nihao'}"
报错还是之前这个:Traceback (most recent call last): File "/opt/ros/humble/local/lib/python3.10/dist-packages/rosidl_generator_py/import_type_support_impl.py", line 46, in import_type_support return importlib.import_module(module_name, package=pkg_name) File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1050, in _gcd_import File "<frozen importlib._bootstrap>", line 1027, in _find_and_load File "<frozen importlib._bootstrap>", line 1004, in _find_and_load_unlocked ModuleNotFoundError: No module named 'fishbot_interfaces.fishbot_interfaces_s__rosidl_typesupport_c' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/opt/ros/humble/bin/ros2", line 33, in <module> sys.exit(load_entry_point('ros2cli==0.18.7', 'console_scripts', 'ros2')()) File "/opt/ros/humble/lib/python3.10/site-packages/ros2cli/cli.py", line 89, in main rc = extension.main(parser=parser, args=args) File "/opt/ros/humble/lib/python3.10/site-packages/ros2service/command/service.py", line 41, in main return extension.main(args=args) File "/opt/ros/humble/lib/python3.10/site-packages/ros2service/verb/call.py", line 58, in main return requester( File "/opt/ros/humble/lib/python3.10/site-packages/ros2service/verb/call.py", line 86, in requester cli = node.create_client(srv_module, service_name) File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/node.py", line 1413, in create_client check_is_valid_srv_type(srv_type) File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/type_support.py", line 51, in check_is_valid_srv_type check_for_type_support(srv_type) File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/type_support.py", line 29, in check_for_type_support msg_or_srv_type.__class__.__import_type_support__() File "/home/nzb/vscode_project/cplus_demo/ros2_demo/chat13/example14_custom_interfaces/extra_packages/install/fishbot_interfaces/local/lib/python3.10/dist-packages/fishbot_interfaces/srv/_oled_control.py", line 303, in __import_type_support__ module = import_type_support('fishbot_interfaces') File "/opt/ros/humble/local/lib/python3.10/dist-packages/rosidl_generator_py/import_type_support_impl.py", line 48, in import_type_support raise UnsupportedTypeSupport(pkg_name) rosidl_generator_py.import_type_support_impl.UnsupportedTypeSupport: Could not import 'rosidl_typesupport_c' for package 'fishbot_interfaces'
-
RE: 动手学ros2第5章进阶篇-控制OLED-自定义消息接口
@小鱼 示例也不行
* Executing task: platformio run Processing featheresp32 (platform: espressif32; board: featheresp32; framework: arduino) --------------------------------------------------------------------------------------------------------------------------------------------------- Library Manager: Installing git+https://gitee.com/ohhuo/micro_ros_platformio.git git version 2.34.1 Cloning into '/home/nzb/.platformio/.cache/tmp/pkg-installing-mkfoxl4p'... remote: Enumerating objects: 5773, done. remote: Counting objects: 100% (5773/5773), done. remote: Compressing objects: 100% (2618/2618), done. remote: Total 5773 (delta 2905), reused 5732 (delta 2883), pack-reused 0 Receiving objects: 100% (5773/5773), 19.12 MiB | 5.79 MiB/s, done. Resolving deltas: 100% (2905/2905), done. Library Manager: micro_ros_platformio@0.0.1+sha.085c5dd has been installed! Library Manager: Installing adafruit/Adafruit SSD1306 @ ^2.5.7 Unpacking [####################################] 100% Library Manager: Adafruit SSD1306@2.5.7 has been installed! Library Manager: Resolving dependencies... Library Manager: Installing Adafruit GFX Library Unpacking [####################################] 100% Library Manager: Adafruit GFX Library@1.11.8 has been installed! Library Manager: Resolving dependencies... Library Manager: Installing Adafruit BusIO Unpacking [####################################] 100% Library Manager: Adafruit BusIO@1.14.4 has been installed! Verbose mode can be enabled via `-v, --verbose` option CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/featheresp32.html PLATFORM: Espressif 32 (5.2.0) > Adafruit ESP32 Feather HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash DEBUG: Current (cmsis-dap) External (cmsis-dap, esp-bridge, esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa) PACKAGES: - framework-arduinoespressif32 @ 3.20005.220925 (2.0.5) - tool-esptoolpy @ 1.40201.0 (4.2.1) - toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch3 LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf LDF Modes: Finder ~ chain, Compatibility ~ soft Installing pyyaml with pip at PlatformIO environment /home/nzb/.platformio/penv/bin/python -m pip install pyyaml Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple Requirement already satisfied: pyyaml in /home/nzb/.platformio/penv/lib/python3.10/site-packages (6.0) [notice] A new release of pip available: 22.3.1 -> 23.2.1 [notice] To update, run: pip install --upgrade pip Installing markupsafe==2.0.1 with pip at PlatformIO environment /home/nzb/.platformio/penv/bin/python -m pip install markupsafe==2.0.1 Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple Requirement already satisfied: markupsafe==2.0.1 in /home/nzb/.platformio/penv/lib/python3.10/site-packages (2.0.1) [notice] A new release of pip available: 22.3.1 -> 23.2.1 [notice] To update, run: pip install --upgrade pip Configuring featheresp32 with transport serial micro-ROS already built Found 36 compatible libraries Scanning dependencies... Dependency Graph |-- micro_ros_platformio @ 0.0.1+sha.085c5dd |-- Adafruit SSD1306 @ 2.5.7 |-- Wire @ 2.0.0 |-- Adafruit GFX Library @ 1.11.8 Building in release mode Compiling .pio/build/featheresp32/src/main.cpp.o Building .pio/build/featheresp32/bootloader.bin Generating partitions .pio/build/featheresp32/partitions.bin esptool.py v4.2.1 Creating esp32 image... Merged 1 ELF section Successfully created esp32 image. src/main.cpp:13:10: fatal error: fishbot_interfaces/srv/oled_control.h: No such file or directory #include <fishbot_interfaces/srv/oled_control.h> // 添加接口 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ compilation terminated. Compiling .pio/build/featheresp32/lib61f/micro_ros_platformio/platform_code/arduino/clock_gettime.cpp.o Compiling .pio/build/featheresp32/lib61f/micro_ros_platformio/platform_code/arduino/serial/micro_ros_transport.cpp.o Compiling .pio/build/featheresp32/lib31c/Wire/Wire.cpp.o Compiling .pio/build/featheresp32/lib271/SPI/SPI.cpp.o Compiling .pio/build/featheresp32/libaae/Adafruit BusIO/Adafruit_BusIO_Register.cpp.o *** [.pio/build/featheresp32/src/main.cpp.o] Error 1 =========================================================== [FAILED] Took 16.30 seconds =========================================================== * The terminal process "platformio 'run'" terminated with exit code: 1. * Terminal will be reused by tasks, press any key to close it.
-
RE: 动手学ros2第5章进阶篇-控制OLED-自定义消息接口
@小鱼 删除重新编译后还不行
CMakelists.txt
cmake_minimum_required(VERSION 3.5) project(fishbot_interfaces) if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") add_compile_options(-Wall -Wextra -Wpedantic) endif() # find dependencies find_package(ament_cmake REQUIRED) # uncomment the following section in order to fill in # further dependencies manually. # find_package(<dependency> REQUIRED) if(BUILD_TESTING) find_package(ament_lint_auto REQUIRED) # the following line skips the linter which checks for copyrights # uncomment the line when a copyright and license is not present in all source files #set(ament_cmake_copyright_FOUND TRUE) # the following line skips cpplint (only works in a git repo) # uncomment the line when this package is not in a git repo #set(ament_cmake_cpplint_FOUND TRUE) ament_lint_auto_find_test_dependencies() endif() find_package(rosidl_default_generators REQUIRED) rosidl_generate_interfaces(${PROJECT_NAME} "srv/OledControl.srv" ) ament_package()
OledControl.srv
int32 px int32 py string data --- int32 result
-
RE: 动手学ros2第5章进阶篇-控制OLED-自定义消息接口
@小鱼 感谢大佬的的回复,我补充完整了
main.cpp
后可以编译了,我按照教程还没到编写main.cpp
,我以为不用先写main.cpp
,编译看看是否有错但是命令行调用服务时出现了类似这种导包问题:重新运行代码时出现:UnsupportedTypeSupport: Could not import 'rosidl_typesupport_c' for package 'village_interfaces',
CMakelist.txt
和packages.xml
,看着好像都没问题,麻烦大佬再帮我看看$ source install/setup.bash && ros2 service call /oled_control fishbot_interfaces/srv/OledControl "{px: 0, py: 0, data: 'nihao'}" Traceback (most recent call last): File "/opt/ros/humble/local/lib/python3.10/dist-packages/rosidl_generator_py/import_type_support_impl.py", line 46, in import_type_support return importlib.import_module(module_name, package=pkg_name) File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1050, in _gcd_import File "<frozen importlib._bootstrap>", line 1027, in _find_and_load File "<frozen importlib._bootstrap>", line 1004, in _find_and_load_unlocked ModuleNotFoundError: No module named 'fishbot_interfaces.fishbot_interfaces_s__rosidl_typesupport_c' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/opt/ros/humble/bin/ros2", line 33, in <module> sys.exit(load_entry_point('ros2cli==0.18.7', 'console_scripts', 'ros2')()) File "/opt/ros/humble/lib/python3.10/site-packages/ros2cli/cli.py", line 89, in main rc = extension.main(parser=parser, args=args) File "/opt/ros/humble/lib/python3.10/site-packages/ros2service/command/service.py", line 41, in main return extension.main(args=args) File "/opt/ros/humble/lib/python3.10/site-packages/ros2service/verb/call.py", line 58, in main return requester( File "/opt/ros/humble/lib/python3.10/site-packages/ros2service/verb/call.py", line 86, in requester cli = node.create_client(srv_module, service_name) File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/node.py", line 1413, in create_client check_is_valid_srv_type(srv_type) File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/type_support.py", line 51, in check_is_valid_srv_type check_for_type_support(srv_type) File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/type_support.py", line 29, in check_for_type_support msg_or_srv_type.__class__.__import_type_support__() File "/home/nzb/vscode_project/cplus_demo/ros2_demo/chat13/example14_custom_interfaces/extra_packages/install/fishbot_interfaces/local/lib/python3.10/dist-packages/fishbot_interfaces/srv/_oled_control.py", line 303, in __import_type_support__ module = import_type_support('fishbot_interfaces') File "/opt/ros/humble/local/lib/python3.10/dist-packages/rosidl_generator_py/import_type_support_impl.py", line 48, in import_type_support raise UnsupportedTypeSupport(pkg_name) rosidl_generator_py.import_type_support_impl.UnsupportedTypeSupport: Could not import 'rosidl_typesupport_c' for package 'fishbot_interfaces'
main.cpp
#include <Arduino.h> #include <micro_ros_platformio.h> #include <rcl/rcl.h> #include <rclc/rclc.h> #include <rclc/executor.h> #include <micro_ros_utilities/string_utilities.h> #include "Wire.h" #include <Adafruit_GFX.h> #include <Adafruit_SSD1306.h> #include <fishbot_interfaces/srv/oled_control.h> rclc_executor_t executor; rclc_support_t support; rcl_allocator_t allocator; rcl_node_t node; rcl_service_t service; fishbot_interfaces__srv__OledControl_Request req; fishbot_interfaces__srv__OledControl_Response res; Adafruit_SSD1306 display; void service_cb(const void *req, void *res) { fishbot_interfaces__srv__OledControl_Request *req_in = (fishbot_interfaces__srv__OledControl_Request *)req; fishbot_interfaces__srv__OledControl_Response *res_in = (fishbot_interfaces__srv__OledControl_Response *)res; display.clearDisplay(); display.setCursor(req_in->px, req_in->py); display.println(req_in->data.data); display.display(); res_in->result = 0; } void setup() { // put your setup code here, to run once: Serial.begin(115200); set_microros_serial_transports(Serial); delay(2000); allocator = rcl_get_default_allocator(); rclc_support_init(&support, 0, NULL, &allocator); rclc_node_init_default(&node, "example14_interfaces", "", &support); rclc_service_init_default(&service, &node, ROSIDL_GET_SRV_TYPE_SUPPORT(fishbot_interfaces, srv, OledControl), "/oled_control"); rclc_executor_init(&executor, &support.context, 1, &allocator); rclc_executor_add_service(&executor, &service, &req, &res, service_cb); req.data = micro_ros_string_utilities_init_with_size(100); Wire.begin(18, 19); display = Adafruit_SSD1306(128, 64, &Wire); display.begin(SSD1306_SWITCHCAPVCC, 0x3c); display.clearDisplay(); display.setTextSize(1); display.setCursor(0, 0); display.setTextColor(SSD1306_WHITE); display.println("hello world!"); display.display(); } void loop() { // put your main code here, to run repeatedly: delay(100); rclc_executor_spin_some(&executor, RCL_MS_TO_NS(100)); }
-
RE: 动手学ros2第5章进阶篇-控制OLED-自定义消息接口
@小鱼
platformio.ini[env:featheresp32] platform = espressif32 board = featheresp32 framework = arduino lib_deps = https://gitee.com/ohhuo/micro_ros_platformio.git adafruit/Adafruit SSD1306@^2.5.7
CMakeLists.txt
cmake_minimum_required(VERSION 3.5) project(fishbot_interfaces) if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") add_compile_options(-Wall -Wextra -Wpedantic) endif() # find dependencies find_package(ament_cmake REQUIRED) # uncomment the following section in order to fill in # further dependencies manually. # find_package(<dependency> REQUIRED) if(BUILD_TESTING) find_package(ament_lint_auto REQUIRED) # the following line skips the linter which checks for copyrights # uncomment the line when a copyright and license is not present in all source files #set(ament_cmake_copyright_FOUND TRUE) # the following line skips cpplint (only works in a git repo) # uncomment the line when this package is not in a git repo #set(ament_cmake_cpplint_FOUND TRUE) ament_lint_auto_find_test_dependencies() endif() find_package(rosidl_default_generators REQUIRED) rosidl_generate_interfaces(${PROJECT_NAME} "srv/OledControl.srv" ) ament_package()
package.xml
<?xml version="1.0"?> <?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?> <package format="3"> <name>fishbot_interfaces</name> <version>0.0.0</version> <description>TODO: Package description</description> <maintainer email="root@todo.todo">root</maintainer> <license>TODO: License declaration</license> <buildtool_depend>ament_cmake</buildtool_depend> <build_depend>rosidl_default_generators</build_depend> <exec_depend>rosidl_default_runtime</exec_depend> <member_of_group>rosidl_interface_packages</member_of_group> <test_depend>ament_lint_auto</test_depend> <test_depend>ament_lint_common</test_depend> <export> <build_type>ament_cmake</build_type> </export> </package>
extra_package包
extra_packages/fishbot_interfaces/ ├── CMakeLists.txt ├── include │ └── fishbot_interfaces ├── package.xml ├── src └── srv └── OledControl.srv
-
RE: 动手学ros2第5章进阶篇-控制OLED-自定义消息接口
@小鱼 刚刚重新编译了下,好慢,麻烦大佬帮我看看
Building micro-ROS library Found 36 compatible libraries Scanning dependencies... Dependency Graph |-- micro_ros_platformio @ 0.0.1+sha.085c5dd |-- Adafruit SSD1306 @ 2.5.7 Building in release mode Compiling .pio/build/featheresp32/src/main.cpp.o Building .pio/build/featheresp32/bootloader.bin Generating partitions .pio/build/featheresp32/partitions.bin esptool.py v4.2.1 Creating esp32 image... Merged 1 ELF section Successfully created esp32 image. Compiling .pio/build/featheresp32/lib1a4/micro_ros_platformio/platform_code/arduino/clock_gettime.cpp.o Compiling .pio/build/featheresp32/lib1a4/micro_ros_platformio/platform_code/arduino/serial/micro_ros_transport.cpp.o Compiling .pio/build/featheresp32/lib2c3/Adafruit SSD1306/Adafruit_SSD1306.cpp.o In file included from .pio/libdeps/featheresp32/Adafruit SSD1306/Adafruit_SSD1306.cpp:53: .pio/libdeps/featheresp32/Adafruit SSD1306/Adafruit_SSD1306.h:42:10: fatal error: Adafruit_GFX.h: No such file or directory ********************************************************************** * Looking for Adafruit_GFX.h dependency? Check our library registry! * * CLI > platformio lib search "header:Adafruit_GFX.h" * Web > https://registry.platformio.org/search?q=header:Adafruit_GFX.h * ********************************************************************** #include <Adafruit_GFX.h> ^~~~~~~~~~~~~~~~ compilation terminated. Compiling .pio/build/featheresp32/FrameworkArduino/Esp.cpp.o Compiling .pio/build/featheresp32/FrameworkArduino/FirmwareMSC.cpp.o *** [.pio/build/featheresp32/lib2c3/Adafruit SSD1306/Adafruit_SSD1306.cpp.o] Error 1 ======================================== [FAILED] Took 658.83 seconds ======================================== * The terminal process "platformio 'run'" terminated with exit code: 1. * Terminal will be reused by tasks, press any key to close it.