Useful ROS commands
1.- Workspace:
Create and build and empty workspace:
For the examples the workspace is called “catkin_ws”:Create a package:
Go to the source directory of the workspace: cd ~/catkin_ws/src
then create a package catkin_create_pkg [depend1] [depend2] [depend3]
catkin_create_pkg requires that you give it a package_name and optionally a list of dependencies on which that package depends.Example:
catkin_create_pkg turtlebot_controller turtlesim geometry_msgs std_msgs roscpp rospy
The name of the package is "turtlebot_controller" and the dependences are "turtlesim", "geometry_msgs", "std_msgs", "roscpp" and "rospy"
Build the packages in the catkin workspace:
cd ~/catkin_ws
catkin_make
To add the workspace to the ROS environment :
. ~/catkin_ws/devel/setup.bash
2.- Running and see states:
Start using ROS:
roscore
this command is the first thing you should run when using ROS.Run a node of a package:
rosrun [package_name] [node_name]
Displays ROS nodes that are currently running:
rosnode list
/rosout is always presentDisplay more information about a node currently running:
rosnode info [node]
Example: rosnode info /rosout
Displays ROS topics that are currently present:
rostopic list
See the actual messages that are being published on a topic:
rostopic echo [topic]
Get information about ROS topics:
rostopic type [topic]
It will be updated with more commands ...
Create a simple graph in Python and Matlab
Python examples:
With arange (use the form start,end,step):
arange documentation:http://docs.scipy.org/doc/numpy/reference/generated/numpy.arange.html#numpy.arange
With linespace
linespace documentation:http://docs.scipy.org/doc/numpy/reference/generated/numpy.linspace.html
Matlab examples:
Creating a vector of values (form start:step:end)
With linespace
Install Python + OpenCV in Mac OS X Yosemite
1.- Install the prerequisite software:
1.1.- Install MacPorts from:
1.2.- Install Xcode from apple store. Once installed, open Xcode and accept the licence agreement (In this tutorial Xcode 6.4 was used).
1.3.- Install the "Command Line Tools". For this go to the terminal (Applications > Utilities > Terminal) and write:
sudo xcode-select --install
A windows is shown, you need to select "install" and wait until installation is finished.
1.4 Once Command Line Tools are installed, see the xcode instalation path with:
sudo xcode-select -p
In my case this command print:
/Applications/Xcode.app/Contents/Developer
1.5 Then, run the next command:
sudo xcode-select -switch <xcode path>
Where in my case is:
sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
1.6.- Go to the terminal and update the package index with:
sudo port -v selfupdate
and
sudo port upgrade outdated
and
sudo port upgrade outdated
2.- Install Python and basic packages:
2.1 Install Python with: sudo port install python27
2.2 Select the version of python as:
sudo port select --set python python27
2.3 Install the basic packages of scientific computing (matplotlib and numpy are required for use OpenCV).
sudo port install py27-numpy py27-matplotlib py27-scipy
3.- Install OpenCV
3.1 Install OpenCV with support for Python with:
sudo port install opencv +python27
3.2 To verify that the installation is correct, write in the terminal:
python
The, in the python terminal and write:
import cv2
If no error is shown then the installation was successful.
Note: I'm sorry for my poor grammar!
Cambiar directorio o ruta de la terminal de Python
Para ello se debe escribir en la terminal de python:
import os
Si se desea conocer el directorio actual de trabajo escribir:
os.getcwd()
Para cambiar de directorio simplemente hay que usar la función os.chdir y especificar la ruta del nuevo directorio, por ejemplo en el escritorio en Windows:
os.chdir('C:\\Users\\username\\Desktop')
Donde username es el nombre de usuario.
Agregar código a una entrada en Wordpress.com
Para agregar código con un formato agradable y numerado como:
Simplemente hay que entrar en el modo texto y agregar:
Donde se puede se puede sustituir "python" otro lenguaje de programación soportado. Un ejemplo se muestra en la siguiente imagen.
Para mayor información y ver los lenguajes soportados visitar: https://en.support.wordpress.com/code/posting-source-code/
Simplemente hay que entrar en el modo texto y agregar:
Donde se puede se puede sustituir "python" otro lenguaje de programación soportado. Un ejemplo se muestra en la siguiente imagen.
Para mayor información y ver los lenguajes soportados visitar: https://en.support.wordpress.com/code/posting-source-code/