Skip to content

Commit 26f2070

Browse files
committed
feat: add configurable sensors, display depth color map
1 parent 1b1bf2e commit 26f2070

File tree

11 files changed

+467
-1576
lines changed

11 files changed

+467
-1576
lines changed

README.md

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
# Module orbbec-camera
22

3-
Provide a description of the purpose of the module and any relevant information.
3+
Use [Orbbec cameras](https://www.orbbec.com/products/) compatible with [v2 of the Orbbec SDK](https://github.com/orbbec/pyorbbecsdk/tree/v2-main?tab=readme-ov-file#hardware-products-supported-by-python-sdk).
4+
This module provides access to the color and depth sensors.
45

56
## Model viam-labs:camera:orbbec
67

7-
Provide a description of the model and any relevant information.
8+
Use [Orbbec cameras](https://www.orbbec.com/products/) compatible with [v2 of the Orbbec SDK](https://github.com/orbbec/pyorbbecsdk/tree/v2-main?tab=readme-ov-file#hardware-products-supported-by-python-sdk).
89

910
### Configuration
1011
The following attribute template can be used to configure this model:
1112

1213
```json
1314
{
14-
"attribute_1": <float>,
15-
"attribute_2": <string>
15+
"sensors": ["color", "depth"]
1616
}
1717
```
1818

@@ -22,29 +22,31 @@ The following attributes are available for this model:
2222

2323
| Name | Type | Inclusion | Description |
2424
|---------------|--------|-----------|----------------------------|
25-
| `attribute_1` | float | Required | Description of attribute 1 |
26-
| `attribute_2` | string | Optional | Description of attribute 2 |
25+
| `sensors` | array | Optional | An array that contains the strings `color` and/or `depth`, defaults to include both. The sensor that comes first in the array is designated the "main sensor" and will be the image that gets returned by `get_image` calls and what will appear in the Control tab on the [Viam app](https://app.viam.com). When both sensors are requested, `get_point_cloud` will be available for use, and `get_images` will return both the color and depth outputs. Additionally, color and depth outputs returned together will always be aligned, have the same height and width, and have the same timestamp. See [Viam's documentation on the Camera API](https://docs.viam.com/components/camera/#api) for more details. |
2726

2827
#### Example Configuration
2928

3029
```json
3130
{
32-
"attribute_1": 1.0,
33-
"attribute_2": "foo"
31+
"sensors": ["color"]
3432
}
3533
```
3634

37-
### DoCommand
35+
## Troubleshooting
3836

39-
If your model implements DoCommand, provide an example payload of each command that is supported and the arguments that can be used. If your model does not implement DoCommand, remove this section.
37+
**Unable to connect to camera**
4038

41-
#### Example DoCommand
39+
The `first_run.sh` script included in this module should automatically install the `udev` rules for connecting to the camera on Linux devices.
40+
If there is an issue, try copying `99-obsensor-libusb.rules` in the `scripts/` directory of this repo to `/etc/udev/rules.d/` on the Viam machine and calling the following command on the system:
4241

43-
```json
44-
{
45-
"command_name": {
46-
"arg1": "foo",
47-
"arg2": 1
48-
}
49-
}
5042
```
43+
sudo udevadm control --reload-rules && sudo udevadm trigger
44+
```
45+
46+
## Development
47+
48+
This module depends on the [v2-main branch of the pyorbbecsdk](https://github.com/orbbec/pyorbbecsdk/tree/v2-main) as a git submodule. So use the `--recursive` flag when cloning this repo or `git submodule update --init --recursive` if you've already cloned it.
49+
50+
To build this module on the target device (aarch64 or amd64 Linux machines), run `make archive.tar.gz`.
51+
52+
To build this module on another platform for a target device, use a tool like [canon](https://github.com/viamrobotics/canon) to run the Make command in the appropriate Docker container: `canon make archive.tar.gz`

build.sh

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,9 @@ VENV_NAME=".venv"
99

1010
source "./$VENV_NAME/bin/activate"
1111

12-
# if ! uv pip install pyinstaller -q; then
13-
# exit 1
14-
# fi
15-
1612
uv build --wheel
1713

1814
cp ./pyorbbecsdk/dist/*.whl ./dist/
19-
cp -r ./scripts/ ./dist/
15+
cp ./scripts/* ./dist/
2016

21-
# uv run pyinstaller --onefile -p src src/main.py
2217
tar -czvf archive.tar.gz ./dist/ meta.json first_run.sh run.sh

build_sdk.sh

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ sudo apt install -y cmake gcc clang
1212

1313
# Build pyorbbecsdk
1414
cd pyorbbecsdk
15+
uv pip install -r requirements.txt
1516
if [ -d "build" ]; then
1617
rm -rf build
1718
fi
@@ -23,11 +24,7 @@ make install
2324
cd ..
2425

2526
# Build wheel
26-
# uv pip install wheel
2727
python setup.py bdist_wheel
2828

29-
# Install the wheel
30-
uv pip install dist/*.whl
31-
32-
echo "pyorbbecsdk built and installed successfully!"
29+
echo "pyorbbecsdk built successfully!"
3330
cd ..

first_run.sh

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@ fi
2828

2929
source "$VENV_NAME/bin/activate"
3030

31-
# if ! uv pip install -r requirements.txt; then
32-
# echo "unable to sync requirements to venv"
33-
# exit 1
34-
# fi
35-
36-
# uv pip install
31+
echo "Installing dependencies"
32+
uv pip install ./dist/pyorbbecsdk-*.whl
33+
uv pip install ./dist/orbbec_camera-*.whl

meta.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
{
99
"api": "rdk:component:camera",
1010
"model": "viam-labs:camera:orbbec",
11-
"short_description": "Provide a short (100 characters or less) description of this model here",
12-
"markdown_link": "README.md#model-viam-labsorbbec-cameraorbbec"
11+
"short_description": "Get color and depth images from Orbbec cameras",
12+
"markdown_link": "README.md#model-viam-labscameraorbbec"
1313
}
1414
],
1515
"markdown_link": "README.md",

pyproject.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
[project]
22
name = "orbbec-camera"
33
version = "0.1.0"
4-
description = "Add your description here"
4+
description = "Viam module for supporting Orbbec 3D cameras"
55
readme = "README.md"
66
requires-python = ">=3.10"
77
dependencies = [
88
"viam-sdk==0.45.2",
99
"typing-extensions",
1010
"pillow",
11-
"open3d",
1211
"opencv-python",
1312
"numpy<2",
1413
]

requirements.txt

Lines changed: 0 additions & 5 deletions
This file was deleted.

run.sh

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,38 +4,10 @@ set -euo pipefail
44

55
cd $(dirname $0)
66

7-
8-
# echo "Installing udev rules"
9-
# Install udev rules
10-
# sudo bash ./dist/install_udev_rules.sh
11-
127
# Create a virtual environment to run our code
138
VENV_NAME="${VIAM_MODULE_DATA}/.venv"
149
PYTHON="$VENV_NAME/bin/python"
1510

16-
export PATH=$PATH:$HOME/.local/bin
17-
18-
if [ ! "$(command -v uv)" ]; then
19-
if [ ! "$(command -v curl)" ]; then
20-
echo "curl is required to install UV. please install curl on this system to continue."
21-
exit 1
22-
fi
23-
echo "Installing uv command"
24-
curl -LsSf https://astral.sh/uv/install.sh | sh
25-
fi
26-
27-
echo "Creating virtual environment"
28-
if ! uv venv $VENV_NAME --python 3.10; then
29-
echo "unable to create required virtual environment"
30-
exit 1
31-
fi
32-
33-
source $VENV_NAME/bin/activate
34-
35-
echo "Installing dependencies"
36-
uv pip install ./dist/pyorbbecsdk-*.whl
37-
uv pip install ./dist/orbbec_camera-*.whl
38-
3911
# Be sure to use `exec` so that termination signals reach the python process,
4012
# or handle forwarding termination signals manually
4113
echo "Starting module..."

setup.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ fi
2828

2929
source "./$VENV_NAME/bin/activate"
3030

31-
if ! uv pip install -r requirements.txt; then
31+
if ! uv sync; then
3232
echo "unable to sync requirements to venv"
3333
exit 1
3434
fi

0 commit comments

Comments
 (0)