Skip to content

Commit

Permalink
Merge pull request #34 from Hermanye996/main
Browse files Browse the repository at this point in the history
update for camera
  • Loading branch information
mangdangroboticsclub committed Apr 10, 2023
2 parents 511331e + 8248851 commit 69a0af7
Show file tree
Hide file tree
Showing 11 changed files with 2,739 additions and 0 deletions.
42 changes: 42 additions & 0 deletions RPiCamera/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Use RPi Camera in your Mini Pupper
## Step1: Connect Pi Camera to the Raspberry Pi 4B CSI Port
1. Ensure the Raspberry Pi is turned off and unplugged from the power source.
2. Locate the CSI (Camera Serial Interface) port on the Raspberry Pi 4B. This port is a rectangular-shaped connector located between the micro HDMI and audio ports.
![camera_port_4B](/imgs/camera_port_4B.png)
3. Open the camera module's plastic tab by gently pulling it away from the circuit board.
![camera_module.png](/imgs/camera_camera_module.png)
1. Gently insert the ribbon cable into the camera module's connector with the shiny contacts facing the circuit board.
2. Push the plastic tab back into place to secure the ribbon cable.
3. Gently insert the other end of the ribbon cable into the CSI port on the Raspberry Pi 4B, making sure that the shiny contacts are facing the micro HDMI port.
4. Push the ribbon cable firmly into the CSI port, ensuring that it is properly connected.
![camera_connect_camera](/imgs/camera_connect_camera.gif)

Remember to handle the ribbon cable and connector carefully to avoid damage, and double-check that everything is properly aligned before inserting or securing the cable.
![camera_all_4B](/imgs/camera_all_4B.jpg)
For additional information, please refer to the official Raspberry Pi documentation on [getting started with Picamera](https://projects.raspberrypi.org/en/projects/getting-started-with-picamera), which includes these images.

## Step2: Install the camera driver and configure Raspberry Pi

```bash
cd ~/mini_pupper_bsp/RPiCamera # To RPiCamera directory
```

```bash
. install.sh # Set camera configurations
```

## Step3: Test camera


- Camera ffplay test
```bash
cd ~/mini_pupper_bsp/demos # To demos directory
```

```bash
sudo apt install python-is-python3 -y # install python
python camera_ffplay_test.py # run ffplay test demo
```
- Camera image in RViz
TODO

28 changes: 28 additions & 0 deletions RPiCamera/details_for_install_sh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# sudo apt install -y v4l-utils
The command "sudo apt install -y v4l-utils" installs the Video 4 Linux (v4l) utilities package on a Debian-based Linux system.

Video 4 Linux is a kernel module that provides support for webcams and other video capture devices on Linux systems. The v4l-utils package provides a set of command-line utilities for working with video capture devices, such as listing available devices, adjusting device settings, and capturing video.

Some of the utilities provided by v4l-utils include v4l2-ctl, which allows for querying and adjusting video device settings, and v4l2-sysfs-path, which can be used to identify the device path of a video device.

Overall, the v4l-utils package is essential for working with video capture devices on Linux systems and enables developers to create applications that can access video streams from cameras and other capture devices.

# # camera_auto_detect=1
This command checks if the configuration file /boot/firmware/config.txt contains a line that starts with "camera_auto_detect=1". If such a line is found, it is commented out by adding a "#" character at the beginning of the line using the sed command. The purpose of this is to disable the camera auto-detection feature on the Raspberry Pi, as it can cause conflicts when using certain camera modules.

# echo "gpu_mem=128" | sudo tee -a /boot/firmware/config.txt
When using a CSI camera on a Raspberry Pi, setting the `gpu_mem` to 128MB is recommended because the GPU needs a sufficient amount of memory to be able to process the data from the camera. The CSI camera interface uses the GPU to handle the camera data, and if there is not enough memory allocated to the GPU, the system may become unstable or the camera may not work correctly. By setting the `gpu_mem` to 128MB, we ensure that the GPU has enough memory to handle the camera data and avoid potential issues.

# echo "start_x=1" | sudo tee -a /boot/firmware/config.txt
This command adds a line "start_x=1" to the end of the /boot/firmware/config.txt file. This line enables the Raspberry Pi to start the X Windows system on boot, which is necessary for running graphical applications and interfaces. By default, this line is commented out, which means that the X Windows system is not started on boot.

# sudo usermod -aG video $USER
The command "sudo usermod -aG video $USER" adds the current user to the "video" group on the system. This grants the user permission to access video devices such as cameras and webcams.

In Linux, user accounts are associated with one or more groups, which are used to control access to files and devices on the system. The "video" group is a special group that grants access to video devices. By default, only users who are members of this group can access video devices.

When the "sudo usermod -aG video $USER" command is executed, it modifies the user account by adding the user to the "video" group. The "-aG" option specifies that the user should be added to the group, rather than replacing any existing group membership. The "$USER" variable is expanded to the username of the current user.

After the command is executed and the user is added to the "video" group, the user will have access to video devices without needing to use the "sudo" command. This is because members of the "video" group have the necessary permissions to access video devices.
# sudo dtc -I dts -O dtb -o /boot/firmware/dt-blob.bin dt-blob-cam1.dts
This command compiles a DTS file into a binary DTB file and saves it to the specified output file path /boot/dt-blob.bin. The DTB file contains information about the hardware devices connected to the Raspberry Pi, which is used by the operating system to properly configure and use those devices.
9 changes: 9 additions & 0 deletions RPiCamera/dts/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# What is dt-blob-cam1.dts?
The dt-blob-cam1.dts file is a Device Tree Source file that defines the hardware configuration of a Raspberry Pi compute module. The Camera Serial Interface (CSI) is a dedicated interface in Raspberry Pi for connecting the Raspberry Pi camera module to the Raspberry Pi board. The CSI camera is connected to the camera interface via a ribbon cable, providing a high-speed data connection between the camera and the processor. The dt-blob-cam1.dts file configures the GPIO pins for the CSI camera interface and enables the interface.

The dt-blob-cam1.dts file provides the necessary hardware configuration for the CSI camera interface, including the configuration of the GPIO pins used for the interface. Without this configuration, the Raspberry Pi board will not be able to communicate with the camera module via the CSI interface.

In summary, the dt-blob-cam1.dts file is essential for enabling the CSI camera interface on the Raspberry Pi compute module. Without it, the camera module would not function correctly.

# Where can I find official Raspberry Pi dts examples?
For more information about dts files, please refer to the [RPi_Datasheets](https://datasheets.raspberrypi.org).
Loading

0 comments on commit 69a0af7

Please sign in to comment.