8/29/2016

GIT commonly used commands

# How to remove unwanted file from last commit
git reset --soft HEAD~1
Then reset the unwanted files in order to leave them out from the commit:
git reset HEAD path/to/unwanted_file
Now commit again, you can even re-use the same commit message:

git commit -c ORIG_HEAD

# How to resolve conflicts
After git rebase "branch", there may be conflicts.
If you want to accept the changes from the "branch" , just run:
git checkout --ours
Or If you want to accept the changes from current branch, just run:
git checkout --theirs

Or
git rebase -s ours

How to fix this error: error: The following untracked working tree files would be overwritten by merge:
git fetch --all
git reset --hard origin/master




Submodules
=========

g submodule add https://github.com/google/protobuf.git third_party/protobuf
g submodule update --init  # to clone all submodules

How to re-init submodules
emacs .git/config: delete all submodule related items
Then run: git submodule init


After git pull in the main repo, need to run the following commands:
git submodule sync --recursive
git submodule update --recursive


git diff shows no changes, but git status shows a list of modified files:
Open .git/config and make sure:
[core]
        repositoryformatversion = 0
        filemode = false
        bare = false
        logallrefupdates = true
        ignorecase = true
        autocrlf = false
        symlinks = false





8/25/2016

bazel commonly used commands

bazel build foo/bar
bazel build -c opt --strip=always foo/bar/...

# How to verbose log bazel build
bazel build -s //my:target
bazel test --runs_per_test=10

8/24/2016

How to install nginx to serve static files

1. sudo apt install nginx
2. Create a new directory /var/www/track_data
3. Create a new site configuration under /etc/nginx/sites-available
4. Change the nginx settings(/etc/nginx/sites-available/static_content):
server {
  listen 80;

  root /var/www/track_data;

  location / {
      add_header 'Access-Control-Allow-Origin' '*';
      add_header 'Access-Control-Allow-Methods' 'GET';
      autoindex on;
  }
}




8/18/2016

How to add ROS as a third party dependency

1. Create a catkin workspace
2. Follow the instruction to build ROS from source
3. Change the CMakeLists.txt file. Find add_libaray, add STATIC after the library name to build .a files.
4. catkin_make the workspace
5. Find all .a and .h files to include in the BUILD file

8/05/2016

Make git settings better

Copy to ~/.gitconfig
====================
[difftool]
    prompt = false
[gitreview]
    remote = origin
[gui]
    fontui = -family Consolas -size 15 -weight normal -slant roman -underline 0 -overstrike 0
    fontdiff = -family Consolas -size 15 -weight normal -slant roman -underline 0 -overstrike 0
[core]
    editor = emacs -nw
    # Remove the windows trailing space diffs
    autocrlf = input
[diff]
    tool = meld
[merge]

    tool = meld

8/03/2016

How to use SSHFS

# To install
sudo apt install sshfs

# To mount
sshfs -o idmap=user dev@192.168.1.45:/ /mnt/sshfs/

# to umount
fusermount -u /mnt/sshfs/

ROS frequently used commands

Fix most common issues:
=======================
For frame [velodyne]: Frame [velodyne] does not exist
rosrun tf static_transform_publisher 0 0 0 0 0 0 1 map my_frame 10
rosrun tf static_transform_publisher 0 0 0 0 0 0 1 velodyne 10

// launch a service
roslaunch [package name] mtig_driver.launch

// runs a node
rosrun [package name] [node name]

// finds a package
rospack find [package name]
rosstack find [package name]

// Installs dependencies
rosdep install --from-paths src --ignore-src --rosdistro kinetic -y

// Lists topics
rostopic list

// Echo the message
rostopic echo [topic name]

// Build
catkin_make
// Remember to resource the devel/setup.bash in your workspace

// Visualization
rosrun rviz rviz
rosrun rviz rviz -f velodyne

// Dump data
rosbag record -o output.bag [topic]

