Skip to content

Latest commit

 

History

History
218 lines (174 loc) · 6.09 KB

File metadata and controls

218 lines (174 loc) · 6.09 KB

Robot5A Raspberry Pi - ROS2 Control and Hardware Integration

This repository contains the code and configuration necessary for the Raspberry Pi to act as the hardware control interface for the Robot5A robotic arm. The Raspberry Pi handles the ROS2 Control framework and integrates with the SlushEngine to drive the stepper motors of the arm. This setup is designed to work with ROS2 Humble on Ubuntu 22.04.


Table of Contents


Project Overview

This repository is part of the Robot5A project and focuses on the Raspberry Pi hardware interface. The Raspberry Pi communicates with the SlushEngine, which controls the stepper motors, and runs the ROS2 Control stack to receive and execute commands from the central controller on a remote Ubuntu machine.

Key Components

  • SlushEngine: Hardware driver board for stepper motors.
  • ROS2 Control: Framework to manage hardware abstraction and control commands.
  • Visual Servoing: The Raspberry Pi relies on visual joint state feedback from a remote system.

Features

  • Integration with SlushEngine for precise stepper motor control.
  • ROS2 hardware interface to bridge ROS2 controllers and the SlushEngine.
  • Modular configuration with YAML files for controllers and URDF descriptions.
  • Support for networked ROS2 communication between the Raspberry Pi and a central controller.

Hardware Requirements

  • Raspberry Pi 4B with Ubuntu 22.04 (64-bit).
  • SlushEngine Model D for stepper motor control.
  • Stepper Motors (compatible with the SlushEngine).
  • Ethernet or Wi-Fi connectivity for ROS2 communication.

Software Prerequisites

Before setting up this project, ensure the following are installed on your Raspberry Pi:

  1. ROS2 Humble
    Follow the ROS2 Humble installation guide for Ubuntu 22.04.

  2. Python 3
    Install Python and its dependencies:

sudo apt update
sudo apt install -y python3 python3-pip
  1. Git Install Git for version control:
sudo apt install -y git

Setup Guide

Clone the Repository

Start by cloning this repository onto your Raspberry Pi:

cd ~
git clone https://github.com/ABMI-software/Robot5A-RaspberryPi.git
cd Robot5A-RaspberryPi

Install Dependencies

  1. Install ROS2 Dependencies Run the following to install ROS2 dependencies:
sudo apt install -y python3-colcon-common-extensions ros-humble-ros2-control ros-humble-ros2-controllers
  1. Install SlushEngine Dependencies Follow these steps to set up the SlushEngine:
sudo apt install -y python3-pip i2c-tools
pip3 install spidev
git clone https://github.com/Roboteurs/slushengine.git
cd slushengine
python3 setup.py install
  1. Enable I2C and SPI Interfaces Enable I2C and SPI on the Raspberry Pi:
sudo raspi-config
Navigate to Interface Options and enable I2C and SPI.

Configure the Raspberry Pi

  1. Build the ROS2 Workspace Build the workspace after cloning the repository:
cd ~/Robot5A-RaspberryPi
colcon build --packages-select R5A_hardware
source install/setup.bash
  1. Verify ROS2 Installation Test that ROS2 is working by running:
ros2 topic list

Connect to the SlushEngine

  1. Connect the SlushEngine to the Raspberry Pi via GPIO.
  2. Test the Connection Run the following test script:
python3 src/R5A_hardware/scripts/slush_test.py
This script will initialize the motors and execute basic movement commands.

Network Setup for ROS2 Communication

  1. Assign Static IPs Ensure the Raspberry Pi and your Ubuntu computer are on the same network. Assign static IPs if necessary.

  2. Enable ROS2 Multicast Configure ROS2 to use multicast for discovery:

export ROS_DOMAIN_ID=1
  1. Test ROS2 Talker-Listener On the Raspberry Pi, run:
ros2 run demo_nodes_py talker

On your Ubuntu machine, run:

ros2 run demo_nodes_py listener

Directory Structure

Robot5A-RaspberryPi/
├── config/
│   ├── controllers.yaml           # Controller configuration
│   ├── robot_description.urdf     # Robot description
│   └── ros2_control_config.yaml   # Hardware interface configuration
├── launch/
│   ├── controller_manager.launch.py
│   ├── hardware_interface.launch.py
│   └── robot_state_publisher.launch.py
├──  R5A_hardware/
│   │   ├── __init__.py
├── src/
│   ├── slush_engine_hardware.py
├── scripts/
│   └── slush_test.py               # Test script for SlushEngine
├── README.md                       # This README file
├── setup.py                        # Package setup file
└── package.xml                     # ROS2 package metadata

Usage

Launch Files

  • Start Hardware Interface:
ros2 launch R5A_hardware hardware_interface.launch.py
  • Start Controller Manager:
ros2 launch R5A_hardware controller_manager.launch.py
  • Publish Robot State:
ros2 launch R5A_hardware robot_state_publisher.launch.py

Testing the Hardware Interface

Run the SlushEngine test script to verify motor control:

python3 src/R5A_hardware/scripts/slush_test.py

Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository.
  2. Create a feature branch.
  3. Submit a pull request.

License

This project is licensed under the MIT License.