2019年1月17日木曜日

lenovoのtrackpointのスピード調整

thinkpad x1 carbonにlinuxmint19を入れてみたらトラックポイントの感度がめちゃめちゃ良かったので変更しようと思ったお話.


linux mintともなればマウスのスピードとか感度を調整する方法がデフォルトで用意されているが,何故か今回は,それらがうまく行かなかったのでCUIから設定した.

ターミナルから

xinput list

とすると入力デバイス一覧が表示されるので,そこからトラックポイントのIDを探しましょう.

harumo@harumo-thinkpad-x1:~$ xinput list
⎡ Virtual core pointer                    id=2 [master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer              id=4 [slave  pointer  (2)]
⎜   ↳ TPPS/2 Elan TrackPoint                  id=12 [slave  pointer  (2)]
⎜   ↳ SynPS/2 Synaptics TouchPad              id=11 [slave  pointer  (2)]
⎣ Virtual core keyboard                    id=3 [master keyboard (2)]
    ↳ Virtual core XTEST keyboard              id=5 [slave  keyboard (3)]
    ↳ Power Button                            id=6 [slave  keyboard (3)]
    ↳ Video Bus                                id=7 [slave  keyboard (3)]
    ↳ Sleep Button                            id=8 [slave  keyboard (3)]
    ↳ Integrated Camera: Integrated C          id=9 [slave  keyboard (3)]
    ↳ AT Translated Set 2 keyboard            id=10 [slave  keyboard (3)]
    ↳ ThinkPad Extra Buttons                  id=13 [slave  keyboard (3)]

私のパソコンではid = 12なので,それを利用して

xinput list-props 12

とすると,

harumo@harumo-thinkpad-x1:~$ xinput list-props 12
Device 'TPPS/2 Elan TrackPoint':
Device Enabled (143): 1
Coordinate Transformation Matrix (145): 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000
libinput Natural Scrolling Enabled (286): 0
libinput Natural Scrolling Enabled Default (287): 0
libinput Scroll Methods Available (290): 0, 0, 1
libinput Scroll Method Enabled (291): 0, 0, 1
libinput Scroll Method Enabled Default (292): 0, 0, 1
libinput Button Scrolling Button (304): 2
libinput Button Scrolling Button Default (305): 2
libinput Middle Emulation Enabled (296): 0
libinput Middle Emulation Enabled Default (297): 0
libinput Accel Speed (298): 0.000000
libinput Accel Speed Default (299): 0.000000
libinput Accel Profiles Available (306): 1, 1
libinput Accel Profile Enabled (307): 1, 0
libinput Accel Profile Enabled Default (308): 1, 0
libinput Left Handed Enabled (300): 0
libinput Left Handed Enabled Default (301): 0
libinput Send Events Modes Available (263): 1, 0
libinput Send Events Mode Enabled (264): 0, 0
libinput Send Events Mode Enabled Default (265): 0, 0
Device Node (266): "/dev/input/event6"
Device Product ID (267): 2, 10
libinput Drag Lock Buttons (302): <no items>
libinput Horizontal Scroll Enabled (303): 1

が表示される.これは,トラックポイントで設定できる項目一覧なので
ここから,設定したい項目を下記のようにコマンドで設定する.

xinput set-prop [id] [property-id] [configuration]

とりあえず,スピードは以下の用にすると遅くできる.
harumo@harumo-thinkpad-x1:~$ xinput set-prop 12 145 1 0 0 0 1 0 0 0 3

再起動するとこの設定は消えてしまうので,.bashrcとかに
書き込んでおくといいと思うのです


また,センシティビティはxinputでは設定できなかったので
設定ファイルを作ることにより設定する.

   #! /bin/bash
   
   start() {
      echo -n 100 > /sys/devices/platform/i8042/serio1/serio2/sensitivity
   }
   
   stop() {
       echo "call when this service stopped"
   }
  
  case "$1" in
      start)
          start
          ;;
      stop)
          stop
          ;;
      restart)
          stop
          start
          ;;
      status)
          # code to check status of app comes here
          ;;
      *)
          echo "Usage: $0 {start|stop|status|restart}"
  esac
  
  exit 0

