Bye Bye Moore

PoCソルジャーな零細事業主が作業メモを残すブログ

xArmにROS環境をつくる

xArmは中国深圳のUFactory社が出しているロボットアームです。
ユニバーサルロボティクス社のURシリーズと似た規模感、可動軸ながら、軽量安価という特徴があります。

実際のところ

環境

  • Ubuntu 20LTS on WSL
  • ROS noetic

前準備

gazebo_ros_pkg、ros_control、moveit_coreが前提になるので、先にそれらを導入します。

sudo apt install ros-${ROS_DISTRO}-controller-interface  ros-${ROS_DISTRO}-gazebo-ros-control ros-${ROS_DISTRO}-joint-state-controller ros-${ROS_DISTRO}-effort-controllers ros-${ROS_DISTRO}-joint-trajectory-controller

ROSリポジトリの構築

$ cd ~/catkin_ws/src
$ git clone https://github.com/xArm-Developer/xarm_ros.git --recursive

ROSの大元を構築した際にsetup.bashを使っていたなら、環境変数ROS_DISTROが設定されてるはずなので

$ rosdep check --from-paths . --ignore-src --rosdistro $ROS_DISTRO
All system dependencies have been satisfied
$  rosdep install --from-paths . --ignore-src --rosdistro $ROS_DISTRO -y

$ DISPLAY=:0 roslaunch xarm_gazebo xarm7_beside_table.launch

f:id:shuzo_kino:20210924182012p:plain

$ DISPLAY=:0 roslaunch xarm7_gripper_moveit_config xarm7_gripper_moveit_gazebo.launch

f:id:shuzo_kino:20210924182631p:plain

$ DISPLAY=:0 roslaunch xarm_gazebo xarm7_beside_table.launch run_demo:=true

f:id:shuzo_kino:20210924183945p:plain

$ DISPLAY=:0 roslaunch xarm_gazebo xarm7_beside_table.launch run_demo:=true add_gripper:=true 

【読書メモ】PowerPointからPR動画まで! 公務員の動画作成術

最近は動画の時代なんて言って、其処らの中小企業もVLOGを出す時代です。
そうなると否応なく、お役所も動画づくりに巻き込まれるわけで……。
とはいえ日々の業務で忙しいのに手間が掛かりそうな事したくないお気持ちもわかります。

本書はそういう現場でも手堅く動画作成をするためのアレコレを紹介してくれています。

フリー素材サイト、撮影の仕方、お役所ならまず作ってるPowerPoint資料を動画に転用する方法等々、実践的です。
これで足りないと感じる細かいノウハウは別の本でフォローするといいでしょう。

ウチは役所ではありませんが、学んだノウハウは自社素材として応用がききそうです。

著者のYouTubeチャンネルもある

著者の佐久間智之氏のYouTubeチャンネルもありました。
再生数は多いというわけではないみたいですが、こういう情報が欲しい方には有用なのでは?
www.youtube.com

【読書メモ】 写真の上達には近道がある カメラの使い方より大切な「見る力」を身につける方法

業務写真の必要性から色々調べていた中で評価が高そうだった本。
前の「カメラ一年生」と内容は(初心者向けなので当然ですが)重複している部分多し。
元はムックなのか、ページ数は40ページほどと少なめ。

日常のキレイな風景を撮りましょうという趣旨の本で、商品写真が必要だった私にはちょっと違ったかもしれません。

Ubuntu20LTSにArduino-cli環境をいれM5stackのスクリプトを構築できるようにする

Raspberry Pi、それもリモート環境だと、お世辞にも便利とはいえないArduino IDEが余計に不便に感じます。
幸い、公式がCLIツールを出してるので、そいつを導入してみます。

実際のところ

$ curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | sh
$ /home/shuzo/bin/arduino-cli core search esp32 --additional-urls https://dl.espressif.com/dl/pac
kage_esp32_index.json
ID          Version Name
esp32:esp32 1.0.6   esp32
~$ /home/shuzo/bin/arduino-cli core install esp32:esp32 --additional-urls https://dl.espressif.com
/dl/package_esp32_index.json
~$ /home/shuzo/bin/arduino-cli lib install "M5_BM8563" --additional-urls https://dl.espressif.com/
dl/package_esp32_index.json
Error installing M5_BM8563: Library 'M5_BM8563' not found
||>
とか言われるが、ない。
手動で入れる方法もあるみたいだが、環境混乱が怖いので決断的旧式導入

>||
$ /home/shuzo/bin/arduino-cli lib install M5Stack@0.3.5
Downloading M5Stack@0.2.9...
M5Stack@0.2.9 downloaded
Installing M5Stack@0.2.9...
Installed M5Stack@0.2.9
arduino-cli compile --fqbn esp32:esp32:m5stack-core-esp32 /home/shuzo/Arduino/libraries/M5Stack/examples/Basics/HelloWorld/HelloWorld.ino
arduino-cli upload --port /dev/ttyS4 --fqbn esp32:esp32:m5stack-core-esp32 /home/shuzo/Arduino/libraries/M5Stack/examples/Basics/HelloWorld/HelloWorld.ino

【読書メモ】職場で、家で、学校で、働くあなたの疲れをほぐす すごいストレッチ

常々、肩甲骨まわりが固く頭痛薬が手放せません。
加えて、5月から延々と継続している筋トレまわりで脚の柔軟性が必要になる種目(アンイーブンスクワット)に差し掛かり対応する必要がでた為、手に取りました。

全体的に絵が多いので、実演しやすい印象。
そして、実際やってみて地獄の様に体が固いことを強く認識しました。
今ある習慣にプラスアルファするだけなので、継続は普通にイケそうですが。
さて、これも三ヵ月くらいやると、どうなりますかね。

