UnpicklingError in Matlab

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

UnpicklingError in Matlab

dberm22
This post was updated on .
I am using the following Matlab code to import my kinematicreachability data into matlab:

function [a] = loadpickle(filename)
    if ~exist(filename,'file')
        error('%s is not a file',filename);
    end
    outname = [tempname() '.mat'];
    pyscript = ['"import cPickle as pickle;import sys;import scipy.io;file=open(""' filename '"",""rb"");dat=pickle.load(file);file.close();scipy.io.savemat(""' outname '"",dat);"'];
    system(['python -c ' pyscript ]);
    a = load(outname);
end

Basically all it does is call python to open the *.pp file and save it to a *.mat, and then subsequently loads that *.mat file. However, I am getting an Unpickling Error:

Traceback (most recent call last): 
  File "<string>", line 1, in <module> 
cPickle.UnpicklingError: invalid load key, 'H'. 

Is the *.pp a normal pickle file, or is there a better way to get the data into matlab without running the whole process again?

Thanks

EDIT: It looks like the documentation says it is still a python pickle, but it is actually a hdf5 file. I can import it into Matlab using
h5read('filename','/PROPERTY')
 where PROPERTY is one of the following:

'reachabilitystats',  'reachabilitydensity3d',  'reachability3d',  'pointscale',  'xyzdelta',  'quatdelta'

still not quite sure what they mean or how to plot them, so hopefully I can get some more information on that, but at least I got over the first hurdle.
Reply | Threaded
Open this post in threaded view
|

Re: UnpicklingError in Matlab

dberm22
This post was updated on .
For all those who may want to do this in the future, use the following code to plot the manipulator workspace in Matlab:


output = h5read('Path To reachability.pp file','/reachabilitydensity3d');
output(output == 0) = NaN;
output_length=length(output);

close all;
h=figure();
res=1;
c=jet(1000); c(1,:)=[NaN NaN NaN];

slice(output,1:res:output_length,1:res:output_length,1:res:output_length);
colormap(c)
alpha(.1)
set(findobj(gca,'Type','Surface'),'EdgeColor','none')
view([85 -40]);

Reply | Threaded
Open this post in threaded view
|

Re: UnpicklingError in Matlab

Rosen Diankov
Administrator
Depending on whether your PC has the hdf5 library or not, openrave will use python pickle or hdf5.  hdf5 is 100x faster though ;0)


2013/9/28 dberm22 <[hidden email]>
For all those who may want to do this in the future, use the following code
to plot the manipulator workspace in Matlab:






--
View this message in context: http://openrave-users-list.185357.n3.nabble.com/UnpicklingError-in-Matlab-tp4026741p4026749.html
Sent from the OpenRAVE Users List mailing list archive at Nabble.com.

------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60133471&iu=/4140/ostg.clktrk
_______________________________________________
Openrave-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openrave-users


------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60133471&iu=/4140/ostg.clktrk
_______________________________________________
Openrave-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openrave-users