micro-ROS / micro_ros_setup

Support macros for building micro-ROS-based firmware.
Apache License 2.0
365 stars 133 forks source link

some thing wrong with rclc_support_init in appMain #277

Closed Needrom closed 3 years ago

Needrom commented 3 years ago

Error output with appMain thread open.

with no idea of gdb in linux with openocd so I add some printf in code to detect where the code had ran.

printf output.

printf is ready 
endif----- 
freeRTOS allocator success 
Into appMain 
test printf 0 
test printf 1 
rclc_support_init counter : 0 
rclc_support_init counter : 1 
rclc_support_init counter : 2 
rclc_support_init counter : 3 
rclc_support_init counter : 4 
get to end rclc_support_init counter : 5 
rclc_support_init_with_options counter : 0 
rclc_support_init_with_options counter : 1 
rclc_support_init_with_options counter : 2 
rclc_support_init_with_options counter : 3 
rclc_support_init_with_options counter : 4 
rclc_support_init_with_options counter : 5 
rclc_support_init_with_options counter : 6 

It mean the code run into appMain and stop at this line

RCCHECK(rclc_support_init(&support, 0, NULL, &allocator));

and finally it stop here ./mcu_ws/uros/rclc/rclc/src/rclc/init.c

rcl_ret_t
rclc_support_init_with_options(
  rclc_support_t * support,
  int argc,
  char const * const * argv,
  rcl_init_options_t * init_options,
  rcl_allocator_t * allocator)
{
 int counter = 0;
 printf("%s counter : %d \r\n", __func__, counter++);
 RCL_CHECK_FOR_NULL_WITH_MSG(
    support, "support is a null pointer", return RCL_RET_INVALID_ARGUMENT);
   printf("%s counter : %d \r\n", __func__, counter++);
 RCL_CHECK_FOR_NULL_WITH_MSG(
    init_options, "init_options is a null pointer", return RCL_RET_INVALID_ARGUMENT);
   printf("%s counter : %d \r\n", __func__, counter++);
 RCL_CHECK_FOR_NULL_WITH_MSG(
    allocator, "allocator is a null pointer", return RCL_RET_INVALID_ARGUMENT);
  rcl_ret_t rc = RCL_RET_OK;
  printf("%s counter : %d \r\n", __func__, counter++);

  memcpy(&support->init_options, init_options, sizeof(rcl_init_options_t));
  printf("%s counter : %d \r\n", __func__, counter++);

   printf("%s counter : %d \r\n", __func__, counter++);
 support->context = rcl_get_zero_initialized_context();
   printf("%s counter : %d \r\n", __func__, counter++);
 rc = rcl_init(argc, argv, &support->init_options, &support->context);              //stop here
   printf("%s counter : %d \r\n", __func__, counter++);
 if (rc != RCL_RET_OK) {
    PRINT_RCLC_ERROR(rclc_init, rcl_init);
    return rc;
  }
  support->allocator = allocator;
  printf("%s counter : %d \r\n", __func__, counter++);

  rc = rcl_clock_init(RCL_STEADY_TIME, &support->clock, support->allocator);
  if (rc != RCL_RET_OK) {
    PRINT_RCLC_ERROR(rclc_init, rcl_clock_init);
  }
   printf("%s counter : %d \r\n", __func__, counter++);
 return rc;
}

the change I had make.