この設定を

/etc/init.d/trackpoint

ファイルを新しく作って,上の設定を書き込み,さらに

sudo /etc/init.d/trackpoint start

というコマンドを打つことで設定することができる.




2018年12月9日日曜日

rosdep in Linux mint tara(ubuntu18.04)

linux mintでrosdepをするときの注意 rosdep install foo を実行したときに起きる こんな感じの全力でやる気を削ぎに来るエラーはROSがOSを陰にubuntuだと決めつけているから 起こる問題ですので,rosdepに適切な引数をあたえるとよろし. 実際にコマンドはページ最下部にあるでよ.


 ERROR: Rosdep cannot find all required resources to answer your query Missing resource moveit_sample ROS path [0]=/opt/ros/melodic/share/ros ROS path [1]=/opt/ros/melodic/share ROS path [2]=/home/harumo/catkin_ws/src/industrial_core/industrial_core ROS path [3]=/home/harumo/catkin_ws/src/industrial_core/industrial_deprecated ROS path [4]=/home/harumo/catkin_ws/src/industrial_core/industrial_msgs ROS path [5]=/home/harumo/catkin_ws/src/industrial_core/industrial_trajectory_filters ROS path [6]=/home/harumo/catkin_ws/src/industrial_core/industrial_utils ROS path [7]=/home/harumo/catkin_ws/src/motoman/motoman ROS path [8]=/home/harumo/catkin_ws/src/motoman/motoman_gp12_support ROS path [9]=/home/harumo/catkin_ws/src/motoman/motoman_gp7_support ROS path [10]=/home/harumo/catkin_ws/src/motoman/motoman_gp8_support ROS path [11]=/home/harumo/catkin_ws/src/motoman/motoman_mh12_support ROS path [12]=/home/harumo/catkin_ws/src/motoman/motoman_mh50_support ROS path [13]=/home/harumo/catkin_ws/src/motoman/motoman_mh5_support ROS path [14]=/home/harumo/catkin_ws/src/motoman/motoman_motomini_support ROS path [15]=/home/harumo/catkin_ws/src/motoman/motoman_msgs ROS path [16]=/home/harumo/catkin_ws/src/motoman/motoman_sda10f_moveit_config ROS path [17]=/home/harumo/catkin_ws/src/motoman/motoman_sda10f_support ROS path [18]=/home/harumo/catkin_ws/src/motoman/motoman_sia10d_support ROS path [19]=/home/harumo/catkin_ws/src/motoman/motoman_sia10f_support ROS path [20]=/home/harumo/catkin_ws/src/motoman/motoman_sia20d_moveit_config ROS path [21]=/home/harumo/catkin_ws/src/motoman/motoman_sia20d_support ROS path [22]=/home/harumo/catkin_ws/src/motoman/motoman_sia5d_support ROS path [23]=/home/harumo/catkin_ws/src/moveit_sample ROS path [24]=/home/harumo/catkin_ws/src/ros_start ROS path [25]=/home/harumo/catkin_ws/src/sia20 ROS path [26]=/home/harumo/catkin_ws/src/industrial_core/simple_message ROS path [27]=/home/harumo/catkin_ws/src/industrial_core/industrial_robot_client ROS path [28]=/home/harumo/catkin_ws/src/industrial_core/industrial_robot_simulator ROS path [29]=/home/harumo/catkin_ws/src/motoman/motoman_driver ROS path [30]=/home/harumo/catkin_ws/src/urdf_start

