vim で clipboardが無効だけどコピーアンドペーストしたい
vim で 書いたコードを他の環境に貼り付けたい時
・クリップボードを有効なものをインストールする
・再ビルド
等、いろいろあるが最近見つけた方法 xselの使用.
www.mk-mode.com
1. xselのインストール
$ sudo apt install xsel
2. vimrcに書く設定
vnoremap <C-c> :w !xsel -bi<CR><CR>
こんな感じにするとCtrl-Cでコピーすることができる。
vim quickrun でpython,シェルスクリプトの開発
vim の端末で実行しながら開発
簡単なpython , シェルスクリプトを作成するとき、実行結果を確認しながら開発できる、 他にもvim の中で簡単にコマンドが実行できる。
参考:
d.hatena.ne.jp
1. インストール
https://github.com/thinca/vim-quickrun
.vimrcに以下を追加
NeoBundle 'thinca/vim-quickrun'
2. vimprocのインストール
時間のかかる作業をまわすときは非同期で編集をすることができるといい。
https://github.com/Shougo/vimproc.vim
3. 設定を.vimrcに書き込む
私は下の狭いwindowで結果を確認するように設定している.
let g:quickrun_config = { \"_" : { \ "runner" : "vimproc", \ "runner/vimproc/updatetime" : 60, \ "outputter/buffer/split" : "botright 8sp", \ "outputter/buffer/close_on_empty" : 1 \ }, \}
byobu 1コマンドで複数のコマンドを実行 screen 編
byobu はロボットやリモートでの作業に便利
以前紹介したbyobuでの複数コマンド実行はbackendがtmuxの人にしか使うことができない。
memo-methods-in-researching.hatenablog.com
ちなみにbackendの変更は
$byobu-select-backend
で変更可能。
screenはそれぞれのwindowに対してユニークな名前がつけられてわかりやすい。
screenコマンドの場合はbyobuに入らなくてもガンガンコマンドをバックプロセスに投げられる。
もう少し工夫した方法はないか。
1. windowの名前の変更
スクリーン内のウィンドウの名前はこのコマンドで変更することができる。
$ echo -ne "\ekhello\e\\"
2. セッション名、window名を指定してコマンドを実行
$ byobu -r <Session> -p <Window> -X stuff "<command>^M"
例
#!/bin/bash command_0='echo -ne "\ekhello\e\\\\" && screen && echo robot' command_1='echo -ne "\ekhello2\e\\\\" && screen && echo research' session="toaru" window_bash="bash" byobu -d -m -S ${session} byobu -r ${session} -X stuff "${command_0}^M" sleep 1s byobu -r ${session} -p $window_bash -X stuff "${command_1}^M" echo "all done ... "
便利
byobu 1コマンドで複数のコマンドを実行 tmux編
byobuでコマンドを一つにして簡単に
ロボットやリモートでプロセスを回すときにはbyobuを使うとネットワークが突然切れても大丈夫。 ssh 先で複数の端末を開いて作業することができる。 http://byobu.org/about.html
windowのlayoutを保存して復元
1. paneを分ける
縦割り:Shift + F2
横割り:Ctrl + F2
大きさ調整:Alt + Shift + 方向キー
2. 保存
$byobu-layout save <NAME>
コマンドを指定したpaneに振り分ける
1. 保存したwindowを復元
$ byobu-layout restore <NAME>
2. コマンドの振り分け
#!/bin/bash window_name="toaru" byobu-layout restore <NAME> #1.の内容 byobu rename-window $window_name # toaruがそのwindowの名前 byobu send-keys -t $window_name.0 'echo toaru' C-m byobu send-keys -t $window_name.1 'echo gakusei' C-m byobu send-keys -t $window_name.2 'echo robot' C-m byobu send-keys -t $window_name.3 'echo research' C-m
便利 screen でやる方法はこちら
ubuntu16.04でSMACH ロボットの状態遷移を可視化
ロボットの状態遷移ツール
ロボットが複数のタスクをしたり、複数人でロボットを開発するときにはこのような状態遷移の可視化ツールがあると便利。
http://wiki.ros.org/smach_viewer
1 . 依存パッケージのインストール(そのままだとpython関係でエラーが出る)
$sudo add-apt-repository ppa:nilarimogard/webupd8 $sudo apt-get install python-wxgtk2.8
2 . git clone
$cd ~/catkin_ws/src/ $git clone https://github.com/ros-visualization/executive_smach_visualization.git $git clone https://github.com/ros/executive_smach.git
3 . サンプルコード
#!/usr/bin/env python import rospy import smach import smach_ros # define state Foo class Foo(smach.State): def __init__(self): smach.State.__init__(self, outcomes=['outcome1','outcome2']) self.counter = 0 def execute(self, userdata): rospy.loginfo('Executing state FOO') rospy.sleep(1) if self.counter < 3: self.counter += 1 return 'outcome1' else: return 'outcome2' # define state Bar class Bar(smach.State): def __init__(self): smach.State.__init__(self, outcomes=['outcome2']) def execute(self, userdata): rospy.loginfo('Executing state BAR') rospy.sleep(1) return 'outcome2' # main def main(): rospy.init_node('smach_example_state_machine') # Create a SMACH state machine sm = smach.StateMachine(outcomes=['outcome4', 'outcome5']) # Open the container with sm: # Add states to the container smach.StateMachine.add('FOO', Foo(), transitions={'outcome1':'BAR', 'outcome2':'outcome4'}) smach.StateMachine.add('BAR', Bar(), transitions={'outcome2':'FOO'}) # Create and start the introspection server sis = smach_ros.IntrospectionServer('server_name', sm, '/SM_ROOT') sis.start() # Execute SMACH plan outcome = sm.execute() rospy.spin() if __name__ == '__main__': main()
何をしているのかの詳細はここがわかりやすい。
smach/Tutorials/Getting Started - ROS Wiki
4 . viewer の起動
rosrun smach_viewer smach_viewer.py
状態遷移の状態確認
linux 使用メモリをros topic としてpublish
使用メモリをros topic としてpublish
グラフでメモリ使用量がどうなっているか評価するときにbagの中にメモリの使用量も入れておこう考えた。
メモ
#!/usr/bin/env python import rospy import sys import os import commands from std_msgs.msg import MultiArrayLayout from std_msgs.msg import MultiArrayDimension from geometry_msgs.msg import PoseStamped if __name__ == '__main__': args = sys.argv pub = rospy.Publisher('memory', PoseStamped, queue_size=10) rospy.init_node('system_monitor', anonymous=True) r = rospy.Rate(10) while not rospy.is_shutdown(): msg = PoseStamped() msg.header.frame_id = "memory_swap" msg.header.stamp = rospy.Time.now() memory = commands.getoutput('free -m --si | grep -e Mem -e Swap | while read a b c d e f g; do echo -n "$b $c "; done | tr -d GB').split() #msg.pose.orientation.x,msg.pose.orientation.y,msg.pose.orientation.z, msg.pose.orientation.w = commands.getoutput("free -m --si | grep -e Mem -e Swap | while read a b c d e f g; do echo $b $c; done | tr -d GB") print memory msg.pose.orientation.x = float(memory[0]) msg.pose.orientation.y = float(memory[1]) msg.pose.orientation.z = float(memory[2]) msg.pose.orientation.w = float(memory[3]) pub.publish(msg) r.sleep()
だいぶ無理がある。
linux , bibtexで論文の管理を簡単にしたい
論文を書くときにリファレンスに時間をかけない。
論文を書いている時に、リファレンスは学会や論文の種類によってフォーマットが全然違う。毎回気を使いながら少しずつ直すのは手間である。 例えば in proceedings のところはイタリックだったり違ったり。。。 そんな時bibtexというものを知った。厳密には知っていたが、ネットなどを見ても使い方がうまく調べられず。疎遠になってしまっていた。 最低限使えるようになったので備忘録。
環境
ubuntu16.04
linux
bibtexの概要
基本的に論文の情報を一つのファイルにまとめて書いてあって、それを自由に引き出したりしている。
- hoge.bst 設定ファイル(各会議や雑誌が用意しているbibtexの設定ファイル
- huga.bib 自分が調べた論文
基本的には2つのファイルがあればできる。
bibtexが使える環境準備
基本的にはlatexmkでpdfを作れているのであれば、問題がないみたい.
memo-methods-in-researching.hatenablog.combst ファイルを手に入れる
基本的には会議などのテンプレートを手に入れた時についてくる。 どんなファイルを用いているのかきちんと確認する。bib ファイルを作成する.
ここには自分の読んだ論文の情報をbibtex方式で書く。 大体、google scholarでもIEEE exploreでもbibtex形式でcitation をダウンロードすることができる。 試しにここではreference.bibを作成
@article{toaru, title={robot}, author={toaru gakusei and shun niijima}, journal={Journal of robot}, volume={22}, number={6}, pages={758-766}, year={2010}}
- 自分のtexファイルでの書き方
toaru gakusei no bibouroku \cite{toaru} \bibliographystyle{tADR} \bibliography{reference}
- 結果pdf
これは便利、論文の管理まで楽になる。