M5stackをweb鯖化してMCP23017への命令を遠隔で行えるようにする

shuzo-kino.hateblo.jp
の続き。
M5stackと、それにつないだMCP23017とでLEDをブラウザ越しにいじったりできるようにする。

実際のところ

#include <M5Stack.h>
#include "Wire.h"
#include  <WiFi.h>
#include  <WiFiClient.h>
#include  <WebServer.h>
#include  <ESPmDNS.h>


const char* ssid = "###";
const char* password = "###";

WebServer server(80);

void handleRoot() {
    //  LED の制御
    M5.Lcd.print("handleLED: ");
    if (server.method() == HTTP_POST) {
       String val = server.arg("led");
       ledBup(val.toInt());
    }
String mes = "\
<html lang=\"ja\">\n\
<meta charset=\"utf-8\">\n\
<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n\
<head>\n\
 <title>webLedTest</title>\n\
</head>\n\
<body style=\"font-family: sans-serif; background-color: #ffeeaa ;\" >\n\
 <h1>webLedTest</h1>\n\
    <p>\n\
    <form action='' method='post'>\n\
      <button name='led' value='255'>ALL</button>\n\
    </form>\n\
    <form action='' method='post'>\n\
      <button name='led' value='10'>8+2</button>\n\
    </form>\n\
    <form action='' method='post'>\n\
      <button name='led' value='8'>8</button>\n\
    </form>\n\
    <form action='' method='post'>\n\
      <button name='led' value='4'>4</button>\n\
    </form>\n\
    <form action='' method='post'>\n\
      <button name='led' value='2'>2</button>\n\
    </form>\n\
    <form action='' method='post'>\n\
      <button name='led' value='1'>1</button>\n\
    </form>\n\
    <form action='' method='post'>\n\
      <button name='led' value='0'>0</button>\n\
    </form>\n\
  </p>\n\
</body>\n\
</html>\n";

 server.send(200, "text/html", mes);
}

void ledBup(int val) {
  Wire.beginTransmission(0x20);
  Wire.write(0x13); // address bank B
  Wire.write(val); // except B0, all Bs HIGH
  Wire.endTransmission();
  delay(500);
}

void handleNotFound() {
 String message = "File Not Found\n\n";
 message += "URI: ";
 message += server.uri();
 message += "\nMethod: ";
 message += (server.method() == HTTP_GET) ? "GET" : "POST";
 message += "\nArguments: ";
 message += server.args();
 message += "\n";
 for (uint8_t i = 0; i < server.args(); i++) {
   message += " " + server.argName(i) + ": " + server.arg(i) + "\n";
 }
 server.send(404, "text/plain", message);
}

void setup(void) {

    M5.begin();  //Init M5Core.
    M5.Power.begin(); //Init Power module.
    M5.Lcd.setBrightness(200);
    M5.Lcd.setCursor(10, 10); //文字表示の左上位置を設定
    M5.Lcd.setTextColor(RED); //文字色設定(背景は透明)(WHITE, BLACK, RED, GREEN, BLUE, YELLOW..)
    M5.Lcd.setTextSize(2);//文字の大きさを設定(1~7)

    Wire.begin(); // wake up I2C bus
    // set I/O pins to outputs
    Wire.beginTransmission(0x20);
    Wire.write(0x00); // IODIRA register
    Wire.write(0x00); // set all of port A to outputs
    Wire.write(0x00); // set all of port B to outputs
    Wire.endTransmission();

    WiFi.mode(WIFI_STA);
    WiFi.begin(ssid, password);

    // Wait for connection
    while (WiFi.status() != WL_CONNECTED) {
        delay(500);
        M5.Lcd.print(".");
    }

    M5.Lcd.print(ssid);
    M5.Lcd.print("\n");
    M5.Lcd.print(WiFi.localIP());
    M5.Lcd.print("\n");

    if (MDNS.begin("esp32led")) {
        M5.Lcd.print("MDNS responder started");
        M5.Lcd.print("\n");
    }

    server.on("/", handleRoot);
    server.on("/inline", []() {
        server.send(200, "text/plain", "hello from esp8266!");
    });
    server.onNotFound(handleNotFound);
    server.begin();

    M5.Lcd.setCursor(10, 10); //文字表示の左上位置を設定
    M5.Lcd.print("HTTP server started");
    M5.Lcd.print("\n");

}


void loop(void) {

    server.handleClient();
}

M5stackにMCP23017をつかってIOを拡張する

MCP23017という石があります。
IO拡張系の石なのですが、マイコン側からはI2Cで通信できるので線の分お得。
配線も減るし、上手に分離すればモジュール化も容易なんじゃないかと思い、手元のM5stackで実験してみました。

実際のところ

#include <M5Stack.h>
#include "Wire.h"

void setup() {
  M5.begin();  //Init M5Core.
  M5.Power.begin(); //Init Power module.
  Wire.begin(); // wake up I2C bus
  // set I/O pins to outputs
  Wire.beginTransmission(0x20);
  Wire.write(0x00); // IODIRA register
  Wire.write(0x00); // set all of port A to outputs
  Wire.write(0x00); // set all of port B to outputs
  Wire.endTransmission();
}

void ledBup(int val) {
  Wire.beginTransmission(0x20);
  Wire.write(0x13); // address bank B
  Wire.write(val); // except B0, all Bs HIGH
  Wire.endTransmission();
  delay(500);
}


void loop() {
  M5.update();
  ledBup(0xf0);
  ledBup(0xf1);
  ledBup(0xf2);
  ledBup(0xf4);
  ledBup(0xf8);
  ledBup(0xff);
}