Wednesday, 24 August 2016

[ROS Issues] Problems during installing sound_play package on an Odroid XU4

I am going to add some sound play and recognition function on my mobile robot. All good (Ok currently only sound synthesis) on my SONY VAIO laptop, Ubuntu 14.04 with Indigo. Alsamixer shows it is a HDA Intel PCH card...
Though I need to run 

rosdep install --from-paths /path/to/my/sound_play --ignore-src
to install some missing dependent libs to make the package compiled successfully.

However, on the Odroid XU4, ubuntu 14.04 with indigo, I connect a Logitech Z205 usb speaker, there is no compilation problems on my system, but cannot be executed, it says festival is not installed so I try rosdep again.

rosdep install --from-paths /path/to/my/sound_play --ignore-src -r
After that festival will be installed but still some dep errors.

ERROR: the following packages/stacks could not have their rosdep keys resolved
to system dependencies:
sound_play: Cannot locate rosdep definition for [gir1.2-gst-plugins-base-1.0]

Never mind, try

roslaunch sound_play test.launch 
will see some warning

[WARN] [WallTime: 1472029411.178135] Inbound TCP/IP connection failed: connection from sender terminated before handshake header received. 0 bytes were received. Please check sender for additional details.

However this should not be the problem why it is silent. Check 
alsamixer, my device is odroid-audio, try to change it to logitech. 

On the sound_play wiki trouble shooting page or configuring page