とか,あるいは下記のようなもの

 ERROR: the following packages/stacks could not have their rosdep keys resolved to system dependencies: motoman_driver: Cannot locate rosdep definition for [roslint] motoman_gp7_support: Cannot locate rosdep definition for [roslaunch] motoman_sia10f_support: Cannot locate rosdep definition for [roslaunch] industrial_core: Cannot locate rosdep definition for [industrial_trajectory_filters] urdf_start: No definition of [gazebo] for OS version [] motoman_sia10d_support: Cannot locate rosdep definition for [roslaunch] motoman_mh50_support: Cannot locate rosdep definition for [roslaunch] motoman_sda10f_moveit_config: Cannot locate rosdep definition for [xacro] industrial_trajectory_filters: Cannot locate rosdep definition for [orocos_kdl] ros_start: Cannot locate rosdep definition for [std_msgs] motoman_mh12_support: Cannot locate rosdep definition for [roslaunch] my_moveit: Cannot locate rosdep definition for [trajectory_msgs] industrial_utils: Cannot locate rosdep definition for [rosunit] motoman_motomini_support: Cannot locate rosdep definition for [roslaunch] industrial_robot_simulator: Cannot locate rosdep definition for [roslaunch] industrial_msgs: Cannot locate rosdep definition for [message_runtime] motoman_mh5_support: Cannot locate rosdep definition for [roslaunch] motoman_sda10f_support: Cannot locate rosdep definition for [roslaunch] industrial_robot_client: Cannot locate rosdep definition for [rosunit] motoman_msgs: Cannot locate rosdep definition for [trajectory_msgs] sia20: No definition of [gazebo] for OS version [] motoman_sia20d_support: Cannot locate rosdep definition for [roslaunch] industrial_deprecated: Cannot locate rosdep definition for [catkin] motoman: Cannot locate rosdep definition for [motoman_sia5d_support] motoman_gp12_support: Cannot locate rosdep definition for [roslaunch] motoman_sia20d_moveit_config: Cannot locate rosdep definition for [xacro] motoman_sia5d_support: Cannot locate rosdep definition for [roslaunch] simple_message: Cannot locate rosdep definition for [rosunit] motoman_gp8_support: Cannot locate rosdep definition for [roslaunch]


そういうときは,このコマンド.
(catkin_wsに移動してから下記のコマンドを打ってくださいね)

 rosdep install --from-paths src --ignore-src --rosdistro melodic -y --os=ubuntu:bionic

2017年6月20日火曜日

atomでtexを自動更新する環境を作成(ubuntu,mint)

皆様,論文,修論,前刷りに追われる人生,いかがお過ごしでしょうか.
私は元気です.

研究者が数式を含む文章を作成しようとすると,
やはり,使用するのはtexでしょう.

最近になって,プログラムのREADMEぐらいはmarkdownで
書くようになってきましたが,それでも,論文を投稿しようとすると
テンプレがtexになってたりして,texが支配的です.

texの環境を作成することが苦手な私としましては
あまりにもtexを推奨されると
裏で陰謀がうずまき,世界が私を罠にはめようとしてるのではないかっ!!
と疑心暗鬼にならざるを得ません.

えー,そこで,本日はモダンなtexの環境をgithub謹製のエディタである
atomをlinux mint(ubuntu)で立ち上げようと思います.

この環境では,定期的に自動でコンパイルされ
結果が,自動的に右側に表示され,texのコマンドは補完がきくようになります・

必要な(と思われるもの)は以下のとおりです.
・tex-live(apt-getしてください)
・atom(ダウンロードしてください)

ここから下は,atomパッケージです.atomをインストールしてから
各パッケージをインストールしてくださいね.
・latex(texのコンパイルとかをしてくれる)
・language-latex(ハイライト)
・latexer(自動補完,bibliograpyも自動補完してくれる)
・pdf-view(texをコンパイルしてpdfにした時にatomの右側に表示)
・autosave-onchange(atom-idle-autosave)(お好みで好きな方をインストール)

そうして,パッケージのインストールが終了したら
設定を行います.

と言っても,latex以外のパッケージで設定することは何もないのだけど
では,latexの設定を以下のように変更してください.

