Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@
path = src/external_dependencies/phoebe_ws
url = https://github.com/PickNikRobotics/phoebe_ws.git
branch = for-example-ws-no-dups
[submodule "src/moveit_pro_sam3"]
path = src/moveit_pro_sam3
url = https://github.com/PickNikRobotics/moveit_pro_sam3.git
[submodule "src/moveit_pro_sam2"]
path = src/moveit_pro_sam2
url = https://github.com/PickNikRobotics/moveit_pro_sam2.git
3 changes: 2 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ repos:
hooks:
- id: codespell
args: ["--write-changes", "-L", "atleast,inout,ether"] # Provide a comma-separated list of misspelled words that codespell should ignore (for example: '-L', 'word1,word2,word3').
exclude: \.(svg|pyc|stl|dae|lock)$
# Meta's SAM License is verbatim third-party text and must not be rewritten.
exclude: \.(svg|pyc|stl|dae|lock)$|^src/moveit_pro_sam3/models/LICENSE$

- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v14.0.6
Expand Down
1 change: 0 additions & 1 deletion src/moveit_pro_sam3
Submodule moveit_pro_sam3 deleted from 0d6463
4 changes: 4 additions & 0 deletions src/moveit_pro_sam3/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Written by `moveit_pro` when Meta's SAM License is declined.
COLCON_IGNORE
# The build downloads the SAM3 ONNX files; they must never be committed.
*.onnx
105 changes: 105 additions & 0 deletions src/moveit_pro_sam3/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
cmake_minimum_required(VERSION 3.22)
project(moveit_pro_sam3)

find_package(ament_cmake REQUIRED)

# The ONNX files are downloaded at configure time instead of being committed, so
# this repository does not redistribute Meta's SAM Materials. For an offline build,
# point SAM3_MODEL_URL at a file:// directory holding the upstream asset names.
set(SAM3_MODEL_URL "https://github.com/jamjamjon/assets/releases/download/sam3"
CACHE STRING "Location of the SAM3 ONNX release assets")
set(SAM3_MODEL_DIR "${CMAKE_CURRENT_BINARY_DIR}/models")

set(SAM3_MODEL_FILES
sam3_vision_encoder.onnx
sam3_text_encoder.onnx
sam3_geometry_encoder.onnx
sam3_decoder.onnx)
set(SAM3_MODEL_ASSETS
vision-encoder-q4f16.onnx
text-encoder-q4f16.onnx
geometry-encoder-q4f16.onnx
decoder-q4f16.onnx)
set(SAM3_MODEL_SHA256S
9c00c5db8739f4c0cd0158a916f0e9755e0240bb35abca2934ab308e72cb2d6e
639ba5a9991b012d3290fbba27eb8dbcebdc86ed9f747572d7bea1678317d8d1
6717167a4454e063ab71895b5c03d067ce7386437fb489d1484feb2ca3abf741
8496d685a950604626c3e6b972c21f5b4b876b15ce98b9b899875f392947b83c)

set(SAM3_MODEL_PATHS)
foreach(model_file model_asset model_sha256
IN ZIP_LISTS SAM3_MODEL_FILES SAM3_MODEL_ASSETS SAM3_MODEL_SHA256S)
set(model_path "${SAM3_MODEL_DIR}/${model_file}")
list(APPEND SAM3_MODEL_PATHS "${model_path}")
if(EXISTS "${model_path}")
file(SHA256 "${model_path}" actual_sha256)
if(actual_sha256 STREQUAL model_sha256)
continue()
endif()
endif()

