Talk:Open-source hardware

From OpenStreetMap Wiki
Jump to navigation Jump to search

This page is distinct from the current Hardware guide which was never intended to be open source hardware but rather a reusing of post-market devices. This page includes projects whose design files and source code are readily available for everyone to get started.

Recommended Software and External Links

Contributing Guide and Examples

C'est un clamp.

In the image of a clamp (seen on the right), the CAD sourcefile is attached to the metadata of the JPEG file. It is not only the image. Rather, it is also the customizable and FreeCAD-editable parametric model. Clicking on the image will reveal metadata with instructions on how to extract the source. Below is a process that describes how one may share or overwrite source files here to this Wiki using a script, provided that the screenshot image of their design is a JPEG format.

Usage Examples:

  1. ./jpeg-attach pic.jpg src.zip unzip
  2. ./jpeg-attach img.jpg model.FCStd freecad
  3. ./jpeg-attach 000.jpg mesh.stl fstl

We save the below script in a file called jpeg-attach and make it executable with `chmod +x jpeg-attach`

#!/bin/bash
# Attach a Source File to a JPEG Image

F_JPG=$1            # Input File (argument 1)
F_SRC=$2            # Source File (argument 2)
APP=$3              # Application (argument 3)
D_TMP=/tmp          # Temp Folder
SOI="ffd8"          # Start of Image
DESC="(EN) The original $F_JPG file hosts its own source. "
DESC+="Please click \"Show extended details,\" then copy and paste "
DESC+="the JPEG file comment to your terminal."
DESC+="(DE) Die originelle $F_JPG Datei hostet ihren eigenen Quelltext. "
DESC+="Klicken Sie bitte auf \"Erweiterte Details einblenden.\" Danach "
DESC+="kopieren Sie den JPEG-Dateikommentar in den Terminal um."
COM="exiftool -b -ThumbnailImage $F_JPG > .$F_JPG && dd if=.$F_JPG bs=1 "
COM+="skip=\$(exiftool -ThumbnailOffset .$F_JPG | sed \"s/.*\: //g\" | tr -d \"\r\") "
COM+="count=\$(exiftool -ThumbnailLength .$F_JPG | sed \"s/.*\: //g\" | tr -d \"\r\") "
COM+="| xxd -c 1 -p | tr -d \"\n\" | sed \"s/ff00/ff/g\" | xxd -r -p > $F_SRC "
COM+="&& $APP $F_SRC"

# Make a temp folder.
2>/dev/null mkdir $D_TMP

# Make a temp copy.
cp $F_JPG $F_JPG.jpg

# Escape 0xFF source bytes to distinguish them from EXIF markers.
xxd -c 1 -p $F_SRC | tr -d "\n" | sed "s/ff/ff00/g" | xxd -r -p > $D_TMP/$F_SRC

