For reasons beyond me occasionally, one source overrides another. To ensure this does not happen the extend needs to be appended to the sourcing in the bashrc
source /opt/ros/indigo/setup.bash
source ~/catkin_ws_n/devel/setup.sh --extend
Typically I alias two commands in ~/.bashrc, which allows me to extend a workspace or overwrite the previous one
alias sss='source ./devel/setup.bash'
alias sssx=’source ./devel/setup.bash –extend’
</code>
grep -r "search term" ./
ps -A | grep "process"
grep -r --include=\*.m 'rospublisher' ./
find ./ -type f -exec sed -i -e 's/old_name/new_name/g' {} \;
find ./ -iname "laser_manager*" | rename -v "s/laser_manager/laser_sensor_set/g"
find . -name "*~" -exec rm {} \;
wc #Hit Enter The quick brown fox jumped over the lazy dog #Copy all text you need to count then hit ctrl+d 0 9 44 # Voila
for f in *.m; do echo $f ; grep -r ${f:0:(-2)} ./ ; echo " ============== " ; done
for value in {1..5} do roslaunch package1 monitor.launch config:=config1 & rosrun package2 package_node test:=$value & wait done
scp -r username@ip:/path/to/folder/on/remote/pc /path/to/folder/on/local/pc
sudo arp-scan --interface=eth0 --localnet
jekyll --server
compiz --replace
std::vector a,b;
</code>
a.insert(a.end(), b.begin(), b.end());
Multipling each element by an external scalar by using a lambda function
double scalar;
std::for_each(a.begin(),b.end(), [scalar](double& n){n*=scalar;});
Finding the difference between two vectors and storing in a third vector
ev.clear();
std::transform(qdot_ref.begin(),qdot_ref.end(),qdot.begin(),std::back_inserter(ev),std::minus());
</code>
5. Latex IEEE
Sometimes when checking for IEEE pdf compliant I get this wierd error: Type 3 font is a font that is not Type 1. This is due to using embedded fonts in an image, for instance using latex in inkscape. The easiest way I've found to resolve this issue is to convert eps to pdf before latex compliation, as follows:
convert image.eps image.pdf
Then we can check everything is ok by running this command
pdffonts image-eps-converted-to.pdf
6. Using prime numbers for state machines
Often I have to create state machines for simple robot actions. Typically these are high level commands passed by an enum. For instance:
enum ACTION { LIFT_LEFT_HAND, LOOK_AROUND, LIFT_RIGHT_HAND, GRASP, RELEASE, TURN_OFF_LED,TURN_ON_LED} ;
switch my_action
{
case LIFT_LEFT_HAND:
liftLeftHand();
break;
case LOOK_AROUND:
lookAround();
break;
case LIFT_LEFT_HAND_LOOK_AROUND:
liftLeftHand();
lookAround();
}
This type of structure means all actions can be stored in one function. The problem is it tends to balloon when composite actions are possible, for example, TURN_ON_CAMERAS and LEDS and LOOK_AROUND. Instead of creating an case for each composite action what I think is a nice solution is using primes for enums. In doing we can combine as many actions as desired.
enum ACTION { LIFT_LEFT_HAND=2, LOOK_AROUND=3, LIFT_RIGHT_HAND=5, GRASP=7, RELEASE=11, TURN_OFF_LED=13,TURN_ON_LED=17} ;
if (my_action%LIFT_LEFT_HAND==0)
liftLeftHand();
if (my_action%LOOK_AROUND==0)
lookAround();