set(model_url "${SAM3_MODEL_URL}/${model_asset}")
message(STATUS "Downloading SAM3 model file ${model_url}")
# Without a timeout, a connection that stalls after connecting hangs configure silently.
file(DOWNLOAD "${model_url}" "${model_path}.part"
STATUS download_status TLS_VERIFY ON INACTIVITY_TIMEOUT 60)
list(GET download_status 0 download_code)
if(NOT download_code EQUAL 0)
list(GET download_status 1 download_message)
file(REMOVE "${model_path}.part")
message(FATAL_ERROR
"Could not download SAM3 model file ${model_url}: ${download_message}. "
"Check network access to that URL, or set -DSAM3_MODEL_URL=file:///<dir> to a "
"directory holding the files listed in ${CMAKE_CURRENT_SOURCE_DIR}/README.md. "
"To leave SAM3 out of the build, run `moveit_pro configure --sam3-license decline`.")
endif()
file(SHA256 "${model_path}.part" actual_sha256)
if(NOT actual_sha256 STREQUAL model_sha256)
file(REMOVE "${model_path}.part")
message(FATAL_ERROR
"SAM3 model file ${model_url} has SHA-256 ${actual_sha256}, expected "
"${model_sha256}, so it was not used. The upstream file differs from the one "
"MoveIt Pro was tested with; contact PickNik support.")
endif()
file(RENAME "${model_path}.part" "${model_path}")
endforeach()

install(
FILES
${SAM3_MODEL_PATHS}
DESTINATION
share/${PROJECT_NAME}/models
)

# License notices must remain available if the install tree is redistributed
# independently of the source workspace. Use an explicit copy because colcon's
# symlink install would otherwise make them symlinks back into the source tree.
install(
CODE "
file(MAKE_DIRECTORY \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME}\")
execute_process(
COMMAND \"${CMAKE_COMMAND}\" -E copy_if_different
\"${CMAKE_CURRENT_SOURCE_DIR}/LICENSE\"
\"${CMAKE_CURRENT_SOURCE_DIR}/README.md\"
\"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME}\"
COMMAND_ERROR_IS_FATAL ANY
)
file(MAKE_DIRECTORY \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME}/models\")
execute_process(
COMMAND \"${CMAKE_COMMAND}\" -E copy_if_different
\"${CMAKE_CURRENT_SOURCE_DIR}/models/LICENSE\"
\"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME}/models\"
COMMAND_ERROR_IS_FATAL ANY
)
"
)

if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
# CONTRIBUTING.md is custom prose and matches none of ament_copyright's
# bundled *_contributing.txt templates, so the check reports it as unknown.
set(ament_cmake_copyright_FOUND TRUE)
ament_lint_auto_find_test_dependencies()
endif()

ament_package()
5 changes: 5 additions & 0 deletions src/moveit_pro_sam3/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Contributing to this package

Thanks for getting involved! If you want to contribute to this package, please reach out to support@picknik.ai.

Contributions outside `models/` are made under the [BSD 3-Clause License](LICENSE), unless a file states otherwise. Contributions containing or derived from Meta's SAM Materials must comply with the [SAM License](models/LICENSE).
29 changes: 29 additions & 0 deletions src/moveit_pro_sam3/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
BSD 3-Clause License

Copyright (c) 2026 PickNik Inc.
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

* Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
43 changes: 43 additions & 0 deletions src/moveit_pro_sam3/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# moveit_pro_sam3

ROS package that provides SAM 3 ONNX models for image segmentation to MoveIt Pro Behaviors.

## Usage