void appMain(void *argument)
{
    int test_printf_count = 0;
    printf("Into %s \r\n", __func__);
    rcl_allocator_t allocator = rcl_get_default_allocator();
    printf("test printf %d \r\n", test_printf_count++);
    rclc_support_t support;

    printf("test printf %d \r\n", test_printf_count++);
// create init_options
    RCCHECK(rclc_support_init(&support, 0, NULL, &allocator));

    printf("test printf %d \r\n", test_printf_count++);
// create node
    rcl_node_t node;
    RCCHECK(rclc_node_init_default(&node, "pingpong_node", "", &support));

    printf("test printf %d \r\n", test_printf_count++);
// Create a reliable ping publisher
    RCCHECK(rclc_publisher_init_default(&ping_publisher, &node,
        ROSIDL_GET_MSG_TYPE_SUPPORT(std_msgs, msg, Header), "/microROS/ping"));

    printf("test printf %d \r\n", test_printf_count++);
// Create a best effort pong publisher
    RCCHECK(rclc_publisher_init_best_effort(&pong_publisher, &node,
        ROSIDL_GET_MSG_TYPE_SUPPORT(std_msgs, msg, Header), "/microROS/pong"));

    printf("test printf %d \r\n", test_printf_count++);
// Create a best effort ping subscriber
    RCCHECK(rclc_subscription_init_best_effort(&ping_subscriber, &node,
        ROSIDL_GET_MSG_TYPE_SUPPORT(std_msgs, msg, Header), "/microROS/ping"));

    printf("test printf %d \r\n", test_printf_count++);
// Create a best effort  pong subscriber
    RCCHECK(rclc_subscription_init_best_effort(&pong_subscriber, &node,
        ROSIDL_GET_MSG_TYPE_SUPPORT(std_msgs, msg, Header), "/microROS/pong"));

    printf("test printf %d \r\n", test_printf_count++);
// Create a 3 seconds ping timer timer,
    rcl_timer_t timer;
    RCCHECK(rclc_timer_init_default(&timer, &support, RCL_MS_TO_NS(2000), ping_timer_callback));

    printf("test printf %d \r\n", test_printf_count++);
// Create executor
    rclc_executor_t executor;
    RCCHECK(rclc_executor_init(&executor, &support.context, 3, &allocator));
    RCCHECK(rclc_executor_add_timer(&executor, &timer));
    RCCHECK(rclc_executor_add_subscription(&executor, &ping_subscriber, &incoming_ping,
        &ping_subscription_callback, ON_NEW_DATA));
    RCCHECK(rclc_executor_add_subscription(&executor, &pong_subscriber, &incoming_pong,
        &pong_subscription_callback, ON_NEW_DATA));

    printf("test printf %d \r\n", test_printf_count++);
// Create and allocate the pingpong messages
    char outcoming_ping_buffer[STRING_BUFFER_LEN];
    outcoming_ping.frame_id.data = outcoming_ping_buffer;
    outcoming_ping.frame_id.capacity = STRING_BUFFER_LEN;

    char incoming_ping_buffer[STRING_BUFFER_LEN];
    incoming_ping.frame_id.data = incoming_ping_buffer;
    incoming_ping.frame_id.capacity = STRING_BUFFER_LEN;

    char incoming_pong_buffer[STRING_BUFFER_LEN];
    incoming_pong.frame_id.data = incoming_pong_buffer;
    incoming_pong.frame_id.capacity = STRING_BUFFER_LEN;

    device_id = rand();

    printf("test printf %d \r\n", test_printf_count++);

    while(1){
        rclc_executor_spin_some(&executor, RCL_MS_TO_NS(10));
        usleep(10000);
    }

    // Free resources
    RCCHECK(rcl_publisher_fini(&ping_publisher, &node));
    RCCHECK(rcl_publisher_fini(&pong_publisher, &node));
    RCCHECK(rcl_subscription_fini(&ping_subscriber, &node));
    RCCHECK(rcl_subscription_fini(&pong_subscriber, &node));
    RCCHECK(rcl_node_fini(&node));
}
  1. firmware/mcu_ws/uros/rclc/rclc/src/rclc/init.c

    rcl_ret_t
    rclc_support_init(
    rclc_support_t * support,
    int argc,
    char const * const * argv,
    rcl_allocator_t * allocator)
    {
    int counter = 0;
    printf("%s counter : %d \r\n", __func__, counter++);
    RCL_CHECK_FOR_NULL_WITH_MSG(
    support, "support is a null pointer", return RCL_RET_INVALID_ARGUMENT);
    printf("%s counter : %d \r\n", __func__, counter++);
    RCL_CHECK_FOR_NULL_WITH_MSG(
    allocator, "allocator is a null pointer", return RCL_RET_INVALID_ARGUMENT);
    rcl_ret_t rc = RCL_RET_OK;
    printf("%s counter : %d \r\n", __func__, counter++);
    
    printf("%s counter : %d \r\n", __func__, counter++);
    rcl_init_options_t init_options = rcl_get_zero_initialized_init_options();
    printf("%s counter : %d \r\n", __func__, counter++);
    rc = rcl_init_options_init(&init_options, (*allocator) );
    if (rc != RCL_RET_OK) {
    PRINT_RCLC_ERROR(rclc_support_init, rcl_init_options_init);
    return rc;
    }
    printf("get to end %s counter : %d \r\n", __func__, counter++);
    
    rc = rclc_support_init_with_options(support, argc, argv, &init_options, allocator);
    
    printf("get to end %s counter : %d \r\n", __func__, counter++);
    
    return rc;
    }
  2. firmware/mcu_ws/uros/rclc/rclc/src/rclc/init.c

    
    rcl_ret_t
    rclc_support_init_with_options(
    rclc_support_t * support,
    int argc,
    char const * const * argv,
    rcl_init_options_t * init_options,
    rcl_allocator_t * allocator)
    {
    int counter = 0;   
    printf("%s counter : %d \r\n", __func__, counter++);
    RCL_CHECK_FOR_NULL_WITH_MSG(
    support, "support is a null pointer", return RCL_RET_INVALID_ARGUMENT);
    printf("%s counter : %d \r\n", __func__, counter++);
    RCL_CHECK_FOR_NULL_WITH_MSG(
    init_options, "init_options is a null pointer", return RCL_RET_INVALID_ARGUMENT);
    printf("%s counter : %d \r\n", __func__, counter++);
    RCL_CHECK_FOR_NULL_WITH_MSG(
    allocator, "allocator is a null pointer", return RCL_RET_INVALID_ARGUMENT);
    rcl_ret_t rc = RCL_RET_OK;
    printf("%s counter : %d \r\n", __func__, counter++);
    
    memcpy(&support->init_options, init_options, sizeof(rcl_init_options_t));
    printf("%s counter : %d \r\n", __func__, counter++);
    
    printf("%s counter : %d \r\n", __func__, counter++);
    support->context = rcl_get_zero_initialized_context();
    printf("%s counter : %d \r\n", __func__, counter++);
    rc = rcl_init(argc, argv, &support->init_options, &support->context);
    printf("%s counter : %d \r\n", __func__, counter++);
    if (rc != RCL_RET_OK) {
    PRINT_RCLC_ERROR(rclc_init, rcl_init);
    return rc;
    }
    support->allocator = allocator;
    printf("%s counter : %d \r\n", __func__, counter++);
    
    rc = rcl_clock_init(RCL_STEADY_TIME, &support->clock, support->allocator);
    if (rc != RCL_RET_OK) {
    PRINT_RCLC_ERROR(rclc_init, rcl_clock_init);
    }
    printf("%s counter : %d \r\n", __func__, counter++);
    return rc;
    }


## Project Link

https://github.com/Needrom/Microros-on-DIscovery-board

any thing help?
pablogs9 commented 3 years ago

Which RTOS are you using? Which board are you using exactly? Which transport are you using?

Could you share the output of the micro-ROS Agent with a -v6 flag?

Thanks!

Needrom commented 3 years ago

sorry about the the link below .It can't navigate to the project before.Now it could.So you can see I'm with a discovery board from china zhengdianyuanzi, and the RTOS and transport I'm use.

It can't run up yet.some initialization can't be finish. Don't know the mean about ouput with -v6 flag.

some bad new is the code is running to this.

/firmware/mcu_ws/uros/rmw_microxrcedds/rmw_microxrcedds_c/src/rmw_init.c

  if (!uxr_init_udp_transport(
      &context_impl->transport, &context_impl->udp_platform, ip_protocol,
      context_impl->connection_params.agent_address, context_impl->connection_params.agent_port))
  {
    RMW_SET_ERROR_MSG("Can not create an udp connection");
    return RMW_RET_ERROR;
  }

but I'm in the serial mode not udp.

pablogs9 commented 3 years ago

Recently we have changed the approach of the transports. Please check this: https://github.com/Needrom/Microros-on-DIscovery-board/pull/2

I have not built it and maybe you need to change something, but this is the new way of using serial transports in micro-ROS.

