{"id":15020604,"url":"https://github.com/mataruzz/ros2_servo_motion","last_synced_at":"2026-02-26T02:36:49.460Z","repository":{"id":194161805,"uuid":"672206671","full_name":"mataruzz/ROS2_servo_motion","owner":"mataruzz","description":"Micro-servo S90 ROS2 hardware interface for RaspberryPi 3B+.","archived":false,"fork":false,"pushed_at":"2023-10-29T12:47:48.000Z","size":39070,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"humble","last_synced_at":"2025-04-13T10:44:34.981Z","etag":null,"topics":["guide","hardware-interface","raspberry-pi-3","ros2","servo-motor","ubuntu-server"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mataruzz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-07-29T09:25:29.000Z","updated_at":"2024-10-07T17:14:56.000Z","dependencies_parsed_at":"2024-11-07T20:06:57.690Z","dependency_job_id":"145574e0-ec1a-4338-b47f-f003ccb7de37","html_url":"https://github.com/mataruzz/ROS2_servo_motion","commit_stats":{"total_commits":33,"total_committers":2,"mean_commits":16.5,"dds":"0.18181818181818177","last_synced_commit":"c658bccd6e615328ef2509a718987bce668d5dfb"},"previous_names":["mataruzz/ros2_servo_motion"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mataruzz/ROS2_servo_motion","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mataruzz%2FROS2_servo_motion","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mataruzz%2FROS2_servo_motion/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mataruzz%2FROS2_servo_motion/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mataruzz%2FROS2_servo_motion/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mataruzz","download_url":"https://codeload.github.com/mataruzz/ROS2_servo_motion/tar.gz/refs/heads/humble","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mataruzz%2FROS2_servo_motion/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266580495,"owners_count":23951230,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-22T02:00:09.085Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["guide","hardware-interface","raspberry-pi-3","ros2","servo-motor","ubuntu-server"],"created_at":"2024-09-24T19:55:19.600Z","updated_at":"2026-02-26T02:36:49.432Z","avatar_url":"https://github.com/mataruzz.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Micro-servo S90 hardware interface for RaspberryPi 3B+\n\u003cp align=\"center\"\u003e\n  \u003cimg width = \"150\" src=\"./doc/images/micro-servo-motor-sg90.jpg\"\u003e\n\u003c/p\u003e\nThe micro-servo S90 is a small, lightweight motorized device commonly used with Raspberry Pi or Arduino boards to control the precise movement of mechanical parts. It is compact, low-cost, and ideal for applications such as robotics, automation, and remote-controlled systems.\n\nThe \u003cem\u003eprimary objective\u003c/em\u003e of this repository is to develop and incorporate the hardware interface, enabling the utilization within the ROS2 (Robot Operating System) framework.\n\n\u0026NewLine;\n\nFor a better understanding and simple control (outside ROS) of the micro servo, see my other github project [S90_servo_motor](https://github.com/mataruzz/raspberryPi_components_tests/tree/main/S90_servo_motor), or looks at other [examples](https://www.circuitbasics.com/how-to-use-servos-on-the-raspberry-pi/).\n\n\n## Implementation\nTo control the servo position it has used the \"ros2_control\" framework, specifically implementing the ***forward position controller*** hardware interface.\n\nIn addition, it has been integrated the **WiringPi** library for communicate with the servo on the RaspberryPi.\n\n\n## Configuration and Setup\nTo \u003cstrong\u003eenable\u003c/strong\u003e the utilization of this repository, the micro-servo S90's PWM wire \u003cstrong\u003emust be connected\u003c/strong\u003e to \u003cstrong\u003ePIN 5\u003c/strong\u003e (GPIO's pin enumeration, corresponding to physical PIN 29).\n\n\u003cp align=\"center\"\u003e\n  \u003cimg width = \"400\" src=\"./doc/images/gpio_pinout.png\"\u003e\n\u003c/p\u003e\n\n### Used System\nThis repository has been designed for use with the following hardware and software:\n- Raspberry Pi 3B+\n- Ubuntu Server 22.04 LST\n- ROS2 Humble\n\n### Installation \nOnce the hardware connection is ensured, access to the Raspberry (e.g., SSH) and:\n\n* Clone the wiringPi repository, since the installation from apt may not work, and build it:\n```\ncd ~/\ngit clone https://github.com/WiringPi/WiringPi.git\ncd ~/WiringPi \u0026\u0026 ./build\n```\n\n* Clone the servo repository both on your PC (to visualize the simulation) and Raspberry (to send actual signals):\n```\ncd ~/\ngit clone https://github.com/mataruzz/ROS2_servo_motion \n```\nand install all the dependent libraries:\n```\nrosdep install --from-paths src --ignore-src -r -y\n```\n* Build the repository (limitating the number of threads) on the Raspberry:\n```\ncd ~/ROS2_servo_motion\ncolcon build --parallel-workers 2 --executor sequential\n```\n### Run the example\nIn the following example, 5 positions are defined and iteratively passed to the controller.\n\n***Inside the RaspberryPi***:\n\n* Source the ws: \n```\ncd ~/ROS2_servo_motion\nsource install/setup.bash\n```\n* Run the controllers:\n```\nros2 launch ros2_servo_motion S90_servo.launch.py\n```\n* Run the example:\n```\nros2 launch ros2_servo_motion test_fordware_position_controller.launch.py\n```\nAnother way to send to the controller the target position is to write directly on the controller topic:\n```\nros2 topic pub /forward_position_controller/commands std_msgs/msg/Float64MultiArray \"data:\n- 3.14\"\n```\nThe above example script nothing does more than sending to the controller the desired position every second.\n\n***On your PC:*** \n* Open Rviz:\n```\nrviz2 -d ~/ROS2_servo_motion/src/description/config/config.rviz\n```\nYou will see the following model:\n\u003cp align=\"center\"\u003e\n  \u003cimg width = \"350\" src=\"./doc/images/S90_mservo_rviz.png\"\u003e\n\u003c/p\u003e\n\n\n\n## Expected result\nIf everything works as expected, you should be able to see the physical micro-servo S90 moving to 5 different positions ([0, 0.785, 1.57, 2.36, 3.14] rads), in loop.\nIn addition, the movement will be also simulated in the RViz environment, as shown below:\n\n\u003cp align=\"center\"\u003e\n  \u003cimg width = \"350\" src=\"./doc/gifs/h_i_example.gif\"\u003e\n\u003c/p\u003e\n\n## **Pros** and **Cons**\n To provide a clear and structured assessment, you can find pros and cons in the following table:\n\n\u003cp align=\"center\"\u003e\n\n|    \u003cp align=\"center\"\u003e **Pros**   \u003c/p\u003e    |           \u003cp align=\"center\"\u003e **Cons**   \u003c/p\u003e               |\n|:-------------|---------------------------|\n| **Hardware Integration:** The capacity to effectively communicate with physical devices is demonstrated through the construction of a hardware interface for the micro servo S90. |   **Scalability Concerns:** You can run into scalability problems that need to be handled if you integrate more hardware or devices into your project. \u003cbr/\u003e  \u003cbr /\u003e |\n| **Raspberry Pi Compatibility:** As a control platform, the Raspberry Pi 3B+ offers a variety of advantages, including as price, a strong community and ecosystem, and usability. \u003cbr /\u003e \u003cbr /\u003e \u003cbr /\u003e | **Limited Control Precision:** It is difficult to achieve high precision when feedback mechanisms is missing. Due to the lack of a closed loop control system, the current configuration of the project is susceptible to disturbances and inaccuracies in servo positioning, which can restrict precision and robustness. |\n| **Open Source Framework (ROS2) compatibility:** Embracing ROS2 simplifies integration with hardware interfaces and opens a framework that is modular, reusable, and reliable. As part of the ROS2 community, you have access to a vast network of experts, collaborators, and enthusiasts. | **Lack of Trajectory Tracking:** The lack of trajectory control means that the servo cannot smoothly follow a predefined path or perform complex motions. This is often important in applications that require dynamic and precise behavior. \u003cbr /\u003e \u003cbr /\u003e |\n| **Position Control:** Achieving open-loop position control, even if simple and inaccurate, is an important part of advanced control technology and indicates progress toward project goals. |     **Presence of Jitter:** A notable drawback is the presence of jitter caused by using an inaccurate square wave for control (generated by the RaspberryPi 3B+). This can lead to unwanted fluctuations and instability.   |\n\n\u003c/p\u003e\n\n\u003cbr /\u003e\n\u003cbr /\u003e\n\n## Future developement:\nLooking to the future of this project, I would like to pursue several goals.\n\nFirst, I want to enhance the functionality of the system by adding other servos and building a simple 2 degrees of freedom (2DOF) structure. This will provide me the ability to control a possible camera's movements in both the horizontal (right and left) and vertical (up and down) axes, which may be helpful for analyze the surrounding environment.\n\nAdditionally, I would like to explore other control methods, such as velocity control and, if practical, closed-loop control. Implementing these control approaches requires access to the necessary sensor data, such as potentiometer values, speed and time measurements. \n\nFurthermore, I recognize the need to address system jitter, which can affect camera stability.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmataruzz%2Fros2_servo_motion","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmataruzz%2Fros2_servo_motion","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmataruzz%2Fros2_servo_motion/lists"}