2018年3月19日月曜日

Gigabyte Brixをヘッドレス化(モニター無し運用)

Ubuntu16.04を載せたGigabyte Brixをヘッドレス化する.大抵の場合,引っかかるのはモニターを接続していないとログインまでたどりつけない問題.これはXwindowがモニターを探しに行って見つからずに起動できないということなのだが,Biosによっては起動にモニターなしで起動ができるようだ.今回はvncserverで仮想モニターを用意して起動するという内容(のはず).ヘッドレスで起動した後,そのままssh接続可能で,移動した後にモニターを接続しても正しく表示される.やったことだけつらつらと書いていく.
参考<https://askubuntu.com/questions/621313/vnc-server-for-headless-ubuntu-14-04>

$sudo apt-get update && sudo apt-get upgrade
$sudo apt-get install gnome-core xfce4 vnc4server
$sudo adduser user1
$su - user1
$vncserver
$emacs /home/user1/.vnc/xstartup
#!/bin/sh                                                                                                                                                                                                          

# Uncomment the following two lines for normal desktop:                                                                                                                                                            
# unset SESSION_MANAGER                                                                                                                                                                                            
# exec /etc/X11/xinit/xinitrc                                                                                                                                                                                      

[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
x-window-manager &
$sudo emacs /etc/init.d/vncserver
#!/bin/bash                                                                                                                                                                                                        

unset VNCSERVERARGS
VNCSERVERS=""
[ -f /etc/vncserver/vncservers.conf ] && . /etc/vncserver/vncservers.conf
prog=$"VNC server"
start() {
 . /lib/lsb/init-functions
REQ_USER=$2
echo -n $"Starting $prog: "
ulimit -S -c 0 >/dev/null 2>&1
RETVAL=0
for display in ${VNCSERVERS}
do
export USER="${display##*:}"
if test -z "${REQ_USER}" -o "${REQ_USER}" == ${USER} ; then
echo -n "${display} "
unset BASH_ENV ENV
DISP="${display%%:*}"
export VNCUSERARGS="${VNCSERVERARGS[${DISP}]}"
su ${USER} -c "cd ~${USER} && [ -f .vnc/passwd ] && vncserver :${DISP} ${VNCUSERARGS}"
fi
done
}
stop() {
. /lib/lsb/init-functions
REQ_USER=$2
echo -n $"Shutting down VNCServer: "
for display in ${VNCSERVERS}
do
export USER="${display##*:}"
if test -z "${REQ_USER}" -o "${REQ_USER}" == ${USER} ; then
echo -n "${display} "
unset BASH_ENV ENV
export USER="${display##*:}"
su ${USER} -c "vncserver -kill :${display%%:*}" >/dev/null 2>&1
fi
done
echo -e "\n"

echo "VNCServer Stopped"

}
case "$1" in
start)
start $@
;;
stop)
stop $@
;;
restart|reload)
stop $@
sleep 3
start $@
;;
condrestart)
if [ -f /var/lock/subsys/vncserver ]; then
stop $@
sleep 3
start $@
fi
;;
status)
status Xvnc
;;
*)
echo $"Usage: $0 {start|stop|restart|condrestart|status}"
exit 1
esac
$chmod +x /etc/init.d/vncserver
$sudo mkdir -p /etc/vncserver
$sudo vim /etc/vncserver/vncservers.conf
VNCSERVERS="1:user1"
VNCSERVERARGS[1]="-geometry 1024x768"

$sudo reboot

2018年3月1日木曜日

Robomechへの論文投稿でセキュリティだの文書構造の圧縮を解除せよなど引っかかる

TeXShop on MacでPDF出力したものがRobomechへ投稿できない.去年もやった.1年前のことですっかり忘れていた.特殊なソフトを使わずにできたはずなのにな,と思い起こす.

【結論】
プレビューで
ファイル>書き出す>フォーマットはPDFでQuartzフィルタかけない.

【補足】
PDFとして書き出すを使うと何故かファイルサイズがかなり大きくなる→Robomechのファイル制限(2MB)を超える.かといってQuartzフィルタでサイズダウンすると図が見れたもんじゃない.

2018年1月5日金曜日

Macのデータ容量が切迫→オートセーブデータを削除

MacBook Proを使っていてデータ容量が切迫してきたなと思い,DiskWave.appをインストールしてどのディレクトリが容量を喰っているのか確認したのだけれど,全体の使用済み容量と各ディレクトリの使用済み容量が食い違っている(全体の方が大きい).そんな時に怪しいのがMacのオートセーブ機能.強制シャットダウンした時に残るセーブデータのことで,ありがたいのだけれど正常に終了した後には不要になるもの.強制終了を頻繁にしていると知らないうちに100GBまでいってたりする…(VMwareの不具合でMacのuserログイン時にキーボードが効かなくなって強制終了することが多々あった…)

ということで削除しましょう(あくまで自己責任で).

$ sudo rm -r /.DocumentRevisions-V100/.cs

2017年10月24日火曜日

gnuplotで.pltファイルを読み込み自動出力するサンプル

output.txtからデータ出力するサンプルです.

