Skip to content

Probe motor implementation#47

Open
devasilmy wants to merge 56 commits intomainfrom
probe-motor
Open

Probe motor implementation#47
devasilmy wants to merge 56 commits intomainfrom
probe-motor

Conversation

@devasilmy
Copy link
Copy Markdown
Collaborator

@devasilmy devasilmy commented Jan 28, 2026

Summary

This PR implements the core control logic for the LMDCE421 Stepper Motor (Probe Motor). It establishes a hardware abstraction layer using a Factory Pattern, allowing the system to switch between a Modbus TCP-based hardware driver and a simulated motor environment. It also introduces the nav node, which manages autonomous probe deployment and retraction cycles during rover surveying.


Related Task

Closes Notion Task


Type of Change

  • 🆕 Feature (Initial implementation of Probe Motor control)
  • 🧹 Refactor (Abstraction of sensors into a Factory pattern)
  • 🧾 Documentation Update (New documentation added: rpi-ip-setup-for-motor.md, probe-motor.md)
  • 🐞 Bug Fix
  • 🧰 Maintenance / Tooling

📄 Documentation

All of the following applicable documentation changes were added

  • How to connect the new device and wiring see
  • Links to external documentation on the device
  • Any other setup or important information (Configuration via sensors.json)
  • No documentation changes required

Requirements Updated

  • requirements.txt has been updated with pymodbus and pyserial.

🧪 Testing

1. Simulation Testing:

  • Configured sensors.json with "mode": "sim".
  • Executed ros2 launch embr embr_launch.py.
  • Verified that the nav node correctly waits for ProbeMotorFeedback and handles simulated deployment delays

2. Hardware Integration (Modbus TCP):

  • Configured sensors.json with "mode": "real".
  • Verified 32-bit register read/writes
  • Commands tested:

✅ Pre-Merge Checklist

  • PR started as a Draft
  • Linked to correct Notion Task
  • Branch includes updated documentation
  • Code reviewed by peer
  • Ready for final review by Software Lead
  • All tests and builds pass
  • Notion task updated to Ready for Review

🧾 Notes (Optional)

  • Concurrency: The probe_stepper_server node now utilizes a MultiThreadedExecutor and ReentrantCallbackGroup to prevent deadlocks during long-running motor movements.
  • Architecture: The nav.py script uses a dedicated thread for the survey loop to keep the main ROS2 executor responsive to incoming feedback messages.

@devasilmy devasilmy requested a review from mrichards03 January 28, 2026 06:44
@devasilmy devasilmy closed this Jan 28, 2026
@devasilmy devasilmy reopened this Jan 28, 2026
This ros2 node has been revised and added to src/embr/embr as probeMotor.py
Copy link
Copy Markdown
Collaborator

@mrichards03 mrichards03 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll do a more thorough check when you mark the PR as ready for review and when I can test with the actual probe stepper. It looks good so far though! I've left a few comments. Also don't forget about adding python dependencies to the dependencies script for provisioning. I believe pymodbus should be added.

Comment thread Documentation/2025/rpi-ip-setup-for-motor.md Outdated
return SensorFactory.create(sensor_type, config)


class StepperFactory:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This class seems almost identical to the SensorFactory class. Why can't the SensorFactory create the probe stepper motor object? What's the need for another factory?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I totally agree. I'll work on merging the 2 factories together.

@@ -0,0 +1 @@
int32 move_position No newline at end of file
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you need a custom message when the message just contains an int. Just label the topic as having message type int32.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

@devasilmy devasilmy marked this pull request as ready for review April 1, 2026 20:55
Copy link
Copy Markdown
Collaborator

@maisonJar-dev maisonJar-dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great stuff! Just a few miscellaneous fixes but otherwise good to go!

Comment thread Documentation/2025/probe-motor.md
Comment thread ros2_ws/src/embr/embr/sensors/probeMotor.py Outdated
Comment thread ros2_ws/src/embr/embr/sensors/probeMotor.py Outdated
Comment thread Documentation/2025/probe-motor.md
Comment thread ros2_ws/src/embr/config/sensors.json Outdated
"acceleration": 1000000,
"steps_per_distance": 51200,
"motion_range": 10

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

Comment thread ros2_ws/src/msg_interface/action/ProbeStepperOperation.action Outdated
Comment thread ros2_ws/src/embr/embr/sensors/probeMotor.py Outdated
Comment thread ros2_ws/src/embr/embr/sensors/factory.py Outdated
Comment thread ros2_ws/src/embr/embr/sensors/probeMotor.py Outdated
Comment thread ros2_ws/src/embr/embr/sensors/probeMotor.py Outdated
devasilmy and others added 16 commits April 3, 2026 23:47
Co-authored-by: Maison <maison.personal03@gmail.com>
Co-authored-by: Maison <maison.personal03@gmail.com>
Co-authored-by: Maison <maison.personal03@gmail.com>
Co-authored-by: Maison <maison.personal03@gmail.com>
Co-authored-by: Maison <maison.personal03@gmail.com>
Co-authored-by: Maison <maison.personal03@gmail.com>
Co-authored-by: Maison <maison.personal03@gmail.com>
Co-authored-by: Maison <maison.personal03@gmail.com>
Co-authored-by: Maison <maison.personal03@gmail.com>
Co-authored-by: Maison <maison.personal03@gmail.com>
Co-authored-by: Maison <maison.personal03@gmail.com>
Co-authored-by: Maison <maison.personal03@gmail.com>
The action was a previous implementation that was supposed to be removed. The communication type is now changed to a topic.
Added installation command for pymodbus to the script.
Clarified documentation on write_registers function to specify Little-Endian format.
Copy link
Copy Markdown
Collaborator

@maisonJar-dev maisonJar-dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants