micro-ROS / micro-ROS/micro_ros_arduino

Micro ros image subscriber issue

Open
#1,850 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C
Stars
576
Forks
146
PR merge metrics
No merged PRs in 30d

Description

## Issue template

- Hardware description: ESP32
- RTOS:
- Installation type: arduino ide
- Version or commit hash: humble

#### Steps to reproduce the issue

#### Expected behavior
I want a subscriber listen to a image topic.

#### Actual behavior
rclc_executor_spin_some returns RMW_RET_ERROR.

#### Additional information
I've working on it for hours, have no idea how to subscribe to a image topic, but I've successes on publish an image topic on micro ros. Even if I let subscription_callback() do nothing the rclc_executor_spin_some will still returns RMW_RET_ERROR.

here is my code on subscribe an image topic :
```
#include

#include
#include
#include
#include
#include

#include
#include

rcl_subscription_t subscriber;
sensor_msgs__msg__Image msg;
rclc_executor_t executor;
rclc_support_t support;
rcl_allocator_t allocator;
rcl_node_t node;
rcl_timer_t timer;

#define LED_PIN 13

#define RCCHECK(fn) { rcl_ret_t temp_rc = fn; if((temp_rc != RCL_RET_OK)){error_loop();}}
#define RCSOFTCHECK(fn) { rcl_ret_t temp_rc = fn; if((temp_rc != RCL_RET_OK)){}}

void error_loop(){
while(1){
digitalWrite(LED_PIN, !digitalRead(LED_PIN));
delay(100);
}
}

void subscription_callback(const void * msgin){

}

void setup() {
set_microros_transports();

pinMode(LED_PIN, OUTPUT);
digitalWrite(LED_PIN, HIGH);

delay(2000);

allocator = rcl_get_default_allocator();

//create init_options
RCCHECK(rclc_support_init(&support, 0, NULL, &allocator));

// create node
RCCHECK(rclc_node_init_default(&node, "micro_ros_arduino_node", "", &support));

// create subscriber
RCCHECK(rclc_subscription_init_default(
&subscriber,
&node,
ROSIDL_GET_MSG_TYPE_SUPPORT(sensor_msgs, msg, Image),
"micro_ros_subscriber"));

// create executor
RCCHECK(rclc_executor_init(&executor, &support.context, 1, &allocator));
RCCHECK(rclc_executor_add_subscription(&executor, &subscriber, &msg, &subscription_callback, ON_NEW_DATA));
}

void loop() {
delay(100);
RCCHECK(rclc_executor_spin_some(&executor, RCL_MS_TO_NS(100)));
}

Contributor guide

Open the contributing guide

Research direction

Start with the Arduino sketch and trace setup() through rclc_subscription_init_default(), rclc_executor_add_subscription(), and the rclc_executor_spin_some() call in loop(). Compare the sensor_msgs/msg/image.h subscription setup with the micro-ROS Arduino examples and inspect the returned RMW error. Done means a Humble ESP32 subscriber can receive the image topic without rclc_executor_spin_some() returning RMW_RET_ERROR.

Written by the indexing model from the issue text.

Assessment

Tech stack
arduino, c
Domain
embedded-iot
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.