micro-ROS / micro-ROS/micro-ROS-demos

ping_pong rand() is not seeded so device ids are likely the same across nodes

Open Beginner friendly
#97 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C
Stars
101
Forks
35
Avg merge
4d 16h
Merged PRs (30d)
3

Description

## Issue template

- Hardware description: docker only
- RTOS: N/A
- Installation type: a containerized version of https://micro.ros.org/docs/tutorials/core/first_application_linux/
- Version or commit hash: b86db303dd7aed7ed34de2e1c2f94300c2ba7e4e
+ this patch to fix the stack corruption https://github.com/micro-ROS/micro-ROS-demos/pull/96

#### Steps to reproduce the issue
Build this repo on your target
```
cd /ros2_ws
. /opt/ros/humble/setup.bash
. install/local_setup.bash
colcon build --packages-select micro_ros_demos_rclc
/ros2_ws/install/micro_ros_demos_rclc/lib/micro_ros_demos_rclc/ping_pong
```

#### Expected behavior
I expect to see ping/pong messages

#### Actual behavior

You will see only Ping or only Pong messages

#### Additional information
Running on Ubuntu 24.04 host, docker compose driving a pair of containers to pubsub.

---

In my testing, seeding random with a nanosecond clock is sufficient to generate different device ids. I'd file a PR but I'd like to see if this was intended or maybe just an artifact of launching two container simultaneously

Contributor guide

Open the contributing guide

Research direction

Start with the ping_pong executable in the micro_ros_demos_rclc package and follow how its device IDs and rand() state are initialized. Reproduce the issue using the provided colcon build and container commands, then verify that the two containers exchange both Ping and Pong messages with distinct IDs.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
distributed-systems, embedded-iot
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.