Commit c9cd0cdb authored by Arnaud Blanchard's avatar Arnaud Blanchard

Documentation and useful bashes

parents
Blaar works with any cmake from version 2.6. ( [cmake documentation](https://cmake.org/cmake/help/cmake2.6docs.html) )
The cmake builds are in `blaar_build/<project>`. You usually do not need to access here.
The makefiles produced are not human readable but you can use `make help` to see the usable targets. To reset everything when you have changed **CMakeLists.txt** run `make ZERO_CHECK`.
The important settings are stored in CMakeCache.txt. It is a good place to check where the libs are found or where different outputs will be.
When you think that your changes have no effect, you can remove this file and relaunch compilation. It is also safe to remove the whole `blaar_build/` directory. However, you should not need it, the important files to changes are **CMakeLists.txt** in the source root of each project.
CMake configuarion
==================
We use conventions which should make you not needing cmake but with cmake it is much easier. It manages dependencies and it is also good when using an integrated development editor ( eclipse, Xcode, ...). It will be also very useful to test the code and to produce bundles or packages.
[[README]] | [[CMAKE]] | [[ROADMAP]]
Compilation
===========
Use `./compile.sh <project dir> [Release|Debug|RelWithDebugInfo|RelMinSize]` (blc, blv4l2, ...)
The binaries will be in `../blaar_buid/<Release_bin|Debug_bin|RelWithDebugInfo_bin|RelMinSize_bin>/` and the libraries in `../blaar_buid/<Release_lib|Debug_lib|RelWithDebugInfo_lib|RelMinSize_lib>/`
In case of problem you may debug: `./debug.sh <project>` or realize memory check with valgrind: `./valgrind.sh <project>`
The cmake build will be in `../blaar_build/<project>/`. ( more details about [[CMAKE]] )
Using an IDE
------------
If you want to edit the code, you can use:
* [With eclipse](ECLIPSE)
* [With xcode](XCODE)
Code documentation
==================
To build and see the documentatoin do: `./doc.sh <project>`
The built documentation will be in `../blaar_build/doc/<project>/html/index.html` and will be launched automatically.
[[blgtk/GTK]]
\ No newline at end of file
./eclipse_create_project.sh <project dir>
Then you have to launch eclipse
file->import->general->existing projects->select root->browse: `<blaar_build>/eclipse/<project>`
If you want to debug:
run->run configurations->new C/C++ application->browse: `<blaar_build>/Debug_bin/<project>`
# begin opencl config
modprobe nvidia_340_uvm
mknod -m 666 /dev/nvidia-uvm c 249 0
clinfo
# end opencl config
Then use it
\ No newline at end of file
[[DEVELOPMENT]] | [[THEORY]] |[[TODO]]
Basic Libraries And Applications for Robotics (blaar)
====================================================
Copyright : [ETIS](http://www.etis.ensea.fr/neurocyber) - ENSEA, University of Cergy-Pontoise, CNRS (2011-2016)
Author : [Arnaud Blanchard](http://arnaudblanchard.thoughtsheet.com)
Licence : [CeCILL v2.1](http://www.cecill.info/licences/Licence_CeCILL_V2-en.html)
Basic libraries
---------------
- [blc](blc/README.md) : C/C++. Very generic tools
- blv4l2 : Video capture on Linux. Need video for linux libv4l2.
- blQTKit : Video on MAC OS. Need Quicktime libQTKit.
- blcl : OpenCL
- blalsa : ALSA sound on Linux
- blgtk : helpers for gtk graphic library
Basic applications
------------------
- [blc_channels](blc_channels/README) : Display and manipulate blc channels
- i_coreaudio
- i_create_mask
- i_QTKit_camera
- i_v4l2_camera
- i_oscillator
- i_wiimote
- [f_view_channel](f_view_channel/README) : Display bloc channel in a graphical interface
- f_gnuplot : Display data graphs of blc_channels
Usage
=====
./run.sh <project> [args ...]
This automatically compiles the project in release mode and executes it. It uses `rlwrap` to have much better keyboard interaction such as reediting and using history but may sometimes confuse the terminal.
For more details about compilation, see [[DEVELOPMENT]].
Need to install packages
========================
Ubuntu
------
sudo apt-get install git cmake doxygen pkgconfig gtk+3
for OpenCL: nvidia-opencl-dev
OSX
---
brew install git cmake doxygen pkgconfig gtk+3 vte3 gnuplot --with-qt gnome-icon-theme
\ No newline at end of file
Mainly manage chars8, uchars8 and floats
Features
========
- teminating processes: done
- showing processes using a shared memory: done
- sending share memory with UDP
f_gnuplot
=========
\ No newline at end of file
Synchronisation
===============
We will have 3 cases:
Preventing writing and reading at the same time
-----------------------------------------------
We can use a semaphore.
Process1
sen_wait semaphore
write
sem_post semaphore
Process2
sem_wait semaphore
read
sem_post semaphore
The problem is that two processes cannot read at the same time, as they should. If the process stop in the writing or reading part, the semaphore is locked for ever. We need mutexes. To share mutexes across processes you need to make them in share memory and define attributes with `pthread_mutexattr_setpshared`, PTHREAD_PROCESS_SHARED. The POSIX muteness have a robust mode that make them unlock it when the process die. On top of it the next unlocked process will know that a process died unexpectedly by receiving the EOWNERDEAD error code. This will allow him to manage corrupted data and eventually relaunch the failing process. It is not implemented in OS X !!!
On OS X, the `pthread_rwlock_init`doe not support PTHREAD_PROCESS_SHARED therefore we avoid it. A solution may be to have one mutex per reader. A bit costly but clear. Otherwise you need a counter but you will not know which process fail for example.
It exists mutex with conditional variable than can be broadcastly changed. The idea would be than a writer can broadcast the new situation to all the readers.
In general
==========
Using synchronization
f_view_channel
--------------
- f_view_channel with multiple channels
- Possibility to have vector or matrix of images
./xcode_project.sh <project dir>
XCode will be automatically launched with the project
\ No newline at end of file
#!/bin/sh
usage()
{
echo "usage: compile.sh <project> [Release|Debug|RelWithDebugInfo|MinSizeRel] [<target>]" >&2
exit 1
}
if [ ! $1 ]; then
echo "You need to precise the project directory to compile.";
usage
exit 1;
fi
project_dir="$PWD/$1"
current_dir="$PWD"
blaar_build_dir="${PWD}_build"
if [ "$2" ]; then
case "$2" in
Release|Debug|RelWithDebugInfo|MinSizeRel) build_type="$2";;
*)echo "Unknown build type '$2'">&2; usage;;
esac
else build_type="Release"
fi
build_dir="$blaar_build_dir/${build_type}/build/$1"
mkdir -p ${blaar_build_dir}/doc/$1
mkdir -p $build_dir
[ -d build ] || ln -s "$blaar_build_dir" build
cd $build_dir
[ -f Makefile ] || cmake $project_dir -DCMAKE_BUILD_TYPE=${build_type} -DBLAAR_DIR="$current_dir" -DLIBRARY_OUTPUT_PATH="${blaar_build_dir}/${build_type}/lib" -DEXECUTABLE_OUTPUT_PATH="${blaar_build_dir}/${build_type}/bin" -DCMAKE_LIBRARY_PATH="${blaar_build_dir}/${build_type}/lib"
make --jobs ${3%/} #remove the eventual last '/'
result=$?
cd $current_dir
exit $result
#!/bin/sh
blar_build_dir="${PWD}/build"
./compile.sh $1 "Debug" $1 || {
echo "fail compiling '$1'"
exit 1
}
bin_dir="$blar_build_dir/Debug/bin"
program=`basename $1`
shift #remove $1
echo >&2
echo "'run' to start" >&2
echo >&2
echo "execute:" >&2
command -v lldb && {
set -x; lldb -- "$bin_dir/$program" "$@"
}||{
set -x; gdb --args $bin_dir/$program "$@"
}
#!/bin/sh
./compile.sh $1 Release doc_$1
blar_build_dir="${PWD}_build"
if [ $? ] ; then
if type xdg-open 2>/dev/null; then xdg-open "$blar_build_dir/doc/$1/html/index.html";
elif type open 2>/dev/null; then open "$blar_build_dir/doc/$1/html/index.html";
else echo "Open documentation in: $blar_build_dir/doc/$1/html/index.html"; fi
else
echo "Failing building the documentation"
fi
#!/bin/sh
# Basic Library for C/C++ (blclib)
# Copyright ETIS — ENSEA, Université de Cergy-Pontoise, CNRS (2011 - 2014)
# Author: Arnaud Blanchard
# This software is a computer program whose purpose is to simulate neural networks and control robots or simulations.
# This software is governed by the CeCILL v2.1 license under French law and abiding by the rules of distribution of free software.
# You can use, modify and/ or redistribute the software under the terms of the CeCILL v2.1 license as circulated by CEA, CNRS and INRIA at the following URL "http://www.cecill.info".
# As a counterpart to the access to the source code and rights to copy, modify and redistribute granted by the license,
# users are provided only with a limited warranty and the software's author, the holder of the economic rights, and the successive licensors have only limited liability.
# In this respect, the user's attention is drawn to the risks associated with loading, using, modifying and/or developing or reproducing the software by the user in light of its specific status of free software,
# that may mean that it is complicated to manipulate, and that also therefore means that it is reserved for developers and experienced professionals having in-depth computer knowledge.
# Users are therefore encouraged to load and test the software's suitability as regards their requirements in conditions enabling the security of their systems and/or data to be ensured  and, more generally, to use and operate it in the same conditions as regards security.
# The fact that you are presently reading this means that you have had knowledge of the CeCILL v2.1 license and that you accept its terms.
current_dir=`pwd`
parent_dir=`dirname $current_dir`
build_dir="$parent_dir/`basename $current_dir`_build"
if [ $# != 1 ]
then
echo "You need a project name as argument."
echo "Usage : xcode_project project_directory"
exit 1
fi
developer_tools/create_project.sh $1 $build_dir eclipse
echo "eclipse -> file -> import -> general -> existing project -> root directory -> browse -> $build_dir/eclipse/$1"
echo
#!/bin/sh
# Basic Libraries And Applications (blaa)
# Copyright ETIS — ENSEA, Université de Cergy-Pontoise, CNRS (2011 - 2015)
# Author: Arnaud Blanchard
#
# This software is governed by the CeCILL v2.1 license under French law and abiding by the rules of distribution of free software.
# You can use, modify and/ or redistribute the software under the terms of the CeCILL v2.1 license as circulated by CEA, CNRS and INRIA at the following URL "http://www.cecill.info".
# As a counterpart to the access to the source code and rights to copy, modify and redistribute granted by the license,
# users are provided only with a limited warranty and the software's author, the holder of the economic rights, and the successive licensors have only limited liability.
# In this respect, the user's attention is drawn to the risks associated with loading, using, modifying and/or developing or reproducing the software by the user in light of its specific status of free software,
# that may mean that it is complicated to manipulate, and that also therefore means that it is reserved for developers and experienced professionals having in-depth computer knowledge.
# Users are therefore encouraged to load and test the software's suitability as regards their requirements in conditions enabling the security of their systems and/or data to be ensured  and, more generally, to use and operate it in the same conditions as regards security.
# The fact that you are presently reading this means that you have had knowledge of the CeCILL v2.1 license and that you accept its terms.
#Default values
install_prefix="~/.local"
current_dir=`pwd`
parent_dir=`dirname $current_dir`
build_dir="$parent_dir/`basename $current_dir`_build"
usage()
{
echo "Usage: install [options] project_directory"
echo " -b directory :Directory to create the build. (default: $build_dir)"
echo " -h :Display this help."
echo " -i directory :Directory to install the binaries. Default: $install_prefix"
echo
}
set -- $(getopt b:hi: "$@")
while [ $# -gt 0 ]
do
case "$1" in
(-b) build_dir="$2"; shift;;
(-h) usage;exit 0;;
(-i) install_prefix="$2"; shift;;
(--) shift; break;;
(-*) echo "$0: error - unrecognized option $1" 1>&2; exit 1;;
(*) break;;
esac
shift
done
if (($# == 0 ))
then usage; exit 1;
else
echo
echo " Install $1"
echo "=========================="
mkdir -p $build_dir/${1}_build && cd $build_dir/${1}_build && cmake -q $current_dir/$1 -DCMAKE_INSTALL_PREFIX=$install_prefix -DCMAKE_BUILD_TYPE="Release" && make && make install
if [ $? -ne 0 ]
then
echo -e "\nFail installing $1\n"
else
echo -e "\nSuccess installing $1 in $install_prefix .\n"
fi
cd $current_path
fi
#!/bin/sh
current_dir=`pwd`
parent_dir=`dirname $current_dir`
./compile.sh $1 Release $1 >&2 #compile only the executable target
fail=$?
cd $current_dir
if [ $fail != 0 ];
then
echo "fail compiling '$1'" >&2
exit 1
fi
bin_dir="$parent_dir/`basename $current_dir`_build/Release/bin"
program=`basename $1`
shift #remove $0 i.e. run.sh
echo "execute:" >&2
set -x
$bin_dir/$program "$@"
./run.sh f_schunk_hand &
./run f_shared_task
#!/bin/sh
./compile.sh $1 "Debug" $1 || exit 1
bin_dir="${PWD}_build/Debug/bin"
program=`basename $1`
shift #remove $1
echo >&2
command -v valgrind &&{
set -x;
valgrind --dsymutil=yes $bin_dir/$program "$@" || echo "Problems of memory"
} || echo "You need to install valgrind"
#!/bin/sh
command -v gollum &&
{
gollum --config gollum/config.rb --live-preview&
sleep 2 && command -v xdg-open && xdg-open http://localhost:4567/README || command -v open && open http://localhost:4567/README &
}|| echo "You need to insall gollum: sudo ./gollum/install.sh" >&2
#!/bin/sh
current_dir=`pwd`
parent_dir=`dirname $current_dir`
build_dir="$parent_dir/`basename $current_dir`_build"
if (( $# != 1 ))
then
echo "You need a project directory as argument."
echo "Usage : xcode_project <project_directory>"
exit 1
fi
name=`basename $1`
developer_tools/create_project.sh $1 $build_dir xcode
if (( $? == 0 ))
then
open $build_dir/xcode/$1/$name.xcodeproj
fi
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment