88
99#include "esp_log.h"
1010
11+
1112rclcpy_context_t rclcpy_default_context = {
1213 .initialized = false,
1314};
1415
15- static void * microros_allocate (size_t size , void * state ) {
16- (void ) state ;
16+ static void * microros_allocate (size_t size , void * state ) {
17+ (void )state ;
1718 return m_malloc (size );
1819}
1920
20- static void microros_deallocate (void * pointer , void * state ) {
21- (void ) state ;
21+ static void microros_deallocate (void * pointer , void * state ) {
22+ (void )state ;
2223 m_free (pointer );
2324}
2425
25- static void * microros_reallocate (void * pointer , size_t size , void * state ) {
26- (void ) state ;
26+ static void * microros_reallocate (void * pointer , size_t size , void * state ) {
27+ (void )state ;
2728 return m_realloc (pointer , size );
2829}
2930
30- static void * microros_zero_allocate (size_t number_of_elements , size_t size_of_element , void * state ) {
31- (void ) state ;
31+ static void * microros_zero_allocate (size_t number_of_elements , size_t size_of_element , void * state ) {
32+ (void )state ;
3233 size_t total_size = number_of_elements * size_of_element ;
33- void * ptr = m_malloc (total_size );
34+ void * ptr = m_malloc (total_size );
3435 if (ptr != NULL ) {
3536 memset (ptr , 0 , total_size );
3637 }
@@ -65,7 +66,7 @@ void common_hal_rclcpy_init(const char *agent_ip, const char *agent_port, int16_
6566 custom_allocator .allocate = microros_allocate ;
6667 custom_allocator .deallocate = microros_deallocate ;
6768 custom_allocator .reallocate = microros_reallocate ;
68- custom_allocator .zero_allocate = microros_zero_allocate ;
69+ custom_allocator .zero_allocate = microros_zero_allocate ;
6970 // Set custom allocator as default
7071 if (!rcutils_set_default_allocator (& custom_allocator )) {
7172 ESP_LOGW ("RCLCPY" , "allocator failure" );
@@ -77,31 +78,31 @@ void common_hal_rclcpy_init(const char *agent_ip, const char *agent_port, int16_
7778
7879 // Options Init
7980 rclcpy_default_context .init_options = rcl_get_zero_initialized_init_options ();
80- ret = rcl_init_options_init (& rclcpy_default_context .init_options , rclcpy_default_context .rcl_allocator );
81+ ret = rcl_init_options_init (& rclcpy_default_context .init_options , rclcpy_default_context .rcl_allocator );
8182 if (ret != RCL_RET_OK ) {
8283 ESP_LOGW ("RCLCPY" , "Options init failure: %d" , ret );
8384 }
8485 if (domain_id < 0 ) {
8586 mp_raise_RuntimeError (MP_ERROR_TEXT ("Invalid ROS domain ID" ));
8687 }
87- ret = rcl_init_options_set_domain_id (& rclcpy_default_context .init_options , domain_id );
88+ ret = rcl_init_options_set_domain_id (& rclcpy_default_context .init_options , domain_id );
8889 if (ret != RCL_RET_OK ) {
8990 ESP_LOGW ("RCLCPY" , "Options domain failure: %d" , ret );
9091 }
9192
9293 // Set up Agent
9394 rclcpy_default_context .rmw_options = rcl_init_options_get_rmw_init_options (& rclcpy_default_context .init_options );
94- ret = rmw_uros_options_set_udp_address (agent_ip , agent_port , rclcpy_default_context .rmw_options );
95+ ret = rmw_uros_options_set_udp_address (agent_ip , agent_port , rclcpy_default_context .rmw_options );
9596 if (ret != RCL_RET_OK ) {
9697 ESP_LOGW ("RCLCPY" , "Agent options failure: %d" , ret );
9798 }
9899
99100 // Support Init
100101 ret = rclc_support_init_with_options (& rclcpy_default_context .rcl_support ,
101- 0 ,
102- NULL ,
103- & rclcpy_default_context .init_options ,
104- & rclcpy_default_context .rcl_allocator );
102+ 0 ,
103+ NULL ,
104+ & rclcpy_default_context .init_options ,
105+ & rclcpy_default_context .rcl_allocator );
105106 if (ret != RCL_RET_OK ) {
106107 ESP_LOGW ("RCLCPY" , "Initialization failure: %d" , ret );
107108 mp_raise_RuntimeError (MP_ERROR_TEXT ("ROS failed to initialize. Is agent connected?" ));
0 commit comments