天天看點

Ubuntu、ROS、LINUX下的一些記錄

文章目錄

      • Markdown自動生成目錄
      • vscode多機同步
      • Latex Ubuntu
      • c++的路徑join
      • bash和指令行處理文本和檔案非常有用的工具
      • cuda安裝:
      • ubuntu 下Python3的定位
      • 快速生成image.txt:
      • optris_ROS_catkin_make失敗
      • ubuntu挂載window分區
      • QTcreator+ROS
      • rqt_graph
      • ubuntu啟動腳本
      • ubuntu錄屏
      • ROS tf學習

Markdown自動生成目錄

加入

[TOC]

即可

vscode多機同步

tokens:

min: 751d4c977260f423a887665a34e217e174ac53ae

VScode sync

Latex Ubuntu

texliv and texmaker

https://milq.github.io/install-latex-ubuntu-debian/

c++的路徑join

用到boost,代替Python的os.path.join

#include <boost/filesystem.hpp>
namespace fs = boost::filesystem;
    fs::path root(path_root);
    fs::path pathD = root / "val_output_depth";
    fs::path pathInorm = root / "val_output_pure";
    fs::path pathIreal = root / "val_output_intensity";
    cout << "root path " << root << endl;
    string name = pathD.string();
           

bash和指令行處理文本和檔案非常有用的工具

從檔案中随機抽取n行另存為:

shuf -n5 train_gt.txt > val_gt.txt
           

檢視目錄下檔案夾大小

du -h --max-depth=1
           

tree --filelimit 10

,檢視目錄結構,不會列印一堆圖檔

if控制,condition一定要有空格”,而bash中變量名和值之間不能有空格!!

a=12

not

a = 12

if [ -d "${OUT_PATH}" ]
#if [-d "${OUT_PATH}"]
then 
    echo "have result dir"
else
    mkdir -p ${OUT_PATH}
    echo "mkdir result dir"
fi
           

grep配合 xargs,批量删除

find | grep .zip| xargs rm -rf
           

cuda安裝:

1.下載下傳cuda軟體(9.0版本)

wget http://mirror.bj.sensetime.com/research/cuda/cuda_9.0.176_384.81_linux.run
           

2.下載下傳NVIDIA顯示卡驅動

wget http://software.bj.sensetime.com/2-Linux/NVIDIA-Linux-x86_64-410.78.run
           

3.添加安裝程式的可執行權限:

chmod +x NVIDIA* cuda*
           

4.禁用預設的nouveau開源顯示卡驅動:

rmmod nouveau

echo "blacklist nouveau" >> /etc/modprobe.d/blacklist-nouveau.conf
           

之後建議重新開機下系統

5.關閉系統圖形界面,顯示卡驅動安裝過程需要在指令行模式下進行(Ctrl + Alt + F2 進入指令行模式)

sudo su root
service lightdm stop
           

6.安裝顯示卡驅動程式,指令:

./NVIDIA-Linux-x86_64-410.78.run -a -s -Z --no-opengl-files
           

7.安裝CUDA-9.0 驅動(請把cuda安裝程式和安裝目标目錄替換為自己需要安裝的對應版本)

./cuda_9.0.176_384.81_linux.run --no-opengl-libs --toolkit --samples --samplespath=/usr/local/cuda-9.0 -silent
           

8.添加安裝的環境變量(将紅色部分替換為自己安裝的對應版本):

echo 'export LD_LIBRARY_PATH=/usr/local/cuda/lib:/usr/local/cuda/lib64/:/usr/local/cuda-9.0/lib:/usr/local/cuda-9.0/lib64/:$LD_LIBRARY_PATH' >> /etc/profile
echo 'export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/cuda-9.0/bin:/usr/local/cuda/bin:$PATH' >> /etc/profile
echo '/usr/local/cuda/lib64' >> /etc/ld.so.conf.d/cuda.conf
ldconfig
           

9.下載下傳cudnn

wget http://mirror.bj.sensetime.com/research/cudnn/cudnn-9.0-linux-x64-v7.tar
           

10.安裝cudnn

tar xf cudnn-9.0-linux-x64-v7.tar 
mv cuda/lib64/libcudnn* /usr/local/cuda-9.0/lib64/
mv cuda/include/cudnn.h /usr/local/cuda-9.0/include/
           

ubuntu 下Python3的定位

sudo gedit ~/.bashrc
export PYTHONPATH="/home/userx/.local/lib/python3.5/site-packages:$PYTHONPATH"
source ~/.bashrc
           

快速生成image.txt:

Windows下:

在cmd裡 dir *.jpg /B >> a.txt

linux:

ls -R *.jpg > test_file.txt
           

Linu就友善了,直接

ls *.png > image.txt
           

optris_ROS_catkin_make失敗

的gcc g++是48版本太低。需要4.9.更新GCC至5.3 成功解決

當sudo apt-get upgrade/update的時候有包失敗 可以跳過 加字尾 --fix-missing

裝ubuntu時 不要改預設的裝置引導位置!!!!

ubuntu挂載window分區

先fdisk -lu 找到編号,如果是NTFS類型的:

sudo ntfsfix /dev/sda8
           

否則直接mount

QTcreator+ROS

gedit ~/.local/share/applications/DigiaQt-qtcreator-commnity.desktop
           

或者

gedit /usr/share/applications/DigiaQt-qtcreator-commnit
           

在第三行加入bash -i -c

$ cat qtcreator.desktop

[Desktop Entry]
Exec=bash -i -c qtcreator %F
Icon=qtcreator
Type=Application
Terminal=false
Name=Qt Creator
GenericName=Integrated Development Environment
MimeType=text/x-c++src;text/x-c++hdr;text/x-xsrc;application/x-designer;application/vnd.nokia.qt.qmakeprofile;application/vnd.nokia.xml.qt.resource;
Categories=Qt;Development;IDE;
InitialPreference=9 

           

rqt_graph

在roslauch的時候

rosrun rqt_graph rqt_graph
           

可以很友善地看各個node節點的關系

ubuntu啟動腳本

sudo gedit /etc/rc.local
           

exit 0

前面添加指令

TX2:

在終端中執行gnome-session-properties

bash /home/nvidia/run.sh

不要提示煩人的problem error:

sudo gedit /etc/default/apport 

           

ubuntu錄屏

用Kazam即可

ROS tf學習

TF:


	1.broadcaster


	#include <tf/transform_broadcaster.h>


	tf::TransformBroadcaster br;    //create a TransformBroadcaster object,用來傳送Transform




	way1:
	// create a Transform object 
	    tf::Transform transform;


	    transform.setOrigin(……));    //set pose


	        transform.setRotation(……);    //set rotation


	    // send Transform


		 br.sendTransform(tf::StampedTransform(transform, ros::Time::now(), parent_frame_id, child_frame_id));
	



	way2:


	//creat and set StampedTransform
	tf::StampedTransform StampedT;
	StampedT.frame_id_ = "/camera_init";


	    StampedT.child_frame_id_ = "/laser_odom";


	    StampedT.stamp_ =    ;    //set time


	    StampedT.setRotation(  );


	    StampedT.setOrigin( );
	// send Transform


	     tf.sendTransform(StampedT);


	Tips: sendTransform and StampedTransform have opposite ordering of parent and child. 


	2.Listener




	#include <tf/transform_listener.h>
tf::TransformListener listener;//creater TransformListener object
//we want the transform from turtle1 to turtle2, and store in transform
tr::StampedTransform transform;
listener.lookupTransform("/turtle2","/turtle1",ros::Time(0),transform);//(father,child,time,transform) 


           

繼續閱讀