asoundconf set-default-card [device #]
but asoundconf not found ... Ok, try to install this cmd.. until I found this 


One guy is trying to add sound_play to his robot using ros... Wonderful, 
I did not try to understand the command line by line, but the most important part for me (changed from the original post according to my own conf)

$ pacmd list-sources | grep -e device.string -e 'name:'
name: <alsa_output.platform-sound.12.analog-stereo.monitor>
device.string = "0"
name: <alsa_output.usb-Logitech_Logitech_Z205-00-Z205.analog-stereo.monitor>
device.string = "1"

$ pacmd set-default-source alsa_output.usb-Logitech_Logitech_Z205-00-Z205.analog-stereo.monitor 
Welcome to PulseAudio! Use "help" for usage information.

$ pacmd list-sink | grep -e 'name:' -e 'index'
odroid@odroid:/etc$ pacmd set-default-sink alsa_output.
alsa_output.platform-sound.12.analog-stereo
alsa_output.usb-Logitech_Logitech_Z205-00-Z205.analog-stereo

$ pacmd set-default-sink alsa_output.usb-Logitech_Logitech_Z205-00-Z205.analog-stereo 
Welcome to PulseAudio! Use "help" for usage information.

Try again !

roslaunch sound_play test.launch 
"Beep, Beep!" Very loud. 

If we try 

roslaunch sound_play soundplay_node.launch
rosrun sound_play test
Then we can hear "Hello world"!

-----

when there is a sound file (.wav) cannot be completed?

To be resolved..

Tuesday, 12 July 2016

Install Dual Boot System (Windows10 and Ubuntu14.04) on a SONY VAIO laptop

If you are looking for a general guidance for dual boot system installation, checkout this
http://www.everydaylinuxuser.com/2014/05/install-ubuntu-1404-alongside-windows.html

I cannot remember how many times I have been installing ubuntu on a windows PC to realize a dual boot system for ROS. However, seems every time I would encounter some silly frustrated problems. Pity that I did not write down all the details how I solved the problem previously, now I wish to keep this post in very detail when there are problems in installing ubuntu and ROS. This post should be actively maintained.


Install Ubuntu 14.04 on a Pre-installed Windows 10 PC 


2016 Jul 12
I want to install ubuntu14.04 on a SONY VAIO laptop T series with NVidia graphic card. The OS is Win10 upgraded from win8.1, all the partitions for recovery or backup are never modified.

Normally just follow some common tutorials and the system can be boot to ubuntu grub menu. However this time I have no luck.

As usual, I have downloaded a Ubuntu 14.04 ISO file from the official website, created a bootable usb thumb drive, emptied one of the partition, and boot from USB device. FIRST ISSUE - Ok, for my laptop, DEL or any Funtion keys won't take me into BIOS setup... Simply press ASSIST during power off instead of press the power key, you will have an option to access bios setup. EVERY laptop is different, find your own way to do that.

Installing ubuntu...

However after restart, the familiar grub does not appear. The system directly enter Windows 10. Tried many ways but no use. Changed to boot from legacy mode and OPERATING SYSTEM NOT FOUND! Sure no operating system found because both of my OS are installed in UEFI mode.

EasyBCD 2.2 does not work, I can add a new entry and see the NeoSmart Ubuntu option when UEFI boot up but it cannot enter ubuntu, giving some bcd errors.

I cannot remember if I tried the command below but I definitely tried many ways from all the popular posts I googled. This may fix the problem, to be verified...
bcdedit /set {bootmgr} path \EFI\ubuntu\grubx64.efi

So I made a quick decision, reinstall ubuntu, in LEGACY BIOS, and it works, now I can simply choose my OS through change the bios settings. UEFI to win10 and legacy to Ubuntu. Next will try change legacy mode ubuntu to UEFI, will post here if works.

One more thing, EasyBCD 2.2 ruined my windows boot system after I tried many combinations(add and delete entries, finally crashed). Not sure if version 2.3 works well, but it seems safer because it disabled many settings. Repair the bcd using a newly created win10 bootup usb device.
Here is the error code and solution.
error code: 0xc0000098 Missing file: /bcd
solution from this post.
http://answers.microsoft.com/en-us/windows/forum/windows8_1-update/error-code-0xc0000098-missing-file-bcd/a5e0d28d-1e25-4ebd-836a-eb8656f41579?auth=1

key steps, enter prompt shell and repair bcd using the command lines:

BOOTREC /SCANOS
BOOTREC /FIXMBR
BOOTREC /FIXBOOT
BOOTREC /REBUILDBCD


---------
UEFI and Legacy BIOS
I was aware that UEFI is a newer version of firmware, but I did not pay attention to the difference of UEFI and traditional BIOS. Many mistakes are due to the lack of knowledge of UEFI. checkout this link:
http://askubuntu.com/questions/221835/installing-ubuntu-on-a-pre-installed-windows-10-with-uefi
You will find it useful if you encountered pitfalls during make dual boot system.

Future work

Next, will be install ubuntu 16.04 on a win10 pc, should be much easier according to the post above.

And, install ubuntu on all kinds of embedded systems, smartphones, etc.

Friday, 25 October 2013

Let's integrate pcl17 with ROS Fuerte. Using Point Cloud Libary to perform object recognition

We are going to add 3D object recognition to our robot so I have been trying to implement PCL 1.7 on ubuntu 12.04 these two weeks, where the ROS version is fuerte. As we know, even we only want to have a small function in ROS, we need to look into a lot of documents and it is a pity that there is very few step by step tutorial. I simply record what I have done for the past two weeks for my own reference and I hope it can help some one who want to do the same thing.

If you are using Groovy or Hydro, this article may not be helpful on some technical details. However, the pipeline should be the same.

I. PCL17 

Currently PCL is independent from ROS. And the original ros wiki http://wiki.ros.org/pcl  does not provide up-to-date info for PCL installation. We need to refer to wiki.ros.org/pcl17 and you can get basic ideas how to do that through reading the following two posts.

http://answers.ros.org/question/58409/problems-with-repository-pcl17/
http://answers.ros.org/question/44821/updating-to-pcl-17-in-ros-fuerte/

For me, I have downloaded pcl17, but for pcl_ros I am using the original one with fuerte. The package pcl_ros provides functions to convert different data types between PCL and ROS and transformation for point cloud.

It takes quite a looooooong time to compile pcl17. Over 3000s on my Thinkpad T410. So please be patient or just AFK..

II. pcl/Tutorial

Though the compilation of the pcl17 itself is not a problem, it is not that straight forward to include PCL in your own ROS code. Firstly, we try to go through the pcl/Tutorial.  This is a very important tutorial and you should read the whole page line by line and try not to miss a single word!

http://wiki.ros.org/pcl/Tutorials

This section is just following and explaining the ros tutorial,  solving the problems during compilation.

1.Code skeleton

I am not familiar with catkin so that I am using rosbuild. Because in this version of PCL, the used namespace is pcl17. That means we need to change all the pcl:: to pcl17::, and use #include<pcl17/***> instead of #include<pcl/***>. Also, remember to change the manifest.xml

<depend package="pcl17"/>

I stick to the dependency on pcl_ros package because I am not using pcl17_ros.

<depend package="pcl_ros"/> 

You should be able to compile the example.cpp successfully. 

2.sensor_msgs/PointCloud2

Proceed on to ros pcl tutorial section 4.1, simply add the 5 lines of codes into function cloud_cb(), pcl::VoxelGrid . Now you have a function which can down sample the point cloud.

rosrun my_pcl_tutorial example input:= <PointCloud2>
 
The input must be a PointCloud2 type. If you have an RGB-D device and openni installed, you can try

/camera/depth/points
/camera/depth_registered/points 

The results can be visualized in rviz.
But, if you do not have an RGB-D device at present? You can download some .pcd file, the extension means point cloud document.  For example

http://svn.pointclouds.org/data/tutorials/correspondence_grouping/milk_cartoon_all_small_clorox.pcd

After you have the .pcd file, we can use the function in pcl_ros to publish a point cloud. Refer to http://wiki.ros.org/pcl_ros 4.4.3 Usage. For example

rosrun pcl_ros pcd_to_pointcloud milk_cartoon_all_small_clorox.pcd 0.5

So the pcd_to_pointcloud function can read the .pcd file and publish it as point cloud every o.5 sec. The topic is

/cloud_pcd

Finally, using

rosrun my_pcl_tutorial example input:=/cloud_pcd

Now we can see some results in rviz.

3. pcl/PointCloud<T>

I did not really compile and execute this tutorial.  But the data type conversion mentioned here is very important. The cloud using in ROS is sensor_msgs::PointCloud2, but in PCL it is pcl17::PointCloud. We need to perform conversions when needed. The functions are fromROSMsg and toROSMsg, can be checked in

http://docs.pointclouds.org/1.0.0/namespacepcl.html

Pay attention to the format whether your input argument is a pointer or not? We will give detailed examples in the next section.

III. Correspondence Grouping 

After trying out some examples, now we are going to integrate the object recognition with ROS. Please refer to the following link. Now let's try to realize the function in ROS.

http://pointclouds.org/documentation/tutorials/correspondence_grouping.php#correspondence-grouping

1. Code Modification

Read through the PCL tutorial, get familiar with the functions. As we already have the ROS skeleton for PCL, what we need to do is to embed the main() function into cloud_cb(). It is not necessary to have showHelp() and parseCommandLine(). We simply modify the parameters in the program. If you want use command line to control the parameters, ROS provides powerful tools to do that..

Similarly, change all the pcl:: to pcl17::. Pay attention to PCL_VISUALIZER_POINT_SIZE, this parameter in visualization:: class need to change to PCL17_VISUALIZER_POINT_SIZE.

To use the .pcd file provided by the tutorial, you can simply read the .pcd file, or using pcl_ros::fromROSMsg, take in the parameters are arguments for cloud_cb(). Here, we read the model from the file, and takes in the scene from ROS topic. In this way, it is easier to change the scene from .pcd file.

To read the .pcd file, we can use the loadPCDFile() provided by PCL. However, it seems that the loaded point cloud does not contain the transformation/reference information, we need to define it in either camera_link or base_link. Or else it cannot be shown in rviz because rviz cannot perform a transformation.
// The model is loaded from pcd file, the scene is directly obtained from the camera, rostopic, which is an input of the cloud_cb.
  std::string   model_path=ros::package::getPath("my_pcl_tutorial");
  model_path+="/pcd/milk.pcd";
  if (pcl17::io::loadPCDFile (model_path, *model) < 0)
  {
    std::cout << "Error loading model cloud." << std::endl;
    return;
  }

  model->header.frame_id= "camera_link";
  model->header.stamp = ros::Time::now ();


for the scene cloud
void cloud_cb (const sensor_msgs::PointCloud2ConstPtr& input)
{
  pcl17::fromROSMsg (*input, *scene);
}

 And we publish the rotated_model
  pcl17::toROSMsg(*rotated_model,cloud_filtered);
  pub.publish (cloud_filtered);


If you are still not clear how to modify the code, leave me a message with your email.

Finally, we are not going to use the visualization module. Because the visualization will spin itself and the call back function stops there...Instead, we need to publish the topic and visualize the results in rviz. So, we can comment out all the visualization:: class related code. The specific lines which need to be commented are listed below.

  //pcl17::visualization::PCLVisualizer viewer ("Correspondence Grouping");
  //viewer.addPointCloud (scene, "scene_cloud");


    //viewer.addPointCloud (off_scene_model, off_scene_model_color_handler, "off_scene_model");

    //viewer.addPointCloud (scene_keypoints, scene_keypoints_color_handler, "scene_keypoints");
    //viewer.setPointCloudRenderingProperties (pcl17::visualization::PCL17_VISUALIZER_POINT_SIZE, 5, "scene_keypoints");


    //viewer.addPointCloud (off_scene_model_keypoints, off_scene_model_keypoints_color_handler, "off_scene_model_keypoints");
    //viewer.setPointCloudRenderingProperties (pcl17::visualization::PCL17_VISUALIZER_POINT_SIZE, 5, "off_scene_model_keypoints");


    //viewer.addPointCloud (rotated_model, rotated_model_color_handler, ss_cloud.str ());

        //viewer.addLine<PointType, PointType> (model_point, scene_point, 0, 255, 0, ss_line.str ());

//  while (!viewer.wasStopped ())
//  {
//    viewer.spinOnce ();
//  }

2. Compilation 

The executable for our program is correspondence_grouping. Here several errors are listed. However, some errors may not be a problem if you have already changed your code according to my suggestion.

fatal error: vtkMatrix4x4.h: No such file or directory
Add in two lines into CMakelists.txt

include_directories(/usr/include/vtk-5.8)
target_link_libraries(correspondence_grouping ${PCL_LIBRARIES} libvtkCommon.so libvtkFiltering.so libvtkRendering.so)

Please refer to http://answers.ros.org/question/39444/pcl-visualizer-error/?answer=39744#post-id-39744


libboost error

/usr/bin/ld: note: 'boost::system::system_category()' is defined in DSO /usr/lib/libboost_system.so.1.46.1 so try adding it to the linker command line
  /usr/lib/libboost_system.so.1.46.1: could not read symbols: Invalid operation


You need to add in one line into CMakelist.txt

rosbuild_link_boost(correspondence_grouping system)

PCL_VISUALIZER_POINT_SIZE not declared in common.h
This is introduced in the previous section. Change it to PCL17_VISUALIZER_POINT_SIZE
Please refer to
http://www.pcl-users.org/Correspondence-Grouping-Tutorial-ROS-td4021994.html

3. Show results 

Hopefully you can compile you code successfully. 

First, publish the point cloud from a .pcd file. Pay attention to the file path

rosrun pcl_ros pcd_to_pointcloud pcd/milk_cartoon_all_small_clorox.pcd 0.2

So the reference for the cloud is by default /base_link.

rosrun my_pcl_tutorial correspondence_grouping input:=/cloud_pcd

And now we can have a look at the results in rviz.


Wednesday, 19 December 2012

How to successfully compile rgbdslam_freiburg package under ROS

This article was posted in Dec 2012. Later versions of rgbdslam package may differ from our post. I will try to make this post up-to-date and more detailed.

We have been working on rgbdslam package for more than one week to make it compile successfully. The answers in the ROS forum is plentiful, so at the same time it is hard to find out the exact one fits your problem. That is why I am going to compose this article. Since currently I cannot contribute to ROS wiki, and it is not proper to post a tutorial on answer.ros.org, just post a detailed procedure and the problems we encountered here, hope can be helpful for those who are working on the same thing.

Part.I Basic Settings. ROS installation


We are using Ubuntu 12.04 (Precision) and ROS fuerte, on 32 bit system.First you need to follow the instructions on http://www.ros.org/wiki/rgbdslam. If you are new to ROS, better spend at least one week time on the ROS basic things. Keeping in mind that every time downloading packages using svn, you need to enter the /ros_workspace (may differ according to your configuration, mine is /fuerte_workspace) first. Just type 'roscd' in terminal, it should bring you there.

If it brings you into the /opt/ros/fuerte/... something like that, means your ROS_PACKAGE_PATH is not set properly. It is a system environment variable, your can change it in setup.sh. In my case, I added

export ROS_PACKAGE_PATH=~/fuerte_workspace:$ROS_PACKAGE_PATH

to the file. If you still have problem, check .bashrc in your home folder. you can just type

gedit ~/.bashrc

and add 

source ~/fuerte_workspace/setup.bash

Appended on 15 March 2013

I should include this long time ago, about using the rosws command to perform the basic settings for packages and stacks in fuerte.

First, create the overlay and read through the rosws tutorial.
http://www.ros.org/wiki/fuerte/Installation/Overlays
http://mirror.umd.edu/roswiki/doc/independent/api/rosinstall/html/rosws_ros_tutorial.html


So check out the rgbdslam package using svn in the fuerte_workspace. 

svn co http://alufr-ros-pkg.googlecode.com/svn/trunk/rgbdslam_freiburg

Though it is possible to link the package with its source, I do not recommend you to do this. As we know ros is an actively maintained system and many packages are updating frequently. But for most of the users, we only aim for an stable version and do not want to make any change after we successfully integrate it with our own system.

Set rgbdslam_freiburg to a workspace, you should stay in your fuerte_workspace folder.

rosws set rgbdslam_freiburg 

Remember to restart your terminal or source the setup.sh. Try roscd rgbdslam, does it work?

Part.II Install all the dependencies


In fuerte and electric, the command to install all the dependencies are different. Though on wiki, the documentation is well distinguished, on the website answer.ros.org, some replies may be misled. We did not use any command other than provided by the wiki.

Remember to install QT first, it deals with GUI. Install it from Ubuntu software center. Install the QT Creator.

When running

rosdep update

rosdep install rgbdslam_freiburg


it may give you some error. If you are installing QT...then wait until finished. Ubuntu can only install one software at one time. If it says missing package rgbdslam, means you did not download the software in the correct path or your ROS_PACKAGE_PATH not set..go to PART. I...

Any other dependencies missing, you need to check manifest.xml. We simply explain the meaning of the scripts.

<depend package="g2o"/>

means you need to have a ros package, namely g2o, it will compile this package when you compiles the rgbdslam.

<rosdep name="libg2o">

means you need to install a library. So rosdep install rgbdslam_freiburg will install all the libraries.

Problem for eigen, you need to change package to library. When I downloaded the source, it had changed already. See this link http://answers.ros.org/question/38989/rgbdslam-with-ros-fuerte-installed/

A lot of rgbdslam users mentioned change g2o library to package. We explain this in detail in next part.

Part. III g2o, manifest.xml, CMakeLists.txt


Need to say that we spend several days working on these three files.. Following ROS wiki we cannot get it work.. We have read a lot of posts at first beginning, but we missed the useful info because we do not have an idea what problems we were facing.

I think currently most of the people have the same problems as us who failed to do a rosmake. It is because of g2o. If we are using <rosdep name="libg2o"> in the manifest.xml, there is an error"configuring incomplete" when rosmake rgbdslam using<depend package="g2o">, we get an error during compiling g2o package. Same error occurs if we compile g2o separately.

Three main problems we resolved to make the package work are as follows.

A. Follow http://ros.org/wiki/g2o, make sure that you can use roscd g2o to access the folder. Try to rosmake the package, it gives an certificate verification error...Due to the svn command. Actually the ros g2o package need to use svn to download code from openslam and compile it. Check this link http://answers.ros.org/question/50745/rgbdslam-error-trust-certificate-g2o-problem/


I think the author commented out the wrong line in the g2o makefile https://code.ros.org/svn/ros-pkg/stacks/vslam/trunk/g2o/Makefile, or maybe due to different configurations.


Change the corresponding local makefile to

SVN_CMDLINE = svn --no-auth-cache --trust-server-cert --non-interactive


#SVN_CMDLINE = svn --non-interactive --config-dir $(TOP_DIR)/svnconf

rosmake the g2o package again. It should work now. Takes quite a long time cos it needs to perform the svn task...

B. Modify the manifest.xml in rgbdslam package.

Change the g2o to package setting. Means change this line

<rosdep name="libg2o"> 

to

<depend package="g2o"/>


Not sure what is the problem with libg2o. One guy mentioned that you'd better remove the libg2o from software center during rosmake the rgbdslam to avoid conflicts.

C.Modify the CMakeLists.txt in rgbdslam

Remove the line

find_package(g2o REQUIRED)

And compile again. Because the removed line conflicts with the package g2o.
Useful info can be found in these two posts
http://answers.ros.org/question/46669/rgbdslam-on-electric-compiling-error/
http://answers.ros.org/question/46048/couldnt-find-executable-named-rgbdslam/
Seems electric and fuerte got same error..

Now it should be no problem to compile rgbdslam package. I hope this article can be useful for those who are still struggling with rgbdslam package compiling. Leave me a message if you think anything need to be improved.

Sunday, 11 November 2012

Open up of the blogger of a robotics researcher

I am a robotic generalist and neural cognitive robot specialist. I have been working on many aspects of robotics and currently my research focus is on robotic spatial cognition.


I have been doing research on robotics since 2007. This is an inpiring field and many thoughts all come in a sudden and then - GONE. Meanwhile we robotic researchers encounter the same problems again and again... And solve them again and again. I found a lot of useful information on the others experts' blogs or in some forums, it is great that they want to share.

That is why I open up my own blog. This is a totally technical blog about robotics, recording all the sparkles and problem tackles. Maybe, it will become my official personal page, who knows.

Update my research keywords from 2011 to 2013, the sample texts are from my recent research papers - interesting word cloud