Don't hesitate to ask anything if you have any more doubts.

Needrom commented 3 years ago

OK

with some error output it seem it didn't choose a rigth Transport mode

--- stderr: rcutils
/home/mego-ros2/microros_ws/firmware/mcu_ws/uros/rcutils/src/filesystem.c: In function 'rcutils_get_cwd':
/home/mego-ros2/microros_ws/firmware/mcu_ws/uros/rcutils/src/filesystem.c:60:24: warning: unused parameter 'buffer' [-Wunused-parameter]
 rcutils_get_cwd(char * buffer, size_t max_length)
                 ~~~~~~~^~~~~~
/home/mego-ros2/microros_ws/firmware/mcu_ws/uros/rcutils/src/filesystem.c:60:39: warning: unused parameter 'max_length' [-Wunused-parameter]
 rcutils_get_cwd(char * buffer, size_t max_length)
                                ~~~~~~~^~~~~~~~~~
/home/mego-ros2/microros_ws/firmware/mcu_ws/uros/rcutils/src/filesystem.c: In function 'rcutils_is_directory':
/home/mego-ros2/microros_ws/firmware/mcu_ws/uros/rcutils/src/filesystem.c:83:35: warning: unused parameter 'abs_path' [-Wunused-parameter]
 rcutils_is_directory(const char * abs_path)
                      ~~~~~~~~~~~~~^~~~~~~~
/home/mego-ros2/microros_ws/firmware/mcu_ws/uros/rcutils/src/filesystem.c: In function 'rcutils_is_file':
/home/mego-ros2/microros_ws/firmware/mcu_ws/uros/rcutils/src/filesystem.c:102:30: warning: unused parameter 'abs_path' [-Wunused-parameter]
 rcutils_is_file(const char * abs_path)
                 ~~~~~~~~~~~~~^~~~~~~~
/home/mego-ros2/microros_ws/firmware/mcu_ws/uros/rcutils/src/filesystem.c: In function 'rcutils_exists':
/home/mego-ros2/microros_ws/firmware/mcu_ws/uros/rcutils/src/filesystem.c:121:29: warning: unused parameter 'abs_path' [-Wunused-parameter]
 rcutils_exists(const char * abs_path)
                ~~~~~~~~~~~~~^~~~~~~~
/home/mego-ros2/microros_ws/firmware/mcu_ws/uros/rcutils/src/filesystem.c: In function 'rcutils_is_readable':
/home/mego-ros2/microros_ws/firmware/mcu_ws/uros/rcutils/src/filesystem.c:136:34: warning: unused parameter 'abs_path' [-Wunused-parameter]
 rcutils_is_readable(const char * abs_path)
                     ~~~~~~~~~~~~~^~~~~~~~
/home/mego-ros2/microros_ws/firmware/mcu_ws/uros/rcutils/src/filesystem.c: In function 'rcutils_is_writable':
/home/mego-ros2/microros_ws/firmware/mcu_ws/uros/rcutils/src/filesystem.c:158:34: warning: unused parameter 'abs_path' [-Wunused-parameter]
 rcutils_is_writable(const char * abs_path)
                     ~~~~~~~~~~~~~^~~~~~~~
/home/mego-ros2/microros_ws/firmware/mcu_ws/uros/rcutils/src/filesystem.c: In function 'rcutils_is_readable_and_writable':
/home/mego-ros2/microros_ws/firmware/mcu_ws/uros/rcutils/src/filesystem.c:180:47: warning: unused parameter 'abs_path' [-Wunused-parameter]
 rcutils_is_readable_and_writable(const char * abs_path)
                                  ~~~~~~~~~~~~~^~~~~~~~
/home/mego-ros2/microros_ws/firmware/mcu_ws/uros/rcutils/src/filesystem.c: In function 'rcutils_mkdir':
/home/mego-ros2/microros_ws/firmware/mcu_ws/uros/rcutils/src/filesystem.c:257:13: warning: implicit declaration of function 'mkdir' [-Wimplicit-function-declaration]
   int ret = mkdir(abs_path, 0775);
             ^~~~~
/home/mego-ros2/microros_ws/firmware/mcu_ws/uros/rcutils/src/filesystem.c: In function 'rcutils_calculate_directory_size':
/home/mego-ros2/microros_ws/firmware/mcu_ws/uros/rcutils/src/filesystem.c:267:47: warning: unused parameter 'directory_path' [-Wunused-parameter]
 rcutils_calculate_directory_size(const char * directory_path, rcutils_allocator_t allocator)
                                  ~~~~~~~~~~~~~^~~~~~~~~~~~~~
/home/mego-ros2/microros_ws/firmware/mcu_ws/uros/rcutils/src/filesystem.c:267:83: warning: unused parameter 'allocator' [-Wunused-parameter]
 rcutils_calculate_directory_size(const char * directory_path, rcutils_allocator_t allocator)
                                                               ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
/home/mego-ros2/microros_ws/firmware/mcu_ws/uros/rcutils/src/filesystem.c: In function 'rcutils_get_file_size':
/home/mego-ros2/microros_ws/firmware/mcu_ws/uros/rcutils/src/filesystem.c:325:36: warning: unused parameter 'file_path' [-Wunused-parameter]
 rcutils_get_file_size(const char * file_path)
                       ~~~~~~~~~~~~~^~~~~~~~~
/home/mego-ros2/microros_ws/firmware/mcu_ws/uros/rcutils/src/logging.c: In function 'rcutils_get_env_var_zero_or_one':
/home/mego-ros2/microros_ws/firmware/mcu_ws/uros/rcutils/src/logging.c:127:35: warning: unused parameter 'zero_semantic' [-Wunused-parameter]
   const char * name, const char * zero_semantic,
                      ~~~~~~~~~~~~~^~~~~~~~~~~~~
/home/mego-ros2/microros_ws/firmware/mcu_ws/uros/rcutils/src/logging.c:128:16: warning: unused parameter 'one_semantic' [-Wunused-parameter]
   const char * one_semantic)
   ~~~~~~~~~~~~~^~~~~~~~~~~~
