space-concordia-robotics / robotics-prototype

Teleoperated Mars rover with autonomous capabilities intended for robotics competitions.
https://spaceconcordia.github.io/robotics.html
25 stars 18 forks source link

Setup

The code in this repo was built around ROS Humble. First install that. Then, from this folder:

Setup venv

Run python3 -m venv ./space-env from the robotics-orin folder.

So you will use this frequently, add the source to your ~/.bashrc: echo "source ${PWD}/space-env/bin/activate" >> ~/.bashrc. That way it will run automatically.

Running arm and wheels controls

First, run sudo ./scripts/configure-can0.sh and sudo ./scripts/configure-arm.sh. The error message "chmod: cannot access '/dev/ttyUSB1': No such file or directory" is normal. Then, run ros2 launch robot/rospackages/launch/robot_ik.py. NOTE: you will likely need to unplug and re-plug in the USB-Serial adapter for the absolute encoders.

Then, on another computer, run ros2 run joy joy_node that is on the same network as the rover, and with a Logitech X3D joystick plugged in (allowing a wider range of input methods is in progress).

Setting up ros2_aruco

Short version

Run these commands:

Long version

To get this working, you may see the following error:

Installing the transforms3d library by hand required. Please run
        sudo pip3 install transforms3d

Run this command (in my case without the sudo and with pip) and it should work. Adding to PYTHONPATH is likely necessary. You will add a command like the following to ~/.bashrc: export PYTHONPATH="/home/marc/Programming/robotics-orin/space-env/lib/python3.10/site-packages:$PYTHONPATH"

Another thing to consider is that while python3-opencv (installed with apt, from rosdep) works with this package, it also works with opencv-python (installed through pip). There is a version difference, which is why there are lines such as if cv2.__version__ < "4.7.0": in the source.

In addition, to allow the camera used for aruco detection to also be streamed, v4l2loopback must be configured and ffmpeg must be present. Install the following: v4l2loopback-dkms, v4l2loopback-utils, v4l-utils, and ffmpeg.

If you have secure boot enabled, there will be additional setup involved (requiring a reboot). These packages might be added to package.xml at some point, but it will need to be added to rosdep, which takes a little while.

To allow simultaneous streaming on another process, set the camera_index and camera_destination_index params in the launch file. They correspond to which index in /dev/video to use. If camera_destination_index is set (to a value which is not -1), it will (attempt) to stream the camera from the source to the destination location (in /dev/video). Now, any other process can load the camera from the destination index.