Skip to content

Latest commit

 

History

History
235 lines (215 loc) · 8.82 KB

LOG.md

File metadata and controls

235 lines (215 loc) · 8.82 KB

Log of Depth Camera Usage Research

Table of Contents

Concepts Learnt

  • ROS Basics: Learn to navigate the ROS environment, including setting up packages, nodes, and topics.
  • Linux Command Line: Master essential Linux commands like ls, cd, grep, and chmod that are frequently used in ROS workflows.
  • Depth Camera Setup: Understand how to connect and configure depth cameras in a ROS environment, including troubleshooting common issues.
  • OpenNI and OpenCV: Explore the usage of OpenNI for depth sensing and OpenCV for image processing, and how they integrate with ROS.
  • Python Scripting in ROS: Learn how to write Python scripts that interact with ROS nodes, process depth data, and handle camera outputs.
  • Virtualisation for ROS: Quick development when software or hardware takes time to setup though lack completeness

QuickStart for automation (WIP)

  1. Run roslaunch astra_camera astra.launch
  2. Run python3 ultrasonic_sensor.py
  3. Run python3 detect_silo.py
  4. Run python3 ros2serial_gripper.py and python3 ros2serial_gripper.py
  5. Turn on motor and gripper power

Virtualisation

Setup ROS2 & OpenNI SDK (Windows 11) (Wasn't used)

  1. Download a VM of your choice (Oracle VirtualBox is used)
  2. Download Ubuntu 22.04 LTS Jammy Jellyfish iso image (so its compatible with ROS2 Humble)
  3. Setup the Ubuntu VM (at least 4GB RAM but 8GB is better, minimum 25GB storage, 4CPU, USB of depth cam need to be added)
  4. Once in Ubuntu, download ROS2 Humble following here (all commands are typed in terminal can press window key and search for it)
  5. Open firefox and go to here & scroll to the bottom under Wrappers for OpenNI SDK to download OpenNI SDK for ROS2
  6. After download the tar zip file, extract it & open the README.md. Follow the instructions in README.md. (IMPORTANT: Change every galactic word in the file to humble)
  7. Halfway through you might run into an error with a command starting with colcon because its not installed. Follow the steps from here to download it.
  8. At the end, you should see a program with black and white image

Setup ROS & OpenNI SDK (WIN 11)

  1. Download VM
  2. Download Ubuntu 20
  3. Setup VM (Remember to add usb to vm)
  4. Follow steps from here to setup ROS here
  5. Follow steps from here to setup OpenNI here

Notes

  1. If using virtualbox vm after setting up vm go to setting usb and add the usb (must be plugged in the same physical port)
  2. USB controller of VM is set to usb3.0 (has smoother video stream)
  3. This might need to be rerun everytime for it to detect the camera
       roscd astra_camera
       ./scripts/create_udev_rules
       sudo udevadm control --reload && sudo udevadm trigger

OpenNI SDK

How to take picture

  1. Use below command
   rosservice call /camera/save_images "{}"
  1. Images are saved in ~/.ros/image and are only available when the sensor is on.
  2. xdg-open
    • Replace with filename

ROS

Utilisation of custom ROS msg

It uses custom made msg so need to follow this:

  1. Create Coords.msg and CoordsMatrix.msg in /home/ros/ros_ws/src/ros_astra_camera/msg
  2. Copy contents of both files from msg folder here into your local machine
  3. Follow the steps here to build the custom msg link

Running custom code as ROS node

  1. Installation not needed since all necessary dependencies are downloaded in ros_astra_camera package
  2. Get into Scripts folder in ros_astra_camera
   cd ~/ros_ws/src/ros_astra_camera/scripts
  1. Create a python file
   touch detect.py
  1. Paste code from detect.py file into your file in VM
   gedit detect.py
  1. Save the file and give it execution permission
   chmod +x detect.py
  1. Be sure to source these files on all the terminal before running Step 7-8
   cd ~/ros_ws
   source /opt/ros/noetic/setup.bash
   source ~/ros_ws/devel/setup.bash
  • To not do this for all terminal
       gedit ~/.bashrc
  • Copy below into the very bottom of the file and save
    source /opt/ros/noetic/setup.bash
    source ~/ros_ws/devel/setup.bash
  1. Run the depth camera
source ./devel/setup.bash 
roslaunch astra_camera astra.launch
  1. Open a terminal and run
   roscore
  1. Open another terminal and run
   rosrun ros_astra_camera detect.py

Jetson Orin Nano

Reinstall jetpack (The OS)

  1. Using a linux machine (or maybe VM not tested), download Nvidia SDK Manager
  2. Use Jumper Wire to connect Ground and Force Reset Pin on Jetson Orin Nano
  3. Connect type C from Jetson to linux machine
  4. Provide Jetson Power to boot in (safe mode/reset mode?)
  5. Install with SDK Manager

Python

Python virtual env

Purpose is to create an isolated environment for python packages so there is no risk of dependencies conflict with other similar packages

  1. Install virtual env(venv) package
pip install virtualenv
  1. Create venv environment
python -m venv .venv
  1. Activate env
    1. Windows
    .venv\Scripts\activate
    1. Linux/Mac
    source .venv/bin/activate
  2. Install saved dependencies
pip install -r requirements.txt
  1. To leave env
deactivate
  • Once env is activate can use pip install as usual to install new dependencies
  • To check dependencies use
pip list
  • After adding new dependencies execute below to save dependencies
pip freeze > requirements.txt

Docker (udev linux device manager does not work causing inability to use depth camera)

Installation

  1. Download docker desktop from the site
  2. Follow instructions here
    1. Mac: https://docs.docker.com/desktop/install/mac-install/
    2. Windows: https://docs.docker.com/desktop/install/windows-install/
  3. vcxsrv X server is required to run gui through x11 forwarding in ssh, install
  4. Putty (optional)

QuickStart

Replace anything in <>

  1. Pull the docker image from dockerhub
docker pull shadowofskull/depth_cam:latest
  1. Run a container from the image
docker run -it -p 22:22 --name ros-x11-ex shadowofskull/depth_cam:latest

Extra commands

  • To check container id
docker ps
  • To add extra terminal
docker exec -it <container id> bash
  • To rerun already created container use
docker start <container id> 

Building image from scratch

  1. Get into the folder Dockerfile exists
  2. Run
docker build -t <image name> . 
  • Add --no-cache if having issue building

Issues

  1. Q:Color image not showing
    1. A: Issue lies in ros2 and openni sdk for ros2, use back ros instead
  2. ROS2 openni seems to not support uvc camera color stream which our depth cam seems to be
    1. check if can activate uvc like in ros1 or not
  3. Unable to synchronise Arduino and Python code through serial.
  4. Lack of real world and virtual world Gazebo testing cause automation to fail
  5. Remote disconnection issue potentially due to limitation of ssh or internet connection of field.

Author

Adam and Zheng