This repository does not contain the model files. Building the package downloads them from the upstream release listed under [Provenance](#provenance), checks each file against its SHA-256, and installs them to `share/moveit_pro_sam3/models`. A file already in the build directory with the expected hash is not downloaded again.

If you decline Meta's SAM License when `moveit_pro` asks, it writes a `COLCON_IGNORE` into this package, so the build skips it and downloads nothing.

To build without network access, download the four upstream assets into one directory under their upstream names, then pass that directory to the build:

```bash
colcon build --packages-select moveit_pro_sam3 --cmake-args -DSAM3_MODEL_URL=file:///path/to/directory
```

## Model license and use restrictions

The ONNX model files this package downloads are exports of Meta's SAM 3 model and are distributed under the [SAM License](models/LICENSE). By using or redistributing these models, you agree to that license.

The SAM License includes restrictions that downstream users must follow. In particular:

- Do not use the SAM Materials for military or warfare purposes, activities subject to the International Traffic in Arms Regulations (ITAR), nuclear industries or applications, espionage, or the development or use of guns or illegal weapons.
- Comply with applicable trade controls, privacy laws, and data-protection laws.
- Redistribute the models and derivative works only under the SAM License and include a copy of the license.
- Acknowledge the use of the SAM Materials when publishing research results produced with them.

This summary is provided for convenience and does not replace the full [SAM License](models/LICENSE).

## Provenance

The downloaded files are the `*-q4f16.onnx` assets from [jamjamjon/assets, release `sam3`](https://github.com/jamjamjon/assets/releases/tag/sam3), renamed as listed below. They are third-party ONNX exports of Meta's SAM 3 model with q4f16 weight quantization (4-bit weights, float16 activations), produced for the [usls](https://github.com/jamjamjon/usls) project. PickNik performed no training, fine-tuning, or other modification.

| File | Upstream asset | SHA-256 |
| --- | --- | --- |
| `sam3_decoder.onnx` | `decoder-q4f16.onnx` | `8496d685a950604626c3e6b972c21f5b4b876b15ce98b9b899875f392947b83c` |
| `sam3_geometry_encoder.onnx` | `geometry-encoder-q4f16.onnx` | `6717167a4454e063ab71895b5c03d067ce7386437fb489d1484feb2ca3abf741` |
| `sam3_text_encoder.onnx` | `text-encoder-q4f16.onnx` | `639ba5a9991b012d3290fbba27eb8dbcebdc86ed9f747572d7bea1678317d8d1` |
| `sam3_vision_encoder.onnx` | `vision-encoder-q4f16.onnx` | `9c00c5db8739f4c0cd0158a916f0e9755e0240bb35abca2934ab308e72cb2d6e` |

## Package licensing

The downloaded ONNX model files, and derivative works of those models, are governed by the [SAM License](models/LICENSE). All other files in this package are governed by the [BSD 3-Clause License](LICENSE), unless a file states otherwise.
61 changes: 61 additions & 0 deletions src/moveit_pro_sam3/models/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
SAM License
Last Updated: November 19, 2025

“Agreement” means the terms and conditions for use, reproduction, distribution and modification of the SAM Materials set forth herein.


“SAM Materials” means, collectively, Documentation and the models, software and algorithms, including machine-learning model code, trained model weights, inference-enabling code, training-enabling code, fine-tuning enabling code, and other elements of the foregoing distributed by Meta and made available under this Agreement.

“Documentation” means the specifications, manuals and documentation accompanying
SAM Materials distributed by Meta.


“Licensee” or “you” means you, or your employer or any other person or entity (if you are entering into this Agreement on such person or entity’s behalf), of the age required under applicable laws, rules or regulations to provide legal consent and that has legal authority to bind your employer or such other person or entity if you are entering in this Agreement on their behalf.


“Meta” or “we” means Meta Platforms Ireland Limited (if you are located in or, if you are an entity, your principal place of business is in the EEA or Switzerland) or Meta Platforms, Inc. (if you are located outside of the EEA or Switzerland).


“Sanctions” means any economic or trade sanctions or restrictions administered or enforced by the United States (including the Office of Foreign Assets Control of the U.S. Department of the Treasury (“OFAC”), the U.S. Department of State and the U.S. Department of Commerce), the United Nations, the European Union, or the United Kingdom.


“Trade Controls” means any of the following: Sanctions and applicable export and import controls.

By using or distributing any portion or element of the SAM Materials, you agree to be bound by this Agreement.


1. License Rights and Redistribution.


a. Grant of Rights. You are granted a non-exclusive, worldwide, non-transferable and royalty-free limited license under Meta’s intellectual property or other rights owned by Meta embodied in the SAM Materials to use, reproduce, distribute, copy, create derivative works of, and make modifications to the SAM Materials.

b. Redistribution and Use.
i. Distribution of SAM Materials, and any derivative works thereof, are subject to the terms of this Agreement. If you distribute or make the SAM Materials, or any derivative works thereof, available to a third party, you may only do so under the terms of this Agreement and you shall provide a copy of this Agreement with any such SAM Materials.


ii. If you submit for publication the results of research you perform on, using, or otherwise in connection with SAM Materials, you must acknowledge the use of SAM Materials in your publication.


iii. Your use of the SAM Materials must comply with applicable laws and regulations, including Trade Control Laws and applicable privacy and data protection laws.
iv. Your use of the SAM Materials will not involve or encourage others to reverse engineer, decompile or discover the underlying components of the SAM Materials.
v. You are not the target of Trade Controls and your use of SAM Materials must comply with Trade Controls. You agree not to use, or permit others to use, SAM Materials for any activities subject to the International Traffic in Arms Regulations (ITAR) or end uses prohibited by Trade Controls, including those related to military or warfare purposes, nuclear industries or applications, espionage, or the development or use of guns or illegal weapons.
2. User Support. Your use of the SAM Materials is done at your own discretion; Meta does not process any information nor provide any service in relation to such use. Meta is under no obligation to provide any support services for the SAM Materials. Any support provided is “as is”, “with all faults”, and without warranty of any kind.


3. Disclaimer of Warranty. UNLESS REQUIRED BY APPLICABLE LAW, THE SAM MATERIALS AND ANY OUTPUT AND RESULTS THEREFROM ARE PROVIDED ON AN “AS IS” BASIS, WITHOUT WARRANTIES OF ANY KIND, AND META DISCLAIMS ALL WARRANTIES OF ANY KIND, BOTH EXPRESS AND IMPLIED, INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. YOU ARE SOLELY RESPONSIBLE FOR DETERMINING THE APPROPRIATENESS OF USING OR REDISTRIBUTING THE SAM MATERIALS AND ASSUME ANY RISKS ASSOCIATED WITH YOUR USE OF THE SAM MATERIALS AND ANY OUTPUT AND RESULTS.

4. Limitation of Liability. IN NO EVENT WILL META OR ITS AFFILIATES BE LIABLE UNDER ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, TORT, NEGLIGENCE, PRODUCTS LIABILITY, OR OTHERWISE, ARISING OUT OF THIS AGREEMENT, FOR ANY LOST PROFITS OR ANY DIRECT OR INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL, EXEMPLARY OR PUNITIVE DAMAGES, EVEN IF META OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF ANY OF THE FOREGOING.

5. Intellectual Property.


a. Subject to Meta’s ownership of SAM Materials and derivatives made by or for Meta, with respect to any derivative works and modifications of the SAM Materials that are made by you, as between you and Meta, you are and will be the owner of such derivative works and modifications.

b. If you institute litigation or other proceedings against Meta or any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the SAM Materials, outputs or results, or any portion of any of the foregoing, constitutes infringement of intellectual property or other rights owned or licensable by you, then any licenses granted to you under this Agreement shall terminate as of the date such litigation or claim is filed or instituted. You will indemnify and hold harmless Meta from and against any claim by any third party arising out of or related to your use or distribution of the SAM Materials.

6. Term and Termination. The term of this Agreement will commence upon your acceptance of this Agreement or access to the SAM Materials and will continue in full force and effect until terminated in accordance with the terms and conditions herein. Meta may terminate this Agreement if you are in breach of any term or condition of this Agreement. Upon termination of this Agreement, you shall delete and cease use of the SAM Materials. Sections 3, 4 and 7 shall survive the termination of this Agreement.

7. Governing Law and Jurisdiction. This Agreement will be governed and construed under the laws of the State of California without regard to choice of law principles, and the UN Convention on Contracts for the International Sale of Goods does not apply to this Agreement. The courts of California shall have exclusive jurisdiction of any dispute arising out of this Agreement.


8. Modifications and Amendments. Meta may modify this Agreement from time to time; provided that they are similar in spirit to the current version of the Agreement, but may differ in detail to address new problems or concerns. All such changes will be effective immediately. Your continued use of the SAM Materials after any modification to this Agreement constitutes your agreement to such modification. Except as provided in this Agreement, no modification or addition to any provision of this Agreement will be binding unless it is in writing and signed by an authorized representative of both you and Meta.
22 changes: 22 additions & 0 deletions src/moveit_pro_sam3/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" ?>
<package format="3">
<name>moveit_pro_sam3</name>
<version>0.1.0</version>
<description>
ROS package that downloads SAM3 ONNX models for image segmentation at build
time.
</description>

<maintainer email="david.sobek@picknik.ai">David Sobek</maintainer>
<license file="LICENSE">BSD-3-Clause</license>
<license file="models/LICENSE">SAM License</license>

<buildtool_depend>ament_cmake</buildtool_depend>

<test_depend>ament_lint_auto</test_depend>
<test_depend>ament_lint_common</test_depend>

<export>
<build_type>ament_cmake</build_type>
</export>
</package>
Loading