Common ROS Commands
Package
catkin_create_pkg: create a new package
rospack: get info about the package in the file system
catkin_make: build the packages in your workspace
rosdep: install the system dependencies required for a package
Messages
rosmsg show
rosmsg list
rosmsg md5 : display md5sum of a message
rosmsg package : lists messages in a package
Service
Action
Nodes
rosnode info
rosnode kill
rosnode list
rosnode machine
rosnode ping
rosnode cleanup
Topics
rostopic bw
: display the bandwidth used by the given topicrostopic echo
: print the content of the given topicrostopic find
: find topics using the given message typerostopic hz
: display the publishing rate of the given topicrostopic list: list all active topics in the ROS system
rostopic pub
: to publish a value to a topic with a message typerostopic type
: display the message type of the given topicServices
rosservice call
: call the service using the given argumentsrosservice find : find services in the given service type
rosservice info
: print info about the given servicerosservice type
: print the service type of a given servicerosservice uri
: print the service ROSRPC URIBags
rosbag record -O -a: record all topics to a bag file
rosbag record -O [topic_1] [topic_2] …: record some topics to a bag file
rosbag play : playback an existing bag file
Parameter server
Fill in later

Useful Procedures
Create your ROS workspace (THIS IS IMPORTANT)
mkdir -p ~/catkin_ws/src
cd ~/catkin_ws/src
catkin_init_workspace: initialize a catkin workspace
cd ~/catkin_ws
catkin_make: build the empty workspace
After building the empty space, set the environment variables: echo “source ~/catkin_ws/devel/setup.bash” >> ~/.bashrc
source ~/.bashrc
Create your own package
Switch to workspace src folder: cd ~/catkin_ws/src
Create the package: catkin_create_pkg [dependency 1] [dependency 2]
Example: catkin_create_pkg demo_pkg roscpp std_msgs actionlib actionlib_msgs
After creating the package, build the empty package using: ~/catkin_ws$ catkin_make
Start ROS
Run: $roscore
Useful Drivers
Pointgrey camera driver
Installation
Velodyne driver
Installation
cd catkin_ws/src
git clone https://github.com/ros-drivers/velodyne
Follow the steps in the following link to build VLP16 from source:
http://answers.ros.org/question/226594/how-do-i-build-ros-vlp16-velodyne-driver-for-indigo-using-catkin/
Invoke
roslaunch velodyne_pointcloud VLP16_points.launch
Visualize
rosrun rviz rviz
Bottom left corner: “Add” -> PointCloud2
Change: PointCloud2 -> Topic to: /velodyne_points
Important: Change Global Options -> Fixed Frame to: /velodyne
IP Setup for Sensors
In ubuntu, Edit connections -> Edit -> IPv4 settings
Change method to manual
Setting the address like the following
Pointgrey A (16049350) Red
Address: 192.168.100.1
Netmask: 255.255.255.0
Pointgrey B (16049342): Green
Address: 192.168.101.1
Netmask: 255.255.255.0
Velodyne: 
Address: 192.168.200.77

Netmask: 255.255.255.0


How to build a ROS package

$ source /opt/ros/indigo/setup.bash
$ mkdir -p ~/catkin_ws/src
$ cd ~/catkin_ws/src
$ git clone https://github.com/ros-drivers/velodyne.git

Install all the dependencies:

$ cd ..
$ rosdep install --from-paths src --ignore-src --rosdistro kinetic -y

Then, build everything:

$ catkin_make

$ source devel/setup.bash

========
How to update workspace packages
$ wstool set metapackages/perception --git https://github.com/ros-perception/vision_opencv.git -t src
$ wstool update -t src



8/02/2016

Best Linux Apps

Video editing software: Kdenlive
Screen recorder software: Simple Screen Recorder (sudo apt install simplescreenrecorder)
Office software: WPS office
Reminder notes: Globonote
Remote ssh (Host IP may change): teamviewer
* To enable remote control:
* sudo teamviewer setup
Cloud notes: sudo snap install p3x-onenote to use Microsoft OneNote and OneDrive
PDF Viewer: qpdfview (sudo apt install qpdfview)
Image Viewer: wine + faststone image view (windows version)
* To install: WINEARCH=win32 WINEPREFIX=~/.deepinwine/Deepin-FSViewer deepin-wine6-stable FSViewerSetup78.exe
* Use the open with to open: command is: env WINEPREFIX=/home/liangzou/.deepinwine/Deepin-FSViewer deepin-wine6-stable /home/liangzou/.deepinwine/Deepin-FSViewer/drive_c/Program\ Files/FastStone\ Image\ Viewer/FSViewer.exe
* 常用命令:WINEPREFIX="/home/liangzou/.deepinwine/Deepin-FSViewer" deepin-wine6-stable uninstaller
* 常用命令:https://bbs.deepin.org/en/post/238765
Microsoft Teams: https://github.com/IsmaelMartinez/teams-for-linux
Chinese Input: sogou pinyin, but need to do fcitx 搜狗输入法100%CPU占用解决方法
在fcitx配置里把搜狗云拼音这个选项去掉就可以很完美的解决这问题了
对于
对于hdpi 高分辨率两个显示器,可以修改~/.config/sogou-qimpanel/skin 下面的一个皮肤font_size,对于高分辨率可以通过修改皮肤来切换字体大小
IMPORTANT: 需要取消掉Ctrl+Alt+P and Ctrl+Alt+B hotkey shortcuts的占据:打开Fcitx配置,Global Config, Show Advanced Options, disable Ctrl+Alt+P and Ctrl+Alt+B