・engine
    platex
・output format
    pdf
・PFD producer
    dvipdfmx
・Build on save
    チェックボックスにチェケラッチョ
・Open result after successful build
 チェックボックスにチェックする
・Open result background
 チェックボックス オーン
・opener
    PDF-view

はい,以上で設定は済みました.
うまく行かない時は,atomを再起動するとうまく行きます.

テストとして,以下の文章をコピーして見てください.

\documentclass{jsarticle}
\begin{document}
これはサンプルです.問題ないでしょう?
\begin{equation}
a = b+c
\end{equation}
\end{document}

うまくいけば終了です.
そうでなければ,atomの再起動を試してみてくださいな.
あと,bibliograpyにも対応してるので参考文献とかも
すごく楽です.

さあ,学生共よ,研究室に富と名誉を!
...おもに富を
そのために論文を量産するのだ.
tetsuyaでねっ.キラッ!

2017年4月20日木曜日

自作ライブラリをCMakeでディレクトリごとインストールする方法

自作ライブラリをCMakeでディレクトリごとインストールする方法

春先は送迎会などで諭吉が吹き飛んでいくのが悲しい限りです. ああ,諭吉よ.どうしてあなたは行ってしまったのですか. それはさておき, githubとかで自作ライブラリを公開するときに CMakeつかってビルドして/usr/local/lib/にインストールする方法を紹介しますね.

まず,今回はSonyの開発した人類の永遠の友であるPS3のコントローラーをlinuxで簡単に使用できるライブラリを作ったので,それをドヤ顔してgithubに公開してやろうかと思ったところ,opencvとかのように

sudo make install

とかやると, /usr/local/inculde/と /usr/local/lib/ にいい感じにインストールされる方法がわからなかったときのメモであぞよ.

というわけで,どうすればいいかお教えしましょう. まず,本日の生け贄... 本日のメインディッシュはdualshockという名前のライブラリとなっております.

構成

本日の構成は

dualshock
   |-CMakeLists.txt
   |-READEME.md
   |-example--testDs3.cpp
   |-include--dualshock--ds3.cpp
   |-src--ds3.cpp

となっております.というか,こんな感じのディレクトリ構成にしてください.多少は意味があります.

CMakeLists.txt

CMakeLists.txtは以下のように記述すること.

cmake_minimum_required(VERSION 3.5)
 
project(dualshock)
 
add_definitions("-std=c++11")
 
set(SRC_DIR src)
set(INCLUDE_DIR include/dualshock)
 
include_directories(${INCLUDE_DIR})
 
add_library(dualshock STATIC ${SRC_DIR}/ds3.cpp)
target_link_libraries(dualshock pthread)
 
install( TARGETS dualshock
    RUNTIME DESTINATION bin
    LIBRARY DESTINATION lib
    ARCHIVE DESTINATION lib
    )
 
install(DIRECTORY include/dualshock
    DESTINATION /usr/local/include
    )

ポイント

この場合,ファイル構成は綺麗になるが,ヘッダーと実装ファイルの 関係をどのように定義するのかが問題となる.

コンパイル時と,インストール後に使用するときとでは, それらの関係が異なるのである.

具体的には,cppファイルでどのようにヘッダーをincludeするのかということである.

でも,よく考えると,ヘッダーのincludeはコンパイルの時にのみ必要になる.ということは,インストールするときさえ乗り切れば,あとは,どうとでもなる.ということ.よって,ds3.cppのinclude部分をちょっとかえる.

FROM

#include "ds3.hpp"

ライブラリ内のヘッダーを参照するようにincludeのパスを変更する.

TO

#include "../include/dualshock/ds3.hpp"

結果

これを実行すると /usr/local/include 以下に /dualshock/ds3.hpp

/usr/local/lib/ 以下に libdualshock.a

がインストールされる.

2017年3月23日木曜日

TUTの学内LANにVPNで接続する方法