/home/mego-ros2/microros_ws/firmware/mcu_ws/uros/rcutils/src/logging.c: In function 'rcutils_logging_console_output_handler':
/home/mego-ros2/microros_ws/firmware/mcu_ws/uros/rcutils/src/logging.c:797:35: warning: implicit declaration of function 'isatty' [-Wimplicit-function-declaration]
 # define IS_STREAM_A_TTY(stream) (isatty(fileno(stream)) != 0)
                                   ^~~~~~
/home/mego-ros2/microros_ws/firmware/mcu_ws/uros/rcutils/src/logging.c:807:22: note: in expansion of macro 'IS_STREAM_A_TTY'
       is_colorized = IS_STREAM_A_TTY(g_output_stream); \
                      ^~~~~~~~~~~~~~~
/home/mego-ros2/microros_ws/firmware/mcu_ws/uros/rcutils/src/logging.c:928:3: note: in expansion of macro 'IS_OUTPUT_COLORIZED'
   IS_OUTPUT_COLORIZED(is_colorized)
   ^~~~~~~~~~~~~~~~~~~
/home/mego-ros2/microros_ws/firmware/mcu_ws/uros/rcutils/src/process.c: In function 'rcutils_get_pid':
/home/mego-ros2/microros_ws/firmware/mcu_ws/uros/rcutils/src/process.c:51:15: warning: implicit declaration of function 'getpid'; did you mean 'getw'? [-Wimplicit-function-declaration]
   return (int)getpid();
               ^~~~~~
               getw
/home/mego-ros2/microros_ws/firmware/mcu_ws/uros/rcutils/src/shared_library.c: In function 'rcutils_load_shared_library':
/home/mego-ros2/microros_ws/firmware/mcu_ws/uros/rcutils/src/shared_library.c:63:30: warning: unused parameter 'lib' [-Wunused-parameter]
   rcutils_shared_library_t * lib,
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
/home/mego-ros2/microros_ws/firmware/mcu_ws/uros/rcutils/src/shared_library.c:64:16: warning: unused parameter 'library_path' [-Wunused-parameter]
   const char * library_path,
   ~~~~~~~~~~~~~^~~~~~~~~~~~
/home/mego-ros2/microros_ws/firmware/mcu_ws/uros/rcutils/src/shared_library.c:65:23: warning: unused parameter 'allocator' [-Wunused-parameter]
   rcutils_allocator_t allocator)
   ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
/home/mego-ros2/microros_ws/firmware/mcu_ws/uros/rcutils/src/shared_library.c: In function 'rcutils_get_symbol':
/home/mego-ros2/microros_ws/firmware/mcu_ws/uros/rcutils/src/shared_library.c:118:23: warning: implicit declaration of function 'dlsym' [-Wimplicit-function-declaration]
   void * lib_symbol = dlsym(lib->lib_pointer, symbol_name);
                       ^~~~~
/home/mego-ros2/microros_ws/firmware/mcu_ws/uros/rcutils/src/shared_library.c:118:23: warning: initialization of 'void *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
/home/mego-ros2/microros_ws/firmware/mcu_ws/uros/rcutils/src/shared_library.c:119:18: warning: implicit declaration of function 'dlerror'; did you mean 'perror'? [-Wimplicit-function-declaration]
   char * error = dlerror();
                  ^~~~~~~
                  perror
/home/mego-ros2/microros_ws/firmware/mcu_ws/uros/rcutils/src/shared_library.c:119:18: warning: initialization of 'char *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
/home/mego-ros2/microros_ws/firmware/mcu_ws/uros/rcutils/src/shared_library.c: In function 'rcutils_has_symbol':
/home/mego-ros2/microros_ws/firmware/mcu_ws/uros/rcutils/src/shared_library.c:156:23: warning: initialization of 'void *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
   void * lib_symbol = dlsym(lib->lib_pointer, symbol_name);
                       ^~~~~
/home/mego-ros2/microros_ws/firmware/mcu_ws/uros/rcutils/src/shared_library.c:157:20: warning: comparison between pointer and integer
   return dlerror() == NULL && lib_symbol != 0;
                    ^~
/home/mego-ros2/microros_ws/firmware/mcu_ws/uros/rcutils/src/shared_library.c: In function 'rcutils_unload_shared_library':
/home/mego-ros2/microros_ws/firmware/mcu_ws/uros/rcutils/src/shared_library.c:175:20: warning: implicit declaration of function 'dlclose'; did you mean 'pclose'? [-Wimplicit-function-declaration]
   int error_code = dlclose(lib->lib_pointer);
                    ^~~~~~~
                    pclose
/home/mego-ros2/microros_ws/firmware/mcu_ws/uros/rcutils/src/shared_library.c: In function 'rcutils_get_platform_library_name':
/home/mego-ros2/microros_ws/firmware/mcu_ws/uros/rcutils/src/shared_library.c:198:16: warning: unused parameter 'buffer_size' [-Wunused-parameter]
   unsigned int buffer_size,
   ~~~~~~~~~~~~~^~~~~~~~~~~
/home/mego-ros2/microros_ws/firmware/mcu_ws/uros/rcutils/src/shared_library.c:199:8: warning: unused parameter 'debug' [-Wunused-parameter]
   bool debug)
        ^
---
--- stderr: rosidl_runtime_c
CMake Warning at /home/mego-ros2/microros_ws/firmware/mcu_ws/install/rcutils/share/rcutils/cmake/ament_cmake_export_libraries-extras.cmake:116 (message):
  Package 'rcutils' exports library 'dl' which couldn't be found
Call Stack (most recent call first):
  /home/mego-ros2/microros_ws/firmware/mcu_ws/install/rcutils/share/rcutils/cmake/rcutilsConfig.cmake:41 (include)
  CMakeLists.txt:15 (find_package)

---
--- stderr: rcl_logging_noop
CMake Warning at /home/mego-ros2/microros_ws/firmware/mcu_ws/install/rcutils/share/rcutils/cmake/ament_cmake_export_libraries-extras.cmake:116 (message):
  Package 'rcutils' exports library 'dl' which couldn't be found
Call Stack (most recent call first):
  /home/mego-ros2/microros_ws/firmware/mcu_ws/install/rcutils/share/rcutils/cmake/rcutilsConfig.cmake:41 (include)
  CMakeLists.txt:15 (find_package)

