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 
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=12not 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::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::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) 


你可能感兴趣的:(ROS学习笔记,视觉SLAM,计算机视觉)