SSHFS: to mount a remote system to your machine
Hex Binary Data Viewer: bless
Text Editor: Emacs
Disk management: gparted
Get network IP of other devices: wireshark
Markdown language viewer: https://github.com/retext-project/retext
wechat: https://github.com/zq1997/deepin-wine (Deprecated: https://github.com/wszqkzqk/deepin-wine-ubuntu)

Ubuntu 20.04 只有deepin-wine6 6.0.0.39 and 3.2.1是好的,用以下命令downgrade:
weget https://com-store-packages.uniontech.com/appstore/pool/appstore/d/deepin-wine6-stable/deepin-wine6-stable_6.0.0.39-1_amd64.deb
sudo dpkg -i deepin-wine6-stable_6.0.0.39-1_amd64.deb
sudo apt-mark hold deepin-wine6-stable

wget https://com-store-packages.uniontech.com/appstore/pool/appstore/c/com.qq.weixin.deepin/com.qq.weixin.deepin_3.2.1.154deepin14_i386.deb

sudo dpkg -i com.qq.weixin.deepin_3.2.1.154deepin14_i386.deb

暂时不自动升级deepin wechat:
sudo apt-mark hold com.qq.weixin.deepin

等修复后需要升级的话:
sudo apt-mark unhold com.qq.weixin.deepin

有时候系统更新完之后会出现打不开微信的情况,重新启动一下电脑就好了

* /opt/deepinwine/tools/run_v4.sh needs to be modified to use: WINE_CMD="LC_ALL=zh_CN.UTF-8 $APPRUN_CMD"
* Setup shortcut ctrl + alt + w:

请在路径:设置中心->键盘->快捷键中添加,如下:

昵称:提取微信消息

命令:/opt/deepinwine/tools/sendkeys.sh w WeChat

快捷键:Ctrl+Alt+w

按照以上就能设置成功。


* 常用命令:安装最新Wechat,WINEPREFIX=~/.deepinwine/Deepin-WeChat-latest/ deepin-wine WeChatSetup.exe

修改分辨率:WINEPREFIX=~/.deepinwine/Deepin-WeChat/ deepin-wine winecfg

* If not using deepin-wine and wine instead, the method to change default Linux browser to open links:
Modify ~/.wine32/drive_c/Program Files/Internet Explorer/iexplore.exe to a script:
#!/bin/bash
exec /usr/bin/firefox "$@"

* If not using deepin-wine and wine instead, fix the shadow issue:

Reference: (https://zhuanlan.zhihu.com/p/106926984). Solution is already in OneDrive ubuntu_home/bin-scripts.tar fix-wechat.py

在 Ubuntu 下安装 Deepin-wine 环境后,QQ 界面的字体看着不太舒服,于是就找了些文章看看能不能改成微软雅黑,经过一番折腾后修改成功,主要步骤如下:

    在 /usr/share/fonts/ 目录下建立个文件夹用于存放 windows 的字体,例如:windows
    下载微软雅黑字体文件 msyh.ttc (https://github.com/owent-utils/font/blob/master/%E5%BE%AE%E8%BD%AF%E9%9B%85%E9%BB%91/MSYH.TTC),并复制到这个目录
    运行 fc-cache 更新字体信息缓存
    打开注册表:WINEPREFIX=~/.deepinwine/Deepin-Wechat deepin-wine regedit
    找到键 HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\FontLink\SystemLink
    修改里面的三个字段的数据,在前面加上 MSYH.TTC,Microsoft YaHei