Monday, June 18, 2012

Ubuntu Shell scripting for ROS

Hi Guys,

  • Well, I have been using ROS (Robot Operating System: http://www.ros.org/wiki/) to develop my robotics packages and I have been syncing my packages between my laboratory and my home using Dropbox (https://www.dropbox.com/).
  • However, in my laboratory the PC is a 64 bit machine and at home I have a 32 bit machine. So, I have to build the packages from the beginning after syncing via Dropbox. When you have too many packages this is annoying.
  • Today I learned how to do this by a shell script.
  • I know it looks really childish but it does what I want.
  • Create a script file and enter the following into that file.
    • e.g. my_script.sh

#!/bin/bash
roscd my_pkg_one
make clean
rosmake my_pkg_one
roscd my_pkg_two
make clean
rosmake my_pkg_two


  • Go to the directory where your file is located and make it executable.
    • chmod +x my_script.sh 
  •  Run you script
    •  . ./my_script.sh
      the first dot makes sure the commands are run from the current shell and not from a subshell


  • If you want to run your script from anywhere you can add the script path to the PATH environment variable.
    • export PATH=$PATH:~/my_scripts     tothe end of your ~/.bashrc file. 
    • finally source your .bashrc file by
      • source ~/.bashrc

Sunday, June 17, 2012

Environment variables in Ubuntu

Hi guys,

  • I have been using the .bashrc file for long time but it was today that I understood clearly the syntax of export in .bashrc file.
  • Before, going into that let's get to know about the environment variables little bit more.
  • When we open a terminal session and type in a command like ls it is searched in the directories that are marked by the PATH variable.
  • PATH is an environment variable.
  • An environment variable is a variable that persists for the life of a terminal session. The applications running in that session can access these variables. A listing of all the environment variables can be obtained by
    • abc@def:~$ export
  • PATH environment variable has a special format. Use echo command to have a look at the variable:
    • abc@def:~$ echo $PATH
    • /usr/local/bin:/bin:/usr/bin:/sbin:/usr/sbin:.
  • PATH variable is a : separated set of directories. All these directories will be searched when you execute a command in the terminal.
  • Let's give the PATH variable a different set of values
    • export PATH=/usr/bin:/usr/sbin
    • now, if we execute the ls command once again it will give an error because it no longer has /bin in the PATH variable.
  • Instead of changing or replacing the current set of directories in the PATH variable what you should do is to append it.
    • export PATH=$PATH:/new/path
    • echo $PATH  will now give you /usr/bin:/usr/sbin:/new/path
  • These changes, however, will be only valid to the current session. In order to making the changes permanent we can use a specific file called .bashrc file.
    • In Ubuntu (UNIX), files beginning with . are configuration files and are usually hidden.
    • To view these files use ls -a
  • The commands in .bashrc file get executed every time you start a new terminal
    • if you wish to have certain directories automatically added to PATH variable simply place those commands at the end of this file
 p.s.
  • If you are interested in knowing the full path of a binary like ls you can use the command which to find that out
    • e.g. abc@def:~$ which ls    will give you the result -> /bin/ls
      so, the executable ls is located in /bin directory


       

credit should go to the original contributor at http://www.cs.purdue.edu/homes/cs348/unix_path.html

Saturday, June 16, 2012

Grub Customizer for Ubuntu 11.04

Hey guys,

  • Some of you have already experienced that the program "startup manager" does not function in Ubuntu 11.04.
  • Use "Grub Customizer" instead.
  • Here are the steps:
    • sudo apt-add-repository ppa:danielrichter2007/grub-customizer
    • sudo apt-get update
    • sudo apt-get install grub-customizer 

Friday, May 25, 2012

Skype Data rates

Hi all,

according to https://support.skype.com/en-us/faq/FA1417/How-much-bandwidth-does-Skype-need
(1024kByte = 1MByte); (8kbps = 1kBps)

calling
--------
minimum:
30kbps = 30/8 kiloBytes (per second) = 225kiloBytes (per minute) = 0.22 MegaBytes per minute
if they charge both upload and download, then it would be 0.44 MegaBytes per minute

recommended:
100kbps = 100/8 kiloBytes (per second) = 750kiloBytes (per minute) = 0.73 MegaBytes per minute
if they charge both upload and download, then it would be 1.46 MegaBytes per minute
 
 
video calling
---------------
minimum:
128kbps = 128/8 kiloBytes (per second) = 960kiloBytes (per minute) = 0.9375 MegaBytes per minute
if they charge both upload and download, then it would be 1.875 MegaBytes per minute

recommended:
300kbps = 300/8 kiloBytes (per second) = 2250kiloBytes (per minute) = 2.2 MegaBytes per minute
if they charge both upload and download, then it would be 4.4 MBytes per minute
  • so if you assume minimum requirements and charge for only download it will be
    • calling->0.22MB per minute
    • video calling->0.9375MB per minute

cheers!

Wednesday, May 16, 2012

To highlight or edit a pdf file with pdf/a standard

Hi guys,

  • Sometimes you come across pdf files that are protected by the author. PDF/A is such a standard, which makes the document even not possible to higlight.
  • If you want to convert such a document to a normal pdf follow these steps.
    1. Get hold of a pdf creator: I use PrimoPDF; it is free (http://www.primopdf.com/)
    2. Open you protected pdf: you can use the free adobe reader X
    3. File->Print and choose the PrimoPDF as your printer
  • That's it! The resulting PDF can be edited.
Cheers!

Sunday, May 13, 2012

How to get rid of extra line spaces in LATEX: itemize, list, enumerate

Hi all,

Sometimes, the default line spacing in enumerate or itemize is too large.
This is how you can reduce it:
  1. Create your own command and use it instead of {itemize} or {enumerate}
\documentclass[letterpaper,11pt]{report}

\newenvironment{packed_enum}{
\begin{enumerate}
  \setlength{\itemsep}{1pt}
  \setlength{\parskip}{0pt}
  \setlength{\parsep}{0pt}
}{\end{enumerate}}

\newenvironment{packed_item}{
\begin{itemize}
  \setlength{\itemsep}{1pt}
  \setlength{\parskip}{0pt}
  \setlength{\parsep}{0pt}
}{\end{itemize}}


\newenvironment{compactlist}{
 \begin{list}{{$\bullet$}}{
  \setlength{\partopsep}{5pt}
  \setlength{\parskip}{0pt}
  \setlength{\parsep}{0pt}
  \setlength{\topsep}{0pt}
  \setlength{\itemsep}{0pt}
  \setlength{\itemindent}{0pt}
  \setlength{\leftmargin}{10pt}
 }
}{
 \end{list}
}

\begin{document}

\chapter{My List}

Here is my list.

\begin{packed_enum}
   \item Item 1
   \item Item 2
   \item Item 3
\end{packed_enum}

\begin{packed_item}
   \item Item 1
   \item Item 2
   \item Item 3
\end{packed_item}

\begin{compactlist}
\item Item 1
\item Item 2
\item Item 3
\end{compactlist}

\end{document}

--------------------------
By changing the size of {pt} in
\setlength{\itemindent}{0pt}
\setlength{\leftmargin}{10pt}
you can change the indent of the bullets.

Credit should go to the original post: http://www.devdaily.com/blog/post/latex/control-line-spacing-in-itemize-enumerate-tags