---
--- stderr: rmw
CMake Warning at /home/mego-ros2/microros_ws/firmware/mcu_ws/install/rcutils/share/rcutils/cmake/ament_cmake_export_libraries-extras.cmake:116 (message):
  Package 'rcutils' exports library 'dl' which couldn't be found
Call Stack (most recent call first):
  /home/mego-ros2/microros_ws/firmware/mcu_ws/install/rcutils/share/rcutils/cmake/rcutilsConfig.cmake:41 (include)
  CMakeLists.txt:21 (find_package)

---
--- stderr: rosidl_typesupport_microxrcedds_c
CMake Warning at /home/mego-ros2/microros_ws/firmware/mcu_ws/install/rcutils/share/rcutils/cmake/ament_cmake_export_libraries-extras.cmake:116 (message):
  Package 'rcutils' exports library 'dl' which couldn't be found
Call Stack (most recent call first):
  /home/mego-ros2/microros_ws/firmware/mcu_ws/install/rcutils/share/rcutils/cmake/rcutilsConfig.cmake:41 (include)
  /home/mego-ros2/microros_ws/firmware/mcu_ws/install/rosidl_runtime_c/share/rosidl_runtime_c/cmake/ament_cmake_export_dependencies-extras.cmake:21 (find_package)
  /home/mego-ros2/microros_ws/firmware/mcu_ws/install/rosidl_runtime_c/share/rosidl_runtime_c/cmake/rosidl_runtime_cConfig.cmake:41 (include)
  CMakeLists.txt:22 (find_package)

---
--- stderr: rosidl_typesupport_c
CMake Warning at /home/mego-ros2/microros_ws/firmware/mcu_ws/install/rcutils/share/rcutils/cmake/ament_cmake_export_libraries-extras.cmake:116 (message):
  Package 'rcutils' exports library 'dl' which couldn't be found
Call Stack (most recent call first):
  /home/mego-ros2/microros_ws/firmware/mcu_ws/install/rcutils/share/rcutils/cmake/rcutilsConfig.cmake:41 (include)
  CMakeLists.txt:21 (find_package)

---
--- stderr: builtin_interfaces
CMake Warning at /home/mego-ros2/microros_ws/firmware/mcu_ws/install/rcutils/share/rcutils/cmake/ament_cmake_export_libraries-extras.cmake:116 (message):
  Package 'rcutils' exports library 'dl' which couldn't be found
Call Stack (most recent call first):
  /home/mego-ros2/microros_ws/firmware/mcu_ws/install/rcutils/share/rcutils/cmake/rcutilsConfig.cmake:41 (include)
  /home/mego-ros2/microros_ws/firmware/mcu_ws/install/rmw/share/rmw/cmake/ament_cmake_export_dependencies-extras.cmake:21 (find_package)
  /home/mego-ros2/microros_ws/firmware/mcu_ws/install/rmw/share/rmw/cmake/rmwConfig.cmake:41 (include)
  /home/mego-ros2/microros_ws/firmware/mcu_ws/install/rosidl_typesupport_microxrcedds_c/share/rosidl_typesupport_microxrcedds_c/cmake/ament_cmake_export_dependencies-extras.cmake:21 (find_package)
  /home/mego-ros2/microros_ws/firmware/mcu_ws/install/rosidl_typesupport_microxrcedds_c/share/rosidl_typesupport_microxrcedds_c/cmake/rosidl_typesupport_microxrcedds_cConfig.cmake:41 (include)
  /home/mego-ros2/microros_ws/firmware/mcu_ws/install/rosidl_typesupport_c/share/rosidl_typesupport_c/cmake/rosidl_typesupport_c-extras.cmake:13 (find_package)
  /home/mego-ros2/microros_ws/firmware/mcu_ws/install/rosidl_typesupport_c/share/rosidl_typesupport_c/cmake/rosidl_typesupport_cConfig.cmake:41 (include)
  /home/mego-ros2/microros_ws/firmware/mcu_ws/install/rosidl_default_generators/share/rosidl_default_generators/cmake/rosidl_default_generators-extras.cmake:21 (find_package)
  /home/mego-ros2/microros_ws/firmware/mcu_ws/install/rosidl_default_generators/share/rosidl_default_generators/cmake/rosidl_default_generatorsConfig.cmake:41 (include)
  CMakeLists.txt:14 (find_package)

---
--- stderr: libyaml_vendor
CMake Warning (dev) at CMakeLists.txt:55 (add_library):
  ADD_LIBRARY called with SHARED option but the target platform does not
  support dynamic linking.  Building a STATIC library instead.  This may lead
  to problems.
This warning is for project developers.  Use -Wno-dev to suppress it.

/home/mego-ros2/microros_ws/firmware/mcu_ws/build/libyaml_vendor/libyaml-10c9078-prefix/src/libyaml-10c9078/src/api.c: In function 'yaml_strdup':
/home/mego-ros2/microros_ws/firmware/mcu_ws/build/libyaml_vendor/libyaml-10c9078-prefix/src/libyaml-10c9078/src/api.c:66:27: warning: implicit declaration of function 'strdup'; did you mean 'strcmp'? [-Wimplicit-function-declaration]
     return (yaml_char_t *)strdup((char *)str);
                           ^~~~~~
                           strcmp
/home/mego-ros2/microros_ws/firmware/mcu_ws/build/libyaml_vendor/libyaml-10c9078-prefix/src/libyaml-10c9078/src/api.c: In function 'yaml_document_delete':
/home/mego-ros2/microros_ws/firmware/mcu_ws/build/libyaml_vendor/libyaml-10c9078-prefix/src/libyaml-10c9078/src/api.c:1121:7: warning: variable 'context' set but not used [-Wunused-but-set-variable]
     } context;
       ^~~~~~~
