Any and all code for the DACERI (DAta CEnter Robot Inspector) project in affiliation with Jefferson Lab.
- Download the respective file based on OS and architecture: https://github.com/google-deepmind/mujoco/releases
- Extract the file, and run simulate inside the extracted folder. Mujoco simulator should run
- Clone this repository
- Go into the sim/ directory
- Drag-and-drop any .xml into the simulator
- Clone this repository
- Go into the designs/ directory
- Choose any design you'd like
- Open in any CAD software, make changes, and export as STL
- Use a program like UltiMaker Cura or Prusa Slicer and slice the STL file into GCODE
- Run the GCODE file on a 3D printer
- Clone this repository on both the client computer and the robot's R-Pi
- On the robot's R-Pi, run the following steps according to your desired setup:
- Run this first:
python -m venv ./.venv --system-site-packages pip install -r /path/to/daceri/libs/requirements.txt source ./.venv/bin/activate
- UDP Server (Modify the IP Address in the udp-server.py file to the IP of the R-Pi):
python /path/to/daceri/scripts/udp-server.py
- Websockets Server:
python /path/to/daceri/scripts/websockets.py
- Run this first:
- Go into the scripts/ directory
- Use the provided Dockerfile (Wiki: How to download and install Docker) to automatically setup the correct packages and libraries or use a Linux/MacOS system with Python installed
- Container:
cd ./robot-project docker build -t robot-container . docker run -v `pwd`:/work/robot:Z -v /dev/input:/dev/input:ro --rm -it robot-container:latest
- Host System (Linux/MacOS):
python -m venv --system-site-packages ./.venv source ./.venv/bin/activate pip install -r /path/to/daceri/libs/requirements.txt
- Container:
- Plug in a controller (OS-dependent; usually Linux works the best)
- Run the RobotController.py file (under the scripts/ subdirectory) with the desired connection type:
- Serial (Controller is plugged into the Raspberry Pi):
python RobotController.py s
- Websockets:
python RobotController.py w [R-Pi IPv4 address]
- UDP Sockets:
python RobotController.py u [R-Pi IPv4 address]
- Serial (Controller is plugged into the Raspberry Pi):
- Press the right joystick to activate the motors
- Start moving the joysticks to move the robot!
Use the Logitech F310 Game Controller connected to the local RaspPi 4B and control the JLab DACERI robot with the REV Control Hub.
git submodule update --init # Clone the submodules
-
hiddapi
: The underlying system-level support for python packagehid
. Afterdnf/apt install hid
, if you still see the python import error such as cannot find certain .so/.dll files, you will need to compile and install thehidapi
library by your self. Follow the docstrings in detect_joystick.py to see the process. -
REVHubInterface
: The Python module for the REV Control Hub. By runningpython -m REVHubInterface
, you should be able to see a GUI that can take the inputs from the GUI and control the Robot motors.
- motor_test.py: Control one of the wheels (motors) with
REVHubInterface
without launching the GUI. If succeeded, the wheel will run for 3 seconds. - detect_joystick.py: Use the Python
hid
library to detect the Logitech F310 Game Controller, translate its inputs to a string and print the string to the screen.
If you can print the gampad's vendor id and product id to the screen but it raises HIDException
"Unable to open device", that is related to the permission for the device.
Check it with ls -l /dev/hidraw*
(hidraw1
in our case). If it’s owned by root
or another group, the user can’t access it. Fix it by:
- Create a udev rule:
sudo nano /etc/udev/rules.d/99-logitech-f310.rules
- In this rule file, add:
Replace the
SUBSYSTEM=="hidraw", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c216", MODE="0666"
idVendor
andidProduct
with the HEX outputs of the Python file. - Reload the rule
sudo udevadm control --reload sudo udevadm trigger
Rerun the Python script and the HIDException
error should be gone.