Friday, March 21, 2014

Downgrading ARDrone 2.0 firmware to 2.3.3

Preparation

Connect to the ardrone wifi and connect via telnet:
#Connect
telent 192.168.1.1

#Set a "false" old firmware version
echo 2.0.11 > /firmware/version.txt

#Set the new firmware version
echo 2.3.3 > /update/version.txt

Upload the firmware

Download the ARDrone 2.0 firmware version 2.3.3 from the internet and upload it to the drone. Use google to find it. The md5 check sum is: e779504b2fb362a1a727415290a9a914
ftp 192.168.1.1 5551
#Log in as anonymous

#Set the transfer type to binary
binary

#push the firmware file:
put ardrone2_update.plf

Verification

After uploading the firmware, we connect to check that it was correctly transferred and the version files are correct
telent 192.168.1.1

cat /firmware/version.txt
#Should output: 2.0.11

cat /update/version.txt
#Should output: 2.3.3

md5sum /update/ardrone2_update.plf
#Should output: e779504b2fb362a1a727415290a9a914  /update/ardrone2_update.plf

Finally reboot:
#in case you disconnected connect again:
telnet 192.168.1.1

#reboot:
reboot

Tuesday, March 18, 2014

Compile ROS' ardrone_autonomy on ARM:

This is page shows how to install the is the ROS driver to connect to the ARDrone, ardrone_autonomy.

Requirements

- ROS
- Ubuntu 13.04 (Raring Ringtail) 

Install dependencies

sudo apt-get install daemontools libsdl1.2-dev libxml2-dev libudev-dev libiw-dev

Compile and install

#Build env setup:
mkdir -p ~/ros/ardrone
cd ~/ros/ardrone

#Get the sources:
git clone https://github.com/AutonomyLab/ardrone_autonomy.git -b fuerte-devel

Source modifications to compile on ARM architecture

#ARM patch:
wget https://gist.githubusercontent.com/mtourne/7258641/raw/b86f252bc0a3b0027a2bd2f9f6c2912914921f5d/ardrone_autonomy_armv7.patch

cd ~/ros/ardrone/ardrone_autonomy
patch -p1 < ../ardrone_autonomy_armv7.patch
rm ../ardrone_autonomy_armv7.patch

Edit ~/ros/ardrone_autonomy/CMakeLists.txt, to have swscale before avcodec avutil in the link libraries:

Replace:
target_link_libraries(ardrone_driver pc_ardrone avcodec avutil swscale vlib  sdk SDL )
with:
target_link_libraries(ardrone_driver pc_ardrone swscale avcodec avutil vlib  sdk SDL )

Add to ROS and compile:
#Add to ROS
rosstack profile && rospack profile

# Update ROS_PACKAGE_PATH for this session
export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:~/ros/ardrone

# Update ROS_PACKAGE_PATH for every session
echo -e '\n\n#ardrone_autonomy ROS path:\nexport ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:~/ros/ardrone/ardrone_autonomy' >> ~/.bashrc 

#Compile
cd ~/ros/ardrone/ardrone_autonomy
./build_sdk.sh && rosmake ardrone_autonomy

References

Install ethzasl_ptam to ROS

Installing additional libraries

#OpenGL and linear algebra library:  
sudo apt-get install freeglut3-dev libatlas-base-dev  

Install ETHZASL_PTAM

# create and enter stack directory:  
mkdir ~/ros  
cd ~/ros  
   
# Fetch ethzasl_ptam stack  
git clone git://github.com/ethz-asl/ethzasl_ptam.git ethzasl_ptam  
   
# Update ROS_PACKAGE_PATH for this session
export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:~/ros/ethzasl_ptam

# Update ROS_PACKAGE_PATH for every session
echo -e '\n\n#ethzasl_ptam ROS path:\nexport ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:~/ros/ethzasl_ptam' >> ~/.bashrc 
   
# Install system dependencies (in case some still is missing)  
rosdep install ptam  
   
