Giter Site home page Giter Site logo

keyonjerome / ros2-pi-leds Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 334 KB

ROS2 LED strip controller written in C++ using pigpio with button input for switching colors.

CMake 6.00% C++ 18.45% C 3.49% Python 3.06% Shell 0.47% JavaScript 54.85% HTML 13.68%

ros2-pi-leds's Introduction

ROS2 LED Strip Controller

This project is a ROS2 LED Strip controller written in C++ using pigpio with button input for switching colors, running with pigpio on a Raspberry Pi Model 3B+.

Design

  • The led_strip_output node defines a subscriber for "led_controller1/new_color", a std_msgs::msg::ColorRGBA object. Upon receipt of a new color by any publisher, the node will set the LED strip to that color.
  • The button_pub node defines a publisher for "led_controller1/new_color" according to GPIO input from a pushbutton. Depending on which color is next in the queue, a button press will immediately publish a new color. The color rotation goes as follows: White → Red → Blue → Purple → Medium Slate Blue → Off → White. New colors can be added in the button_pub.cpp file in the node's constructor.

Equipment

Hardware Setup

pigpio uses Broadcom numbers for addressing the Raspberry Pi's GPIO outputs. The GPIO arrangement diagram for each Raspberry Pi distribution is available here. The following GPIO constants can be changed in their corresponding header files.

  • LED Strip:
    • Red: GPIO 2
    • Green: GPIO 3
    • Blue: GPIO 4
  • Pushbutton: GPIO 17

Requirements

Installation and How To Run

  1. Make sure ROS2 Galactic and pigpio are installed onto your Raspberry Pi. pigpio-master should be in your home/user directory (~/), as the CMakeLists.txt configuration searches for it there.
  2. Clone this repository and after sourcing your ROS2 installation (source /opt/ros/galactic/setup.bash), run colcon build in the ROS2CPP/led_strip_controller repository folder.
  3. Open a new terminal.
  4. Enter your root shell using sudo -i. This is required for pigpio GPIO setting.
  5. Navigate to the repository directory in the new shell.
  6. In a new terminal, install the newly built package using . install/setup.bash from within the ROS2CPP/led_strip_controller repository folder.
  7. Before running the program, kill all currently running pigpio processes: killall pigpiod
  8. Run the program with ros2 launch led_strip_controller led_launch.py.

Running on Raspberry Pi Startup (Ubuntu 20.04 Systemd)

  1. In both startup_script.sh, and controller_startup.service, change the references to this repository's files to match where you downloaded this repository.
  2. Give the system permissions to run startup_script.sh: sudo chmod 775 [your_path]/ros2-pi-leds/startup_script.sh
  3. Copy controller_startup.service to /etc/systemd/system/ (e.g: sudo cp controller_startup.service /etc/systemd/system/).
  4. Enable the service from the terminal with sudo systemctl enable controller_startup.service. To start the service at the same time, run sudo systemctl --now enable controller_startup.service

ros2-pi-leds's People

Contributors

keyonjerome avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.