-
Notifications
You must be signed in to change notification settings - Fork 1
Developer Guide (JP)
Mitsuhito Ando edited this page Sep 11, 2016
·
9 revisions
projectGenerator を使用してプロジェクト新規作成にアドオンを追加する場合 addons の項目に ofxNetwork と ofxEpilog を選択し、追加してください。
-
既存のプロジェクトに追加する場合
- Xcode 左ペインの addons グループの下に
ofxEpilogディレクトリをドラッグ&ドロップします。 - Create groups for any added folders のみチェックが入っている状態で Finish を選択します。
-
ofxEpilog/examplesディレクトリの参照を削除します。 -
ofxNetworkを既に使用していない場合、Xcode 左ペインの addons グループの下にof_v0.9.3_osx_release/addons/ofxNetworkをドラッグ&ドロップします。
- Xcode 左ペインの addons グループの下に
oF 0.9 からの projectGenerator では既存のプロジェクトにアドオンを後から追加することできます。
最小限の実装をした ofApp.h および ofApp.cpp のサンプルコードを下記に示します。
ofApp.h
#include "ofMain.h"
#include "ofxEpilog.h"
class ofApp : public ofBaseApp
{
:
OutputConfig out_conf;
ofxEpilog epilogLaser;
:
}ofApp.cpp
#include "ofApp.h"
void setup()
{
out_conf.vec_power = 30;
out_conf.vec_speed = 100;
out_conf.vec_freq = 100;
out_conf.ras_power = 10;
out_conf.ras_speed = 50;
out_conf.ras_freq = 50;
out_conf.use_auto_fucus = false;
out_conf.z_thickness = 0;
out_conf.z_offset = 0;
out_conf.dpi = 75;
out_conf.enable_laser_emit = true;
// init epilog laser object with PJL file output (fusion)
//epilogLaser.setup(ofxEpilog::FUSION_32, out_conf, true);
// init epilog laser object with PJL file output (mini)
epilogLaser.setup(ofxEpilog::MINI_18, out_conf, true);
epilogLaser.connect("192.168.3.4", false);
ofPolyline line;
line.addVertex(ofPoint(0,0));
line.addVertex(ofPoint(100,0));
line.addVertex(ofPoint(100,100));
line.addVertex(ofPoint(0,100));
line.addVertex(ofPoint(0,0));
epilogLaser.send(line);
epilogLaser.disconnect();
}
ofxEpilog.h ヘッダには Epilog レーザーとの通信を行うコマンド(PCL,HPGL)の定数群、 利用する Epilog レーザーの機種を定義した MachineProfile 構造体、加工データのパラメータを示す OutputConfig 構造体、その他の接続処理などを含む仮想的な Epilog レーザーを表す ofxEpilog クラスが定義されています。
- 使用する Epilog レーザーカッターの機種に依存する、ワークエリアサイズなどのパラメータを
MachineProfile構造体を使用して設定します。
struct MachineProfile
{
string name; // 機種名
double width; // 横幅 (mm)
double height; // 縦幅 (mm)
double z_top; // 高さ テーブル上限 (mm)
double z_buttom; // 高さ テーブルの底までの距離 (mm)
double min_thickness;
double max_thickness; // 材料サイズ 最大 (mm)
int min_dpi; // 最小 DPI
int max_dpi; // 最大 DPI
double min_freq; // 周波数 下限 (Hzもしくはパーセント)
double max_freq; // 周波数 上限 (Hzもしくはパーセント)
bool is_freq_percentage; // 使用する周波数の値がHzもしくはパーセントなのかを示すフラグ
double focus_dist; // レンズの焦点距離
};デフォルトでは ofxEpilog::FUSION_32 と ofxEpilog::MINI_18 の定数パラメータが定義してあります。このモデル以外の Epilog レーザーのパラメーターが必要な場合は必要に応じて再定義して使用してください。
// 2 inch lens
// https://www.epiloglaser.com/products/fusion-laser-series.htm#techspecs
const struct MachineProfile ofxEpilog::FUSION_32 =
{
"Fusion_32", 813, 508, -12.7, 76.2, 0, 177.8, 75, 1200, 0, 100, true, 50.8
};
// 1.5 inch lens
// https://www.epiloglaser.com/products/legend-laser-series.htm#techspecs
const struct MachineProfile ofxEpilog::MINI_18 =
{
"Mini_18", 457, 305, 0, 0, 0, 177.8, 75, 1200, 10, 5000, false, 38.1
};-
MachineProfileのほかに、カットスピード、カットパワー、彫刻スピード、彫刻パワー、周波数、DPI、オートフォーカス設定などの加工パラメーターを設定する必要があります。
struct OutputConfig
{
int vec_speed = 1; // ベクター加工のスピード (1~100%)
int vec_power = 0; // ベクター加工のパワー (0~100%)
int ras_speed = 1; // ラスター加工のスピード (1~100%)
int ras_power = 0; // ベクター加工のパワー (0~100%)
int dpi = 600; // 加工に使用するDPI (75, 150, 300, 600, 1200) のいずれか
int vec_freq = 0; // ベクター加工の周波数, fusionシリーズはパーセントで指定, miniは10~5000Hzで指定
int ras_freq = 0; // ラスター加工の周波数, fusionシリーズはパーセントで指定, miniは10~5000Hzで指定
double z_offset = 0.0; // テーブルのオフセット距離 (mm), fusionシリーズ向け
double z_thickness = 0.0; // 材料の厚み (mm), fusionシリーズ向け
bool use_auto_fucus = false; // オートフォーカス機能を使用するかどうかの指定
enum RASTER_MODE { BMP16M = 7, BMPGRAY = 2 };
RASTER_MODE raster_mode; // ラスター処理の画像圧縮タイプの指定
bool use_bezier_cmd = false; // ベジエ曲線加工のコマンドを使用するかどうかのフラグ, fusionシリーズ向け
bool enable_laser_emit = false; // レーザー照射を行うかどうかのフラグ
};-
MachineProfileとOutputConfigはofxEpilog::setup()メソッドを使用して設定することができます。
void ofxEpilog::setup(MachineProfile m_profile, OutputConfig out_conf, bool save_pjl=false);- レーザーカッターに割り当てられたIPアドレスを使用して接続を開始するには下記のように行います。
このとき第2引数のブーリアンは、加工中を維持するかどうかのフラグを示し、true にすることで逐次データを送信しながら加工することができます。
bool isConnected = epilogLaser.connect("192.168.3.5", false);- 接続済みの状態で加工ジョブを送信するには次のように行います。
// 100mm * 100mm の矩形をカットする
ofPolyline line;
line.addVertex(0, 0);
line.addVertex(100, 0);
line.addVertex(100, 100);
line.addVertex(0, 100);
line.addVertex(0, 0);
if(epilogLaser.isConnected())
{
// send polyline
epilogLaser.send(line);
}カスタムオブジェクトを加工ジョブとして送信したい場合、 ofxEpilog::send()メソッドをオーバーロードしてください。
- レーザーカッターとのネットワーク接続を切るには次のように行います。
epilogLaser.disconnect();