GithubHelp home page GithubHelp logo

neuro-mechatronics-interfaces / ros2_reward_dispenser Goto Github PK

View Code? Open in Web Editor NEW
0.0 3.0 0.0 41 KB

A ROS2 node that communicates with a microcontroller running the 'Serial-Relay' code

Python 63.24% C++ 36.76%
nhp python ros2 serial arduino

ros2_reward_dispenser's Introduction

ROS2_Reward_Dispenser

A ROS2 node that communicates with a microcontroller running the 'Serial-Relay' code. Part of the Delta task workspace.

Installation

Make sure ROS2 Galactic or a newer ROS2 distribution is installed on your PC, as well as Python >=3.8, and the Arduino IDE

You will need to install some python packages using pip if the dependencies aren't already met:

pip install pyserial bluetooth asyncio

You may need 3 additional libraries to run the sketch with the weight sensing and LED matrix display: MD_Parola, MD_MAX72XX, and Queuetue HX711 Library. These libraries can be installed using the built-in Library Manager from the Tools > Manage Libraries menu:

  • Queuetue HX711
  • MD_MAX27XX
  • MD_Parola

Clone the repository in your ros workspace, build with colcon, finally source

cd /path/to/ros/workspace/src
git clone https://github.com/Neuro-Mechatronics-Interfaces/ROS2_Reward_Dispenser.git src/ros2_reward_dispenser
colcon build --packages-select reward_dispenser
  • For Windows 10 source using call install/local_setup.bat
  • For UBuntu use source install/setup.bash

Use the Arduino IDE to flash the accompanied serial_relay_scale_LEMatrix.ino script onto the microcontroller.

Device Permissions

Device permissions may also need to be set up if interfacing with a USB device for the first time. Add the user to the dialout and tty groups:

sudo usermod -a -G dialout your-username
sudo usermod -a -G tty your-username
sudo chmod a+rw /dev/ttyACM*

If using the ROS2 node, note the COM port assigned to it for the config file.

Quick Start

To quickly run the node, enter the following command in the terminal:

ros2 run reward_dispenser node

The default serial port is set to /dev/ttyACM0 but is also a configurable parameter. To define a specific port or baudrate, pass it as an argument:

ros2 run reward_dispenser node --ros-args -p port:=/dev/ttyACM0 -p baud:=9600

The parameters can also be defined using the provided example .yaml file and passed as an argument:

ros2 run reward_dispenser node --params-file ~/ros2_ws/src/ros2_reward_dispenser/reward_dispenser/config/reward.yaml

The reward dispener node is monitoring a topic called manual_dispense which will send a 200ms dispense command whenever a new boolean value is published to it.

Troubleshooting

  • If you get the ImportError: You must be root to use this library on linux error message issue, you may need to run the node with admin privilidges. Adding the current user to sudo is an option that should fix it, another option is to create device rules:
pip install git+https://github.com/boppreh/keyboard.git#egg=keyboard
sudo usermod -a -G tty,input $USER
sudo chmod +0666 /dev/uinput
echo 'KERNEL=="uinput", TAG+="uaccess""' > /etc/udev/rules.d/50-uinput.rules
echo 'SUBSYSTEM=="input", MODE="0666" GROUP="plugdev"' > /etc/udev/rules.d/12-input.rules
echo 'SUBSYSTEM=="misc", MODE="0666" GROUP="plugdev"' >> /etc/udev/rules.d/12-input.rules
echo 'SUBSYSTEM=="tty", MODE="0666" GROUP="plugdev"' >> /etc/udev/rules.d/12-input.rules
loginctl terminate-user $USER

If you get an error message relating to the user not being in the input group, run the following command to add user to the required group.

sudo usermod -a -G input USERNAME

ros2_reward_dispenser's People

Contributors

jshulgach avatar

Watchers

Forrest Zachary Shooster avatar Monica Liu avatar  avatar

ros2_reward_dispenser's Issues

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.