Skip to content

Add angle-based servo control example#3

Open
dbaldwin wants to merge 2 commits intomainfrom
add-servo-pwm-example
Open

Add angle-based servo control example#3
dbaldwin wants to merge 2 commits intomainfrom
add-servo-pwm-example

Conversation

@dbaldwin
Copy link
Copy Markdown
Contributor

@dbaldwin dbaldwin commented Apr 28, 2026

Summary

  • Adds examples/example_servo_angle.py, a small rclpy client that drives a PCA9685 channel by angle (0-180°) via /dexi/servo_control.
  • Uses the service's natural angle interface; pulse-width range falls back to the node's defaults (500-2500 µs) unless --min-pw / --max-pw are passed.
  • CLI: python3 example_servo_angle.py <channel> <angle> [--min-pw US] [--max-pw US] (defaults: channel 0, angle 90).

Test plan

  • Launch the servo node: ros2 launch dexi_cpp servo_controller.launch.py
  • Run python3 examples/example_servo_angle.py 0 90 and confirm the servo on channel 0 centers
  • Sweep a channel through 0 / 90 / 180 and confirm endpoints + center
  • Run with --min-pw 1000 --max-pw 2000 and verify the narrower range is honored
  • Confirm out-of-range channel (e.g. 16) or angle (e.g. 200) returns success=false

@dbaldwin dbaldwin changed the title Add example for sending raw PWM pulse widths to servo node Add angle-based servo control example Apr 28, 2026
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.

1 participant