/home/mego-ros2/microros_ws/firmware/mcu_ws/build/libyaml_vendor/libyaml-10c9078-prefix/src/libyaml-10c9078/src/emitter.c: In function 'yaml_emitter_write_plain_scalar':
/home/mego-ros2/microros_ws/firmware/mcu_ws/build/libyaml_vendor/libyaml-10c9078-prefix/src/libyaml-10c9078/src/emitter.c:28:6: warning: value computed is not used [-Wunused-value]
      && ((emitter->line_break == YAML_CR_BREAK ?                                \
      ^~
/home/mego-ros2/microros_ws/firmware/mcu_ws/build/libyaml_vendor/libyaml-10c9078-prefix/src/libyaml-10c9078/src/emitter.c:56:11: note: in expansion of macro 'PUT_BREAK'
          (PUT_BREAK(emitter),                                                   \
           ^~~~~~~~~
/home/mego-ros2/microros_ws/firmware/mcu_ws/build/libyaml_vendor/libyaml-10c9078-prefix/src/libyaml-10c9078/src/emitter.c:1931:18: note: in expansion of macro 'WRITE_BREAK'
             if (!WRITE_BREAK(emitter, string)) return 0;
                  ^~~~~~~~~~~
/home/mego-ros2/microros_ws/firmware/mcu_ws/build/libyaml_vendor/libyaml-10c9078-prefix/src/libyaml-10c9078/src/emitter.c: In function 'yaml_emitter_write_single_quoted_scalar':
/home/mego-ros2/microros_ws/firmware/mcu_ws/build/libyaml_vendor/libyaml-10c9078-prefix/src/libyaml-10c9078/src/emitter.c:28:6: warning: value computed is not used [-Wunused-value]
      && ((emitter->line_break == YAML_CR_BREAK ?                                \
      ^~
/home/mego-ros2/microros_ws/firmware/mcu_ws/build/libyaml_vendor/libyaml-10c9078-prefix/src/libyaml-10c9078/src/emitter.c:56:11: note: in expansion of macro 'PUT_BREAK'
          (PUT_BREAK(emitter),                                                   \
           ^~~~~~~~~
/home/mego-ros2/microros_ws/firmware/mcu_ws/build/libyaml_vendor/libyaml-10c9078-prefix/src/libyaml-10c9078/src/emitter.c:1988:18: note: in expansion of macro 'WRITE_BREAK'
             if (!WRITE_BREAK(emitter, string)) return 0;
                  ^~~~~~~~~~~
/home/mego-ros2/microros_ws/firmware/mcu_ws/build/libyaml_vendor/libyaml-10c9078-prefix/src/libyaml-10c9078/src/emitter.c: In function 'yaml_emitter_write_literal_scalar':
/home/mego-ros2/microros_ws/firmware/mcu_ws/build/libyaml_vendor/libyaml-10c9078-prefix/src/libyaml-10c9078/src/emitter.c:28:6: warning: value computed is not used [-Wunused-value]
      && ((emitter->line_break == YAML_CR_BREAK ?                                \
      ^~
/home/mego-ros2/microros_ws/firmware/mcu_ws/build/libyaml_vendor/libyaml-10c9078-prefix/src/libyaml-10c9078/src/emitter.c:56:11: note: in expansion of macro 'PUT_BREAK'
          (PUT_BREAK(emitter),                                                   \
           ^~~~~~~~~
/home/mego-ros2/microros_ws/firmware/mcu_ws/build/libyaml_vendor/libyaml-10c9078-prefix/src/libyaml-10c9078/src/emitter.c:2251:18: note: in expansion of macro 'WRITE_BREAK'
             if (!WRITE_BREAK(emitter, string)) return 0;
                  ^~~~~~~~~~~
/home/mego-ros2/microros_ws/firmware/mcu_ws/build/libyaml_vendor/libyaml-10c9078-prefix/src/libyaml-10c9078/src/emitter.c: In function 'yaml_emitter_write_folded_scalar':
/home/mego-ros2/microros_ws/firmware/mcu_ws/build/libyaml_vendor/libyaml-10c9078-prefix/src/libyaml-10c9078/src/emitter.c:28:6: warning: value computed is not used [-Wunused-value]
      && ((emitter->line_break == YAML_CR_BREAK ?                                \
      ^~
/home/mego-ros2/microros_ws/firmware/mcu_ws/build/libyaml_vendor/libyaml-10c9078-prefix/src/libyaml-10c9078/src/emitter.c:56:11: note: in expansion of macro 'PUT_BREAK'
          (PUT_BREAK(emitter),                                                   \
           ^~~~~~~~~
/home/mego-ros2/microros_ws/firmware/mcu_ws/build/libyaml_vendor/libyaml-10c9078-prefix/src/libyaml-10c9078/src/emitter.c:2300:18: note: in expansion of macro 'WRITE_BREAK'
             if (!WRITE_BREAK(emitter, string)) return 0;
                  ^~~~~~~~~~~
/home/mego-ros2/microros_ws/firmware/mcu_ws/build/libyaml_vendor/libyaml-10c9078-prefix/src/libyaml-10c9078/src/parser.c: In function 'yaml_parser_parse_block_sequence_entry':
/home/mego-ros2/microros_ws/firmware/mcu_ws/build/libyaml_vendor/libyaml-10c9078-prefix/src/libyaml-10c9078/src/parser.c:762:21: warning: variable 'dummy_mark' set but not used [-Wunused-but-set-variable]
         yaml_mark_t dummy_mark;     /* Used to eliminate a compiler warning. */
                     ^~~~~~~~~~
/home/mego-ros2/microros_ws/firmware/mcu_ws/build/libyaml_vendor/libyaml-10c9078-prefix/src/libyaml-10c9078/src/parser.c: In function 'yaml_parser_parse_block_mapping_key':
/home/mego-ros2/microros_ws/firmware/mcu_ws/build/libyaml_vendor/libyaml-10c9078-prefix/src/libyaml-10c9078/src/parser.c:872:21: warning: variable 'dummy_mark' set but not used [-Wunused-but-set-variable]
         yaml_mark_t dummy_mark;     /* Used to eliminate a compiler warning. */
                     ^~~~~~~~~~
/home/mego-ros2/microros_ws/firmware/mcu_ws/build/libyaml_vendor/libyaml-10c9078-prefix/src/libyaml-10c9078/src/parser.c: In function 'yaml_parser_parse_flow_sequence_entry':
/home/mego-ros2/microros_ws/firmware/mcu_ws/build/libyaml_vendor/libyaml-10c9078-prefix/src/libyaml-10c9078/src/parser.c:955:17: warning: variable 'dummy_mark' set but not used [-Wunused-but-set-variable]
     yaml_mark_t dummy_mark;     /* Used to eliminate a compiler warning. */
                 ^~~~~~~~~~
/home/mego-ros2/microros_ws/firmware/mcu_ws/build/libyaml_vendor/libyaml-10c9078-prefix/src/libyaml-10c9078/src/parser.c: In function 'yaml_parser_parse_flow_mapping_key':
/home/mego-ros2/microros_ws/firmware/mcu_ws/build/libyaml_vendor/libyaml-10c9078-prefix/src/libyaml-10c9078/src/parser.c:1107:17: warning: variable 'dummy_mark' set but not used [-Wunused-but-set-variable]
     yaml_mark_t dummy_mark;     /* Used to eliminate a compiler warning. */
                 ^~~~~~~~~~
/home/mego-ros2/microros_ws/firmware/mcu_ws/build/libyaml_vendor/libyaml-10c9078-prefix/src/libyaml-10c9078/src/scanner.c: In function 'yaml_parser_decrease_flow_level':
/home/mego-ros2/microros_ws/firmware/mcu_ws/build/libyaml_vendor/libyaml-10c9078-prefix/src/libyaml-10c9078/src/scanner.c:1189:23: warning: variable 'dummy_key' set but not used [-Wunused-but-set-variable]
     yaml_simple_key_t dummy_key;    /* Used to eliminate a compiler warning. */
                       ^~~~~~~~~
---
--- stderr: micro_ros_msgs
CMake Warning at /home/mego-ros2/microros_ws/firmware/mcu_ws/install/rcutils/share/rcutils/cmake/ament_cmake_export_libraries-extras.cmake:116 (message):
  Package 'rcutils' exports library 'dl' which couldn't be found
Call Stack (most recent call first):
  /home/mego-ros2/microros_ws/firmware/mcu_ws/install/rcutils/share/rcutils/cmake/rcutilsConfig.cmake:41 (include)
  /home/mego-ros2/microros_ws/firmware/mcu_ws/install/rmw/share/rmw/cmake/ament_cmake_export_dependencies-extras.cmake:21 (find_package)
  /home/mego-ros2/microros_ws/firmware/mcu_ws/install/rmw/share/rmw/cmake/rmwConfig.cmake:41 (include)
  /home/mego-ros2/microros_ws/firmware/mcu_ws/install/rosidl_typesupport_microxrcedds_c/share/rosidl_typesupport_microxrcedds_c/cmake/ament_cmake_export_dependencies-extras.cmake:21 (find_package)
  /home/mego-ros2/microros_ws/firmware/mcu_ws/install/rosidl_typesupport_microxrcedds_c/share/rosidl_typesupport_microxrcedds_c/cmake/rosidl_typesupport_microxrcedds_cConfig.cmake:41 (include)
  /home/mego-ros2/microros_ws/firmware/mcu_ws/install/rosidl_typesupport_c/share/rosidl_typesupport_c/cmake/rosidl_typesupport_c-extras.cmake:13 (find_package)
  /home/mego-ros2/microros_ws/firmware/mcu_ws/install/rosidl_typesupport_c/share/rosidl_typesupport_c/cmake/rosidl_typesupport_cConfig.cmake:41 (include)
  /home/mego-ros2/microros_ws/firmware/mcu_ws/install/rosidl_default_generators/share/rosidl_default_generators/cmake/rosidl_default_generators-extras.cmake:21 (find_package)
  /home/mego-ros2/microros_ws/firmware/mcu_ws/install/rosidl_default_generators/share/rosidl_default_generators/cmake/rosidl_default_generatorsConfig.cmake:41 (include)
  CMakeLists.txt:20 (find_package)

---
--- stderr: rmw_microxrcedds
CMake Warning at /home/mego-ros2/microros_ws/firmware/mcu_ws/install/rcutils/share/rcutils/cmake/ament_cmake_export_libraries-extras.cmake:116 (message):
  Package 'rcutils' exports library 'dl' which couldn't be found
Call Stack (most recent call first):
  /home/mego-ros2/microros_ws/firmware/mcu_ws/install/rcutils/share/rcutils/cmake/rcutilsConfig.cmake:41 (include)
  CMakeLists.txt:27 (find_package)

CMake Error at CMakeLists.txt:93 (message):
  Transport not supported.  Use "serial", "udp", "custom"

---
Failed   <<< rmw_microxrcedds [0.64s, exited with code 1]
make: *** [Makefile:334: colcon_compile] Error 1

it seem to configure with UART not UART1, even though I use the -d 1 option.

ros2 run micro_ros_setup configure_firmware.sh ping_pong -t serial -d 1
echo test
/home/mego-ros2/microros_ws/install/micro_ros_setup
Configuring firmware for freertos platform stm32MakefileTest
Using serial device USART.
Configured serial mode with agent at USART
pablogs9 commented 3 years ago

Rebuild all from scratch, create a new micro_ros_setup workspace.

Needrom commented 3 years ago

tough way to rebuild when I try to create the firmware again. The last time a create the firmware I try for multiple time to get it done. If anything a I should know before I create the firmware so I can make it easy.

Creating firmware for freertos platform olimex-stm32-e407
reading in sources list data from /etc/ros/rosdep/sources.list.d
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/base.yaml
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/python.yaml
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/ruby.yaml
ERROR: unable to process source [https://raw.githubusercontent.com/ros/rosdistro/master/releases/fuerte.yaml]:
    Failed to download target platform data for gbpdistro:
    <urlopen error timed out>
Query rosdistro index https://raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml
Skip end-of-life distro "ardent"
Skip end-of-life distro "bouncy"
Skip end-of-life distro "crystal"
Add distro "dashing"
Skip end-of-life distro "eloquent"
Add distro "foxy"
ERROR: error loading sources list:
    <urlopen error <urlopen error [Errno 0] Error> (https://raw.githubusercontent.com/ros/rosdistro/master/foxy/distribution.yaml)>

1614046828(1)

recreate the firmware was killing all time, not finish download every component yet.

pablogs9 commented 3 years ago

Please check:

Needrom commented 3 years ago

Please check:

OK thanks

checking the other question for now. can't even rosdep update.Didn't know why.

Needrom commented 3 years ago

Can you add an option which the micro_ros_setup create_firmware.sh can keep download git repo if it failed ? because if it failed I may delete the firmware and run it again.For my poor network.

pablogs9 commented 3 years ago

Sorry, we have not planned to implement this feature, if you improve the micro-ROS build system, feel free to contribute with a PR.

Needrom commented 3 years ago

OK, may be later. have to take some time to test it. But I just download it one by one to the firmware.and the environment not is working.

But the problem is still here. The code can get here ,at the line 208 in file freertos.c

for(;;)
209   {
210     printf("into the printf \r\n");
211     if (eTaskGetState(xHandle) != eSuspended && availableNetwork)
212     //if(1)
213     {
214         HAL_GPIO_WritePin(GPIOF, GPIO_PIN_10, GPIO_PIN_SET);
215         osDelay(150);
216         HAL_GPIO_WritePin(GPIOF, GPIO_PIN_10, GPIO_PIN_RESET);
217         osDelay(150);
218         HAL_GPIO_WritePin(GPIOF, GPIO_PIN_9, GPIO_PIN_SET);
219         osDelay(150);
220         HAL_GPIO_WritePin(GPIOF, GPIO_PIN_9, GPIO_PIN_RESET);
221         osDelay(150);
222     }
223     else {
224 //        HAL_GPIO_WritePin(GPIOF, GPIO_PIN_10, GPIO_PIN_SET);    
225 //      osDelay(1000);
226 //      HAL_GPIO_WritePin(GPIOF, GPIO_PIN_10, GPIO_PIN_RESET);
227 //      osDelay(1000);  
228         HAL_GPIO_WritePin(GPIOF, GPIO_PIN_9, GPIO_PIN_SET);
229         osDelay(1000);
230         HAL_GPIO_WritePin(GPIOF, GPIO_PIN_9, GPIO_PIN_RESET);
231         osDelay(1000);
232     }
233   }

and the led is right to blink.

but the appMain may not working. and the printf after the

osThreadNew(appMain, NULL, &attributes);

is disappear.

pablogs9 commented 3 years ago

Check your stack, how many bytes have you configured for your main stack and for appMain stack?

Try to increase the attributes.stack_size

Needrom commented 3 years ago

I may think 3 * 10000 is big enough. but still not working.

osThreadAttr_t attributes;
  memset(&attributes, 0x0, sizeof(osThreadAttr_t));
  attributes.name = "microROS_app";
  attributes.stack_size = 3 * 10000;
  attributes.priority = (osPriority_t)osPriorityNormal1;
  printf("before appMain \r\n");
  osThreadNew(appMain, NULL, &attributes);
  Retarget_Init(&huart1);
  osDelay(500);
  char ptrTaskList[500];
  vTaskList(ptrTaskList);
  printf("**********************************\n");
  printf("Task  State   Prio    Stack    Num\n");
  printf("**********************************\n");
  printf(ptrTaskList);
  printf("**********************************\n");
pablogs9 commented 3 years ago

And can you debug where is your micro-ROS app failing?

Needrom commented 3 years ago

Sorry for learning openocd recently.No use it before

when I set the break after the while here, like the break at 39, it seem to stuck in the while

30              UART_HandleTypeDef * uart = (UART_HandleTypeDef*) transport->args;                                                                 │
   │31                                                                                                                                                 │
   │32              HAL_StatusTypeDef ret;                                                                                                             │
   │33              if (uart->gState == HAL_UART_STATE_READY){                                                                                         │
B+>│34                  ret = HAL_UART_Transmit_DMA(uart, buf, len);                                                                                   │
   │35                  while (ret == HAL_OK && uart->gState != HAL_UART_STATE_READY){                                                                 │
   │36                  osDelay(1);                                                                                                                    │
   │37                  }                                                                                                                              │
   │38                                                                                                                                                 │
b+ │39                  return (ret == HAL_OK) ? len : 0;                                                                                              │
   │40              }else{                                                                                                                             │
   │41                  return 0;                                                                                                                      │
   │42              }                    
pablogs9 commented 3 years ago

It seems that your serial transport is not sending data. Have you tried to send data over DMA? Have you changed any configuration related?

Needrom commented 3 years ago

It seems that your serial transport is not sending data. Have you tried to send data over DMA? Have you changed any configuration related?

Actually B+>│34 ret = HAL_UART_Transmit_DMA(uart, buf, len); this line will send a little bit. in HEX

7E 00 00 18 00 80 00 00 00 00 01 10 00 58 52 43 45 01 00 01 0F 06 C3 81 83 81 00 FC 01 6A B5 

in Str

~€XRCE脕儊?j?
pablogs9 commented 3 years ago

That's correct, this is the XRCE init frame. So if this is being sent over the serial the agent should answer with a "session ok" message.

The point is why is it hanging in the while (ret == HAL_OK && uart->gState != HAL_UART_STATE_READY)?

Needrom commented 3 years ago

That's correct, this is the XRCE init frame. So if this is being sent over the serial the agent should answer with a "session ok" message.

The point is why is it hanging in the while (ret == HAL_OK && uart->gState != HAL_UART_STATE_READY)?

Yes the state seem to stay in the HAL_UART_STATE_TX

pablogs9 commented 3 years ago

Maybe you should review your serial device configuration because it should exit HAL_UART_STATE_TX as soon as all bytes are sent.

Have you checked if the len in this function is correct? The function should send len bytes from buf.

Needrom commented 3 years ago

All serial device configuration is auto generate, some relate function which may change the serial option had comment.And the uart->gState as usual.

and the len here is 31

33              if (uart->gState == HAL_UART_STATE_READY){                                                                 │
   │34                  ret = HAL_UART_Transmit_DMA(uart, buf, len);                                                           │
   │35                  while (ret == HAL_OK && uart->gState != HAL_UART_STATE_READY){                                         │
B+>│36                  osDelay(1);                                                                                            │
   │37                  }                                                           
Needrom commented 3 years ago

yeah thanks a lot .I fix that with add global interrupt for usart, and Then it won't stuck in the state of TX.

setting

and it can connect now