$> file = 'output'
$> output = 1
$> load "plotter.plt"

  • グラフの大きさをmarginで指定する
  • 軸ラベルをつける
  • グリッドを表示する
  • 凡例を移動させる
  • 線のスタイルを変更する
  • multiplotによって1つの図に2つのグラフを表示する
  • if文処理により,変数output=1にセットした時のみ.epsファイルを出力する
  • 参照ファイル名を用いて出力ファイルを作成する
等の内容を含みます.

plotter.pltの中身は以下の通りです.

# plotter.plt

set terminal wxt 0
reset
set lmargin 9
set rmargin 2
set xlabel "Time [sec]"
set ylabel "Position [m]"
set grid
set key left bottom
p [:][-2.5:2.5] file.".txt" u ($1):($4) w l lw 4 lc 2 title "Measured X", "" u ($1):($2) w l lw 3 lc 3 title "Desired X"

if(exist("output")&& output == 1)\
set terminal postscript eps color enhanced "Arial,20";\
set output file."_X.eps";\
p [:][-2.5:2.5] file.".txt" u ($1):($4) w l lw 4 lc 2 title "Measured X", "" u ($1):($2) w l lw 3 lc 3 title "Desired X";\

set terminal wxt 1
set key left bottom
p [:][-2.5:2.5] file.".txt" u ($1):($5) w l lw 4 lc 2 title "Measured Y", "" u ($1):($3) w l lw 3 lc 3 title "Desired Y"

if(exist("output")&& output == 1)\
set terminal postscript eps color enhanced "Arial,20";\
set output file."_Y.eps";\
p [:][-2.5:2.5] file.".txt" u ($1):($5) w l lw 4 lc 2 title "Measured Y", "" u ($1):($3) w l lw 3 lc 3 title "Desired Y";\

set terminal wxt 2
set multiplot layout 2,1
unset xlabel
set format x ""
set key left bottom
set tmargin screen 0.99
set bmargin screen 0.585
p [:][-2.5:2.5] file.".txt" u ($1):($4) w l lw 4 lc 2 title "Measured X", "" u ($1):($2) w l lw 3 lc 3 title "Desired X"
set format x
set xlabel "Time [sec]"
set key left bottom
set tmargin screen 0.535
set bmargin screen 0.13
p [:][-2.5:2.5] file.".txt" u ($1):($5) w l lw 4 lc 2 title "Measured Y", "" u ($1):($3) w l lw 3 lc 3 title "Desired Y"
unset multiplot

if(exist("output")&& output == 1)\
set terminal postscript eps color enhanced "Arial,20";\
set output file."_Layout.eps";\
set multiplot layout 2,1;\
unset xlabel;\
set format x "";\
set key left bottom;\
set tmargin screen 0.99;\
set bmargin screen 0.585;\
p [:][-2.5:2.5] file.".txt" u ($1):($4) w l lw 4 lc 2 title "Measured X", "" u ($1):($2) w l lw 3 lc 3 title "Desired X";\
set format x;\
set xlabel "Time [sec]";\
set key left bottom;\
set tmargin screen 0.535;\
set bmargin screen 0.13;\
p [:][-2.5:2.5] file.".txt" u ($1):($5) w l lw 4 lc 2 title "Measured Y", "" u ($1):($3) w l lw 3 lc 3 title "Desired Y";\
unset multiplot;\

undefine output
set terminal wxt 0

2017年6月23日金曜日

ROSのtopicを他のPCからRVizで確認したくて2台のPCでを接続する

表題の通りROSを2台のPCで走らせてトピックをやり取りします(正しくは1台のPC上で走っているroscoreに他が接続する).何故やろうと思ったかというとロボットに組み込んだPCでSLAMを走らせているのだけれどリアルタイムでMAPの様子を確認したいから(ssh -Xでやっても良いのだけれどいかんせん重たくなる).ですのでロボット側がマスターとします.

ロボットPC
$ export ROS_HOSTNAME=robot_ip_adress
$ export ROS_MASTER_URI=http://robot_ip_adress:11311
$ roscore
これどうやら全てのターミナルでやる必要があるので~/.bashrcに
$ export ROS_HOSTNAME=robot_ip_adress
$ export ROS_MASTER_URI=http://robot_ip_adress:11311
の二行を最下部に書いてしまいましょう.

次に観測用のPC
$ export ROS_HOSTNAME=observer_ip_adress
$ export ROS_MASTER_URI=http://robot_ip_adress:11311
$ rosrun rviz rviz

これでO.K.

2017年6月18日日曜日

ヘッドレスでUbuntuを起動

ヘッドレス(ディスプレイ接続なし)でUbuntuを起動する.使用PCはZOTACのZBoxです.GPUはNvidia.通常の設定ではディスプレイを探しに行って見つからないずにOSが起動しないという状態になります.ディスプレイがなくても起動することを許可すればOK.

$ sudo nvidia-xconfig --allow-empty-initial-configuration

2017年6月13日火曜日

学内(社内)ネットワークからgitできない

githubからsubmoduleでcloneするときにconnectionがないと怒られる.

fatal: unable to connect to github.com:

原因は学内ネットワークのファイアウォールが強すぎるから

git://~

を弾いてしまっている.ということで「git://」を「https://」に書き換える.

git config --global url."https://".insteadOf git://