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

Nobody has claimed this yet.

Assessment

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

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.

Description

Issue template

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

Dominant language
C
Stars
101
Forks
35
Avg merge
4d 16h
Merged PRs (30d)
3

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from micro-ROS/micro-ROS-demos

All issues in micro-ROS/micro-ROS-demos

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.