# build  
rosmake ethzasl_ptam  

Using ETHZASL_PTAM with ARDrone2

Modify the image details in cameracalibrator.launch as such:
...
        <remap from="image" to="/ardrone/front/image_raw" />   
...
Edit command:
nano ~/ros/ethzasl_ptam/ptam/launch/cameracalibrator.launch  


For ptam.launch:
...
        <remap from="image" to="$(optenv IMAGE /ardrone/front/image_mono)" />  
...
Edit command:
 nano ~/ros/ethzasl_ptam/ptam/launch/ptam.launch  

Calibrating the ARDrone2 camera

Print ~/ros/ethzasl_ptam/ptam/calib_pattern.pdf. It is a chessboard used to estimate the focal length of the camera.
Now start ROS and launch the calibrator:
#In one console start ROS:
roscore
#in another console
roslaunch ptam cameracalibrator.launch  
Now "grab" around 10 frames, then press "optimize" and "save".

Saving calibration values

Using the output values of the cameracalibrator, update PtamFixParams.yaml:
#edit the image size and Camera   
nano ~/ros/ethzasl_ptam/ptam/PtamFixParams.yaml  

As such:
#ARDrone2 default camera resolution:  
ImageSizeX: 640  
ImageSizeY: 360  
   
...  
...  
   
#ARDrone2 camera intrinsic calibration values  
Cam_fx: first value (normalized focal length in x)  
Cam_fy: second value (normalized focal length in y)  
Cam_cx: third value (normalized camera center in x)  
Cam_cy: fourth value (normalized camera center in y)  
Cam_s: fifth value (normalized distortion factor, <1 for wide FoV)  

Running it

Locally:

#start ROS in one console  
roscore  
   
#Start the ARDrone2 streaming (publishes the image/camera topics). In another console:  
rosrun ardrone_autonomy ardrone_driver _realtime_navdata:=True _navdata_demo:=0  
   
#Use image_proc to convert to grayscale. In another console:  
ROS_NAMESPACE=/ardrone/front rosrun image_proc image_proc  
   
#Launch ETHZASL_PTAM in another console:  
roslaunch ptam ptam.launch  

Remotely:

Edit PtamFixParams.yaml to not run the GUI:
Gui: False

Next, start ptam and on the same machine or a different one that has the correct ROS_MASTER_URI, run:
#image stream  
rosrun ptam remote_ptam  
   
#3D cloud stream  
rosrun ptam ptam_visualizer

References


Monday, March 17, 2014

Installing minimalistic ROS for use with ETHZASL-PTAM

Requirements:

- Ubuntu 13.04 (Raring Ringtail)
- X86/X86_64 architecture machine

APT related stuff

#Add the sources:  
sudo sh -c 'echo "deb http://packages.namniart.com/repos/ros raring main" > /etc/apt/sources.list.d/ros-latest.list'  
#Add the sources public key:  
wget http://packages.namniart.com/repos/namniart.key -O - | sudo apt-key add -
#Update the packages list:  
sudo apt-get update  
#Install ROS (and the ROS dependences required for PTAM):  
sudo apt-get install ros-hydro-ros-base ros-hydro-geometry ros-hydro-image-transport ros-hydro-visualization-msgs ros-hydro-dynamic-reconfigure ros-hydro-cv-bridge ros-hydro-rqt-gui ros-hydro-rqt-gui-cpp ros-hydro-image-view ros-hydro-ardrone-autonomy ros-hydro-camera-calibration ros-hydro-image-proc ros-hydro-gscam ros-hydro-rviz python-rosinstall python-rosdep python-imaging 

Environment setup

#setup environment for current session:  
source /opt/ros/hydro/setup.bash  
#setup environment for the following sessions   
echo "source /opt/ros/hydro/setup.bash" >> ~/.bashrc  

Initialize rosdep

sudo rosdep init  
rosdep update  

References: