console output color

console output color

#


ansi code

  • 终端字符的颜色是用 esc 开头的转义序列进行控制 是文本模式下的系统显示功能
  • esc i.e. \033 (esc ascii 码十进制 27. 八进制 33)
  • 使用 ; 分隔以连续设置
code effect
\033[0m 关闭所有属性
\033[1m 粗体
\033[4m 下划线
\033[5m 闪烁
\033[7m 反显
\033[8m 消隐
\033[22m 非粗体
\033[24m 非下划线
\033[25m 非闪烁
\033[27m 非反显
\033[fg-colorm e.x. \033[30m 设置前景色
\033[bg-colorm e.x. \033[47m 设置背景色
\033[nA 光标上移 n 行
\03[nB 光标下移 n 行
\033[nC 光标右移 n 行
\033[nD 光标左移 n 行
\033[y;xH 设置光标位置 (x, y)
\033[2J 清屏
\033[K 清除从光标到行尾的内容
\033[s 保存光标位置
\033[u 恢复光标位置
\033[?25l 隐藏光标
\033[?25h 显示光标

fg color

  • 字(fg)颜色: [30, 39]
value color
30
31
32 绿
33
34
35
36 深绿
37 白色

bg color

  • 背景(bg)颜色范围: [40, 49]
value color
40
41
42 绿
43
44
45
46 深绿
47 白色

example

#define YUIWONGLOGNFTALL(__name, __fmt, __args...) \
    fprintf(stdout, \
        "\033[30;49m[%s %015ld ALL ][%s] " __fmt " (%s+%d)\n\033[0m", \
        yuiwong::LogRealTime().c_str(), ::pthread_self(), __name, ##__args, \
        __FILE__, __LINE__)
#define YUIWONGLOGNFTFATA(__name, __fmt, __args...) \
    fprintf(stderr, \
        "\033[1;31;49m[%s %015ld FATA][%s] " __fmt " (%s+%d)\n\033[0m", \
        yuiwong::LogRealTime().c_str(), ::pthread_self(), __name, ##__args, \
        __FILE__, __LINE__)
#define YUIWONGLOGNFTERRO(__name, __fmt, __args...) \
    fprintf(stderr, \
        "\033[31;49m[%s %015ld ERRO][%s] " __fmt " (%s+%d)\n\033[0m", \
        yuiwong::LogRealTime().c_str(), ::pthread_self(), __name, ##__args, \
        __FILE__, __LINE__)
#define YUIWONGLOGNFTWARN(__name, __fmt, __args...) \
    fprintf(stderr, \
        "\033[33;49m[%s %015ld WARN][%s] " __fmt " (%s+%d)\n\033[0m", \
        yuiwong::LogRealTime().c_str(), ::pthread_self(), __name, ##__args, \
        __FILE__, __LINE__)
#define YUIWONGLOGNFTNOTE(__name, __fmt, __args...) \
    fprintf(stdout, \
        "\033[1;30;49m[%s %015ld NOTE][%s] " __fmt " (%s+%d)\n\033[0m", \
        yuiwong::LogRealTime().c_str(), ::pthread_self(), __name, ##__args, \
        __FILE__, __LINE__)
#define YUIWONGLOGNFTINFO(__name, __fmt, __args...) \
    fprintf(stdout, \
        "\033[30;49m[%s %015ld INFO][%s] " __fmt " (%s+%d)\n\033[0m", \
        yuiwong::LogRealTime().c_str(), ::pthread_self(), __name, ##__args, \
        __FILE__, __LINE__)
#define YUIWONGLOGNFTDEBU(__name, __fmt, __args...) \
    fprintf(stdout, \
        "\033[36;49m[%s %015ld DEBU][%s] " __fmt " (%s+%d)\n\033[0m", \
        yuiwong::LogRealTime().c_str(), ::pthread_self(), __name, ##__args, \
        __FILE__, __LINE__)
#define YUIWONGLOGNFTDETA(__name, __fmt, __args...) \
    fprintf(stdout, \
        "\033[30;49m[%s %015ld DETA][%s] " __fmt " (%s+%d)\n\033[0m", \
        yuiwong::LogRealTime().c_str(), ::pthread_self(), __name, ##__args, \
        __FILE__, __LINE__)


cmake 2

cmake 2

use pkg-config in cmake

example

if($ENV{ROS_DISTRO} STREQUAL jade)
  message(STATUS "ROS_DISTRO is jade")
  find_package(PkgConfig REQUIRED)
  pkg_search_module(eigen3 REQUIRED eigen3)
  message(STATUS "eigen3_INCLUDE_DIRS " ${eigen3_INCLUDE_DIRS})
else()
  find_package(Eigen3 REQUIRED)
  message(STATUS "EIGEN3_INCLUDE_DIRS " ${EIGEN3_INCLUDE_DIRS})
endif()

see also and ref.
https://cmake.org/cmake/help/v3.0/module/FindPkgConfig.html

cmake link directories

example

message(STATUS "catkin_make LD_LIBRARY_PATH " $ENV{LD_LIBRARY_PATH})
link_directories($ENV{LD_LIBRARY_PATH})
set(LIBS
  # ros
  ${catkin_LIBRARIES}
  pcl_ros_tf
  # no ros
  ${PCL_LIBRARIES}
  ${octomap_LIBRARIES}
  boost_system)

mac-install-ubuntu

install ubuntu on mac

#

  • example (2017 05)

better install the latest lts or the latest!! here the example i need
another old version ubuntu for some outdated short support
(.. and at present vbox almost cannot work..),
later will upgrade to the latest!!

* ubuntu 14.04.5 desktop amd64
* macbookpro

install

download ubuntu

http://mirrors.163.com/ubuntu-releases/14.04.5/ubuntu-14.04.5-desktop-amd64.iso

create startup disk / udisk

use “startup disk creator”

mac partition in recovery mode

  • press command + R to recovery mode when boot
  • repair disk error in recovery mode
  • partition

install ubuntu

  • plug startup udisk to mac
  • press option/alt to choose boot media: usb
  • install ubuntu and not reboot when finish

config efi boot

sudo apt-get install efibootmgr
sudo efibootmgr

# let boot to ubuntu
sudo efibootmgr -o 0, 80

reboot to ubuntu

config macos boot

  • edit /etc/grub.d/40_custom, add:
menuentry "macos" { exit }
  • edit: /etc/default/grub
    • original:
GRUB_DEFAULT=0
GRUB_HIDDEN_TIMEOUT=0
  • modified
GRUB_DEFAULT=2
#GRUB_HIDDEN_TIMEOUT=0
  • or modified (mac default)
GRUB_DEFAULT=2
#GRUB_HIDDEN_TIMEOUT=0

apply macos boot config

sudo update-grub

# here install to /dev/sda
sudo grub-install /dev/sda

reboot and done

troubleshoot

if wireless fail because use ‘bcmwl-kernel-source’, try below to fix:

  • full remove bcmwl-kernel-source
sudo apt-get purge bcmwl-kernel-source
  • force shutdown
  • power on and boot
  • so maybe not try to enable the broadcom addtional driver!!

fix ~

  • add below to /etc/rc.local
echo 0 > /sys/module/hid_apple/parameters/iso_layout

see also