# Make a thumbnail with the same size as the Source file.
let i=${#SOI}/2
let I=$(stat -c %s $D_TMP/$F_SRC)
echo $SOI | xxd -r -p > $D_TMP/$F_JPG
echo "for (i=$i; i<$I; i++) \"00\"" | bc | xxd -r -p >> $D_TMP/$F_JPG

# Copy and insert the thumbnail into the Input file.
cp $D_TMP/$F_JPG .$F_JPG
exiftool "-ThumbnailImage<=.$F_JPG" $F_JPG

# Get the new offset and length of the Input file.
let off=$(exiftool -ThumbnailOffset $F_JPG | sed "s/.*\: //g" | tr -d "\r")
let len=$(exiftool -ThumbnailLength $F_JPG | sed "s/.*\: //g" | tr -d "\r")

# Copy Input file bytes that precede the Source to a New file.
dd if=$F_JPG of=$D_TMP/$F_JPG bs=$off count=1

# Insert Source file bytes to the New file.
dd if=$D_TMP/$F_SRC >> $D_TMP/$F_JPG

# Copy Input file bytes that succeed the Source file to the New file.
dd if=$F_JPG bs=$((off+len)) skip=1 >> $D_TMP/$F_JPG

# Overwrite the Input file with the New file.
mv $D_TMP/$F_JPG $F_JPG

# Remove the New file and Temp Folder among others.
rm $D_TMP/$F_SRC
rmdir $D_TMP
rm .$F_JPG

# Add the Temp file as the Input file's thumbnail.
exiftool "-ThumbnailImage<=$F_JPG" $F_JPG.jpg

# Overwrite the Input file with the Temp file.
mv $F_JPG.jpg $F_JPG

# Add a comment and a description to the Input file.
exiftool -comment="$COM" $F_JPG
exiftool -description="$DESC" $F_JPG

Windows Guide

Setting up Cygwin

  1. Download and run the ExifTool installer by Oliver Betz and any relevant CAD applications.
  2. Download and run the Cygwin installer. Install packages xxd, nano, and bc (double click on "skip").
  3. Launch Cygwin and enter the following lines into your terminal to finish setting it up:
ln -s /cygdrive/c/Program\ Files/FreeCAD*/bin/FreeCAD.exe /usr/bin/freecad
ln -s /cygdrive/c/Program\ Files/KiCad/bin/kicad.exe /usr/bin/kicad
echo "alias get='tr -d \"\\n\\r\" | sed \"s/.*: e/e/\" | sed \"s/\\\\\\\\/\\\\\\\\\\\\\\\\/g\" | sed \"s/\\\"/\\\\\\\\\\\"/g\" | xargs -I cmd bash -c \"cmd\"'" >> ~/.bash_profile
echo 'cd "/cygdrive/c/Users/$(whoami)/Downloads/"' >> ~/.bash_profile && exit

Copy the bash script

Relaunch the Cygwin, and type `nano jpeg-attach`. Hit Enter. Right click the terminal and select 'Paste'. Hit CTRL+X, then Enter to quit nano. Make our script executable with `chmod +x jpeg-attach'.

Extract the source

Using any image from the Wiki, right click the blue "Original file" link > Save As. Save in Downloads. Either copy the comment from the Wiki or enter in the Cygwin, `exiftool -Comment image.jpg | get`.

Wrapping up

Save a snippet/screenshot of your modifications as a JPEG to the Downloads folder, and attach the CAD source using the script `./jpeg-attach image.jpg source appname`

Alternative Guide

The above described method does not require a PDF viewer. It also is more central to the Wiki and allows more collaborative formatting using Wikitext. Here are some alternatives:

  • Use Adobe Reader or pdftk to attach your source to a PDF image. This has the benefit of allowing "multiple viewing angles" and selecting the page number in the Wiki later.
  • Use an external hosting site. There are version control systems dedicated to software, and some hosts provide advanced 3d viewers or customizers for hardware designs.

Metric Thread Size Chart (M-Profile in mm)

ASME B1.13M-2005 (R2015)
Name Pitch Screw Minor Diam. Nut Diameter Screw Diameter Nut Major Diam.
M1.6 0.35 1.221 - 1.321 1.291 - 1.373 1.373 - 1.458 1.496 - 1.600
M2 0.40 1.567 - 1.679 1.654 - 1.740 1.740 - 1.830 1.886 - 2.000
M2.5 0.45 2.013 - 2.138 2.117 - 2.208 2.208 - 2.303 2.380 - 2.500
M3 0.50 2.459 - 2.599 2.580 - 2.675 2.675 - 2.775 2.874 - 3.000
M3.5 0.60 2.850 - 3.010 3.004 - 3.110 3.110 - 3.222 3.354 - 3.500
M4 0.70 3.242 - 3.422 3.433 - 3.545 3.545 - 3.663 3.838 - 4.000
M5 0.80 4.134 - 4.334 4.361 - 4.480 4.480 - 4.605 4.826 - 5.000
M6 1.00 4.917 - 5.153 5.212 - 5.350 5.350 - 5.500 5.794 - 6.000
M8 1.25 6.647 - 6.912 7.042 - 7.188 7.188 - 7.348 7.760 - 8.000
1.00 6.917 - 7.153 7.212 - 7.350 7.350 - 7.500 7.794 - 8.000
M10 1.50 8.376 - 8.676 8.862 - 9.026 9.026 - 9.206 9.732 - 10.000
1.25 8.647 - 8.912 9.042 - 9.188 9.188 - 9.348 9.760 - 10.000
1.00 8.917 - 9.153 9.212 - 9.350 9.350 - 9.500 9.794 - 10.000
0.75 9.188 - 9.378 9.391 - 9.513 9.513 - 9.645 9.838 - 10.000