これは,TUTの学内LANに学外からLinux Mintで接続する方法です.
いままで,接続方法は研究室のWIKIに書いておいてあったんですけども,
それだと,結局,学内からしかアクセスできまへんやん!

という問題に気づきまして,学外からでもアクセスできる,このブログに書いておいて
困った時に確認し,ドヤ顔を使用という聡明にして賢明な作戦をたてました.

この投稿はその洗練された作戦の一旦であります.

方法は以下の通り,

百回回って,犬の真似をすると,
あら不思議VPNで接続することができるようになります.
あと,気分次第で以下のコマンドを売ってください.

sudo apt-get install network-manager-openconnect network-manager-openconnect-gnome 


あとは,設定をすればOKです.

george washington.vpn.***.**.**

2017年3月1日水曜日

YouCompleteMeをNeoVimでインストールしようとしたらハマった話.

さあさあ,寄ってらっしゃい,見てらっしゃい.
ここにかざってあるのは,機械学習のプログラムを作って実験したら,見事に成功して.
「やった!これで来月の研究発表会に離すことができたッ!」と喜び,さらに
「じゃあ,気分もいいし,久々にdein#update()して,プラグインたちをアップデートしてやるか」と深夜4時のテンションで深謀遠慮したあげく,それが悲劇のもととは知らずに意気揚々と突っ込んでいった若者の成れの果てでございます.


経緯をおって話すと
私はvimのプラグインたちをdein.vimで管理してる.
そのプラグインたちの中に,特にお世話になっているのが,補完用プラグインのYouCompeleteMeである.このオシャンティーにI love youと言っている名前のプラグインによって私は「プログラマーですけど?」と虚勢を張って要られるのである.しかし,このプラグイン,他のプラグインと違い,vimscriptに寄って書かれているわけではなくC++とその愉快な仲間であるboostによって書かれているので,インストールするためにはdein.vimに任せるわけには行かず.ダウンロードしてコンパイルする必要がある.
そのため,私のめんどくさがりも手伝って,なかなかプラグインをアップデートしないのであるが,昨日はなぜか判断を誤ってしまったのである.こんなことになった,責任者は誰か?断固として私ではない!!


しかし,昨日dein#update()をしたらYouCompleteMeが補完してくれなくなった.
vimで:YcmDiagsコマンドを打ったところ,
[Native filetype completion not supported for current file, cannot force recompilation.]
と返事が返ってきた.よくわからないにゃー.
C++が補完できないファイルタイプとは偉くなったものだなYCMよ.
散々インストールを繰り返した挙句.もうvimなんて知らない,neovimに行っちゃうんだから!!とおもむろにneovimに手を出したが,こちらでもYouCompleteMeは作動しなかった.
直し方が分かったのでここに載せておく.この解決方法はneovimのみならずvimでも役立つであろう.ちなみに,この方法は,vimのyoucompletemeの導入記事としても役立つよう書きました.

deinでプラグインを管理していると~/.vim以下にたくさんのディレクトリができるが
全消去.

$ pip3 install neovim
$ sudo apt-get install software-properties-common
$ sudo add-apt-repository ppa:neovim-ppa/unstable
$ sudo apt-get update
$ sudo apt-get install neovim
$ mkdir -p ~/.config/nvim

neovimではvimrcのかわりにinit.vimを使用するので~/.bashrcに

export XDG_CONFIG_HOME="$HOME/.config/nvim"

を書き込んでおく.書き込んだ後,source ~/.bashrcを実行するのもわすれずに

ここでポイント!!!!
vimrcのdein.vimで管理しているプラグインの中でdein.vimとYouConpleteMeのプラグイン以外のプラグインを全部コメントアウトする.これは非常に重要である.どれくらい重要かというと...ちょっと想像できません.ご了承ください.

vimrcの中身を~/.config/nvim/init.vimに書き写す.
そのあと,deinをインストール

