LoginSignup
5
4

More than 5 years have passed since last update.

obnizを使用したIoTロボットアーム(obniz-ARMS)

Posted at

概要

obnizを使用して、遠隔地からロボットアームを操作できる仕組みを構築しました。


材料

MeARM
 ・オープンソースの小型ロボットアーム。自分でレーザーカッターで抜き出すには大変なのでカット済の激安木製タイプのものを購入
・サーボモータ(SG90*4)
・obniz

組み立て

1.アームの組上げ

こんなキットを組上げていきます。
KIMG3762.JPG
KIMG3771.JPG

2.obnizへの接続

KIMG3772.JPG
・3ケーブル*4サーボ=12本だとすべて埋まってしまうため、GNDはブレッドボード経由で共有化
・なぜかピン0につなげると、過電流エラーが出てしまうため、ピン1から使用(原因は未確認)

3.コーディング

obnizARMS.thml
<!-- HTML Example -->
<html>
<head>
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <script src="https://obniz.io/js/jquery-3.2.1.min.js"></script>
  <script src="https://unpkg.com/obniz@1.11.2/obniz.js"></script>
</head>
<body>

<div id="obniz-debug"></div>
<h3>前後</h3>
<input id="slider" type="range"  min="45" max="70" value="60"/>

  <h3>上下</h3>
<input id="slider1" type="range"  min="30" max="90" value="45" />
  <h3>土台</h3>
<input id="slider2" type="range"  min="0" max="90" value="0" />
  <h3></h3>
<input id="slider3" type="range"  min="0" max="180" value="80" />
  <br>

  <button id="on">ON</button>
  <button id="off">OFF</button>

<script>
var obniz = new Obniz("OBNIZ_ID_HERE");
obniz.onconnect = async function () {
    var servo = obniz.wired("ServoMotor", {gnd:1, vcc:2, signal:3});
      var servo1 = obniz.wired("ServoMotor", {gnd:1, vcc:4, signal:5});
      var servo2 = obniz.wired("ServoMotor", {gnd:1, vcc:6, signal:7}); 
        var servo3 = obniz.wired("ServoMotor", {gnd:1, vcc:8, signal:9}); 

          $("#on").on("click",function(){
      servo.angle(5.0); // for testing

      });
      $("#off").on("click",function(){
      servo.angle(0.0); // for testing
    });


  $("#slider").on('input', function() {
    servo.angle($("#slider").val())
  });
  $("#slider1").on('input', function() {
    servo1.angle($("#slider1").val())
  });
  $("#slider2").on('input', function() {
    servo2.angle($("#slider2").val())
  });
    $("#slider3").on('input', function() {
    servo3.angle($("#slider3").val())
  });
};

obniz.onclose = async function(){
   $("#slider").off('input');
};
obniz.onclose = async function(){
   $("#slider1").off('input');
};
 obniz.onclose = async function(){
   $("#slider2").off('input');
};
  obniz.onclose = async function(){
   $("#slider3").off('input');
};
</script>
</body>
</html>

■操作画面
操作画面.JPG

4.感想

ロボットアームの可動域が限られているため、実際にはサーボのMIN/MAXの調整等が結構大変でした。ベストな調整方法を探っていきたいと思います。

5
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
4