task 1 and 2 - how to access data




This forum is dedicated to questions regarding Challenge 3

task 1 and 2 - how to access data

Postby fog » Wed 3. Sep 2014, 09:18

Hi,
our team is actually almost totally new to ROS. So this question is rather a practical one.

I've read all the instructions at least twice, so if I missed something I'm sorry in advance.

The problem is simple - I don't know how to access the data given by simserv from the callback function.
The sample code is:
// ------------ Compute pose here ------------------
// ## Grab image and imu data and compute pose.
//req.vi_data.image[0];
// req.vi_data.image[1];
// req.vi_data.imu[0 ... n];

We want to work with the images in OpenCV. So I've used this tutorial to get the image.
http://wiki.ros.org/cv_bridge/Tutorials ... enCVImages

In every fifth serviceCallback() function I call
imageCb(( sensor_msgs::ImageConstPtr& ) req.vi_data.image[0]);

The ROS task crashes on this:
try
{
printf ( "B_here1\n" );
cv_ptr = cv_bridge::toCvCopy ( msg, sensor_msgs::image_encodings::BGR8 );
printf ( "B_here2\n" );
}
catch ( cv_bridge::Exception& e )
{
ROS_ERROR ( "cv_bridge exception: %s", e.what() );
return;
}

It doesn't get through toCvCopy.

The message I get in terminal is:

[euroc_solution_t1-1] process has died [pid 22178, exit code -11, cmd /home/simclient/catkin_ws/devel/lib/euroc_solution_t1/euroc_solution_t1 __name:=euroc_solution_t1 __log:=/home/simclient/.ros/log/76bdc194-29f7-11e4-9a92-08002749a783/euroc_solution_t1-1.log].
log file: /home/simclient/.ros/log/76bdc194-29f7-11e4-9a92-08002749a783/euroc_solution_t1-1*.log
all processes on machine have died, roslaunch will exit
shutting down processing monitor...
... shutting down processing monitor complete

The log file does not help at all. There's no ROS_ERROR ( "cv_bridge exception: %s", e.what() ); message in the terminal output, so I don't even know the origin of the crash.

So the first question is - how to get the simserv data into standard cvMat format and how to debug the ROS crash?

Second question is - in what data type format are the imu data stored? What exactly is imu[0] imu[1]... etc. How to access them?

Again, I haven't found any details on the imu data in the instruction documents. Perhaps there is a standard way to do so which is clear to people used to ROS?
Since we're not, it is not clear to us.
Please point us to the right direction. :)
fog
 
Posts: 2
Joined: Wed 3. Sep 2014, 08:50

by Advertising » Wed 3. Sep 2014, 09:18

Advertising
 

Re: task 1 and 2 - how to access data

Postby markusachtelik » Fri 5. Sep 2014, 10:40

Hi,

it looks like you are casting the data in the wrong way, and then it crashes even before it can throw the exception.
First, you can have a look here on how to modify launchfiles for debugging nodes in GDB:
http://wiki.ros.org/roslaunch/Tutorials/Roslaunch%20Nodes%20in%20Valgrind%20or%20GDB.

There are two command line tools to get information about topic / services:
http://wiki.ros.org/srv
http://wiki.ros.org/rosmsg

req.vi_data.image[0...n] is defined as an array of sensor_msgs/Image (in c++: sensor_msgs::Image), not as shared pointers to an image. You can also find information on this datatype here: http://docs.ros.org/api/sensor_msgs/html/msg/Image.html

You don't need to call the whole example function, this should do it:
Code: Select all
CvImagePtr cv_image;
cv_image = toCvCopy(req.vi_data.image[0]);

Just leave the string for the image encoding empty, and cv_bridge will figure out the right one.

For your second question, req.vi_data.imu is an array of IMU messages defined here: http://docs.ros.org/api/sensor_msgs/html/msg/Imu.html
the first element is the IMU measurement right after the images that were obtained in the last service call; the last element is the measurement that was taken at the same time as the current images.
E.g. to obtain the acceleration in z-direction at the time of the current images:
Code: Select all
double acc_z =req.vi_data.imu.back().linear_acceleration.z


I hope that helps!

Best, Markus
markusachtelik
 
Posts: 27
Joined: Mon 7. Jul 2014, 20:09


Return to Challenge 3

Who is online

No registered users

cron