$ mkdir -p ~/.vim/dein/repos/github.com/Shougo/dein.vim
$ git clone https://github.com/Shougo/dein.vim.git ~/.vim/dein/repos/github.com/Shougo/dein.vim

そしてnvimをたちあげると,もしくは:call dein#install()すると
deinとyoucompeltemeがインストールされます.

あとは,YouCompleteMeをコンパイルするだけなので

$ cd .vim/dein.vim/repos/github.com/Valloric/YouCompleteMe/
$ ./install.py --clang-completer

とする.君のシステムにすでにあるclangを使わないように!
要求するバージョンはclang3.9以上なのだとある!

...最新(2017-03-01)じゃん.

これで,YouCompleteMeは復活し,私の威厳は保たれた.おしまい.


重要なところは,init.vimのなかのdeinとyoucompleteme以外のプラグインをコメントアウト
したことで,再インストールとか全消去とかは必要あるかどうかはわかりません.
コメントアウトだけで復活するかも知れません.

2017年1月19日木曜日

c++11でliboctave

C++11でliboctave

liboctaveとは

前々から,やってみたかったのだが,簡単に数値計算をc++でできるliboctaveを導入してみた.
ていうか,matlabってあるじゃん.あの,お値段がとてつもなく高い数値計算用ソフト.あのお値段では,叶姉妹ぐらいのファビュラスなお金持ちでないと使うことができないのでは無いだろうか.いや,そうに違いない.

しかし,私は,お金持ちではないので創意工夫でどうにかするしか無い.そこでliboctaveである.matlabのコードがそのまま動くと言われているくらいmatlabにそっくりなoctaveっていう数値解析ソフトが存在し,それはc++11で実装されている.したがって,octaveを構成しているライブラリをc++11の自分のプログラムから呼び出すことが可能なのである.

Let’s 数値計算

環境は以下のとおりである

  • Ubuntu16.04(Linux mintの信者をやめたわけではない)
  • Cmake
  • LLVN Clang

さあ,パーティーの時間だ!!

$ sudo apt-get install octave liboctave-dev
$ sudo ldconfig

さあ,お片付けの時間だ!!

以下のようなテスト用のサンプルプログラムを用意します.

#include <iostream>
//#include </usr/local/include/octave-4.2.0/octave/config.h>
//octave-4.2.0ぐらいからはconfig.hはいらないらしい.コンパイラに怒られた.\(^o^)/

#include </usr/local/include/octave-4.2.0/octave/Matrix.h>

using namespace std;

  int main(int argc, char**argv)
  {
    Matrix A(2,3), B(2,2,1.0);
    ColumnVector x(3), y(2), z(2);
    for(int r(0); r<2; ++r)
      for(int c(0); c<3; ++c)
        A(r,c) = r+c;
    for(int r(0); r<3; ++r) x(r)=(r+1.0)*2.0;
    for(int r(0); r<2; ++r) y(r)=(r+1.0)*r;
    z = B*(A*x+y);

    cout<<"A="<<endl;
    cout<<A;
    cout<<"B="<<endl;
    cout<<B;
    cout<<"x= "<<x.transpose()<<endl;
    cout<<"y="<<y.transpose()<<endl;
    cout<<"z="<<z.transpose()<<endl;
    return 0;
  }

コンパイルは以下の感じで

clang++ -std=c+=11 test.cpp -loctave

Cmakeを使うときは以下の感じで

cmake_minimum_required(VERSION 3.5)
project(test)
add_executable(test test.cpp)
target_link_libraries(test octave)

結果は以下な感じざんす

A=
 0 1 2
 1 2 3
B=
 1 1
 1 1
x=  2 4 6
y= 0 2
z= 46 46

なんと言うことでしょう.
あの憎きmatlabと同等の環境を手に入れてしまった.ふはは.
何と言う高揚感!

まあ,当然のごとく,こういったことには先人がいて,わたしはコピーしただけなんだけどね.
どんなことができるかはここを見る