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

boost mutex

boost mutex

boost mutex

better use boost::shared_mutex!!
=> see boost::shared_mutex

essentials

  • mutable
  • scoped_lock

boost::mutex example

#include "boost/thread/mutex.hpp" /* mutex* */

class Some {
#define _DOBODIESLOCK() \
    boost::mutex::scoped_lock __lk(this->bodiesLock); \
    (void)(__lk)

    Foo getFoo(void) const
    {
        _DOBODIESLOCK();
        ...
        Foo ret = this->foo:
        ...
        return ret;
    }
    void setFoo(Foo const& foo)
    {
        _DOBODIESLOCK();
        ...
        this->foo = foo;
        ...
    }

    Foo foo;
    mutable boost::mutex bodiesLock;/* !! */
#  undef _DOBODIESLOCK
};

boost shared mutex

essentials

  • mutable
  • shared_lock for read
  • upgrade_lock and upgrade_to_unique_lock for write

example

#include "boost/thread/shared_mutex.hpp" /* shared_mutex */

class Some {
#define _DOSHAREDREAD() \
    boost::shared_lock<boost::shared_mutex> __rLock(this->rwlock); \
    (void)(__rLock)
#define _DOEXCLUSIVEWRITE() \
    boost::upgrade_lock<boost::shared_mutex> __uplock(this->rwlock); \
    boost::upgrade_to_unique_lock<boost::shared_mutex> __wLock(__uplock); \
    (void)(__wLock)

    Foo getFoo(void) const
    {
        _DOSHAREDREAD();
        ...
        Foo ret = this->foo:
        ...
        return ret;
    }
    void setFoo(Foo const& foo)
    {
        _DOEXCLUSIVEWRITE();
        ...
        this->foo = foo;
        ...
    }

    Foo foo;
    mutable boost::shared_mutex rwlock;
#  undef _DOSHAREDREAD
#  undef _DOEXCLUSIVEWRITE
}: