鱼香ROS社区
    • 版块
    • 最新
    • 未解决
    • 已解决
    • 群组
    • 注册
    • 登录
    紧急通知:禁止一切关于政治&VPN翻墙等话题,发现相关帖子会立马删除封号
    提问前必看的发帖注意事项: 社区问答规则(小鱼个人)更新 | 高质量帖子发布指南

    连接正常却无node无topic

    已定时 已固定 已锁定 已移动
    MicroROS
    microeos ros2-humble
    2
    3
    700
    正在加载更多帖子
    • 从旧到新
    • 从新到旧
    • 最多赞同
    回复
    • 在新帖中回复
    登录后回复
    此主题已被删除。只有拥有主题管理权限的用户可以查看。
    • 邪恶海星星邪
      邪恶海星星
      最后由 编辑

      1703212731219.jpg
      我使用的RT-thread+STM32
      32的程序是官方int32_publisher那套,上下位机的代码都找的是humble版本
      上位机Agent代码来自以下语句

      git clone http://github.fishros.org/https://github.com/micro-ROS/micro-ROS-Agent.git -b humble
      git clone http://github.fishros.org/https://github.com/micro-ROS/micro_ros_msgs.git -b humble
      

      现在搞不懂哪边出问题了
      下面是32中有关的代码

      #include <rtthread.h>
      
      #include <micro_ros_rtt.h>
      #include <stdio.h>
      
      #include <rcl/rcl.h>
      #include <rcl/error_handling.h>
      #include <rclc/rclc.h>
      #include <rclc/executor.h>
      
      #include <std_msgs/msg/int32.h>
      
      static rcl_publisher_t publisher;
      static std_msgs__msg__Int32 msg;
      
      static rclc_executor_t executor;
      static rclc_support_t support;
      static rcl_allocator_t allocator;
      
      static rcl_node_t node;
      static rcl_timer_t timer;
      
      static void timer_callback(rcl_timer_t * timer, int64_t last_call_time)
      {  
          // RCLC_UNUSED(last_call_time);
          if (timer != NULL) 
          {
             rcl_publish(&publisher, &msg, NULL);
      
             rt_kprintf("msg.data = %d\n",  msg.data);
             msg.data++;
          }
          else {
              rt_kprintf("[micro_ros] timer null\n");
          }
      }
      
      static void microros_pub_int32_thread_entry(void *parameter)
      {
          while(1)
          {
              rt_thread_mdelay(100);
              rclc_executor_spin_some(&executor, RCL_MS_TO_NS(100));
          }
      }
      
      void microros_pub_int32(int argc, char* argv[])
      {
      #if defined MICRO_ROS_USE_SERIAL
          // Serial setup
           set_microros_transports();
      #endif
      
      #if defined MICRO_ROS_USE_UDP
          // UDP setup
           if(argc==2) {
               set_microros_udp_transports(argv[1], 9999);
           }
           else {
               set_microros_udp_transports("192.168.1.100", 9999);
           }
      #endif
      
          allocator = rcl_get_default_allocator();
      
          //create init_options
          if (rclc_support_init(&support, 0, NULL, &allocator) != RCL_RET_OK)
          {
              rt_kprintf("[micro_ros] failed to initialize\n");
              return;
          };
      
          // create node
          if (rclc_node_init_default(&node, "micro_ros_rtt_node", "", &support) != RCL_RET_OK)
          {
              rt_kprintf("[micro_ros] failed to create node\n");
              return;
          }
          rt_kprintf("[micro_ros] node created\n");
      
          // create publisher
          rclc_publisher_init_default(
            &publisher,
            &node,
            ROSIDL_GET_MSG_TYPE_SUPPORT(std_msgs, msg, Int32),
            "micro_ros_rtt_node_publisher");
      
          rt_kprintf("[micro_ros] publisher created\n");
      
          // create timer
          const unsigned int timer_timeout = 1000;
          rclc_timer_init_default(
            &timer,
            &support,
            RCL_MS_TO_NS(timer_timeout),
            timer_callback);
          rt_kprintf("[micro_ros] timer created\n");
      
          // create executor
          rclc_executor_init(&executor, &support.context, 1, &allocator);
          rclc_executor_add_timer(&executor, &timer);
          rt_kprintf("[micro_ros] executor created\n");
      
          msg.data = 0;
      
          rt_thread_t thread = rt_thread_create("mr_pubint32", microros_pub_int32_thread_entry, RT_NULL, 2048, 25, 10);
          if(thread != RT_NULL)
          {
              rt_thread_startup(thread);
              rt_kprintf("[micro_ros] New thread mr_pubint32\n");
          }
          else
          {
              rt_kprintf("[micro_ros] Failed to create thread mr_pubint32\n");
          }
      }
      MSH_CMD_EXPORT(microros_pub_int32, microros publish int32 example)
      
      
      1 条回复 最后回复 回复 引用 0
      • 邪恶海星星邪
        邪恶海星星
        最后由 编辑

        1c8b8648-3eeb-4a0b-98bf-35e53bf3a70b-1703215890527.jpg
        不太懂内部运行原理,摸索的时候 在v6中 发现数据确实过来了

        1 条回复 最后回复 回复 引用 0
        • 8
          橡皮擦
          最后由 编辑

          遇到了一样的问题,debug有数据, 没有node和topic
          a68ded8b-df7c-4d32-bf65-fb734c60a115-image.png

          1 条回复 最后回复 回复 引用 0
          • 第一个帖子
            最后一个帖子
          皖ICP备16016415号-7
          Powered by NodeBB | 鱼香ROS