MatLab crashing

Report crashes, strange behaviour, or apparent bugs
kleinash
Posts: 112
Joined: 28 Sep 2014, 09:58

MatLab crashing

Post by kleinash » 08 Dec 2014, 11:54

Hi,

I am having trouble with either MatLab or VREP or both crashing and having to restart.. Is there a way to check crash reports / log errors and send them through to you for analysis?

Regards
Last edited by kleinash on 27 Jan 2015, 13:39, edited 1 time in total.

kleinash
Posts: 112
Joined: 28 Sep 2014, 09:58

Re: MatLab crashing

Post by kleinash » 08 Dec 2014, 14:46

Hi,

There are a few issues - and I re-downloaded V-REP to make sure that I was on the latest version.

1. When V-REP starts it freezes a bit and I cannot move my mouse to past the top or bottom of the GUI
2. I then have to ALT+T to get to another screen, which seams to unfreeze V-REP
3. I head to my remote API MatLab set up and open the server communication
4. I run my program and it crashes MatLab (sometimes, but more often than not lately)
5. As my V-REP program has not completed I head over to the simulator and hit stop button
6. Re-start MatLab and server - if I get a successful run then MatLab provides me with the answers I need - but V-REP freezes and I have to hard shut down the gui (end task) - if it doesn't happen the first run it happens the second

Any thoughts?

Regards
Last edited by kleinash on 27 Jan 2015, 13:40, edited 1 time in total.

coppelia
Site Admin
Posts: 7272
Joined: 14 Dec 2012, 00:25

Re: MatLab and VREP crashing

Post by coppelia » 08 Dec 2014, 22:34

Hello Ashley,

on what platform are you? Are you using the remote API synchronous mode? Did the problem exist since long, or did it happen only recently (e.g. after you modified something)?

Cheers

kleinash
Posts: 112
Joined: 28 Sep 2014, 09:58

Re: MatLab and VREP crashing

Post by kleinash » 09 Dec 2014, 14:48

Hi,

I have two machines the one that has the problem is Windows 7, MatLab is 2013b

If I run exaclty the same code on my Linux machine I do not have the problem.. ie everything runs (a little slower because its a smaller machine - but it runs no problems). Ubuntu 12.04, MatLab 2012a

I think I am running synchronous, I have changed allot - but not with the connectivity and that doesnt explain why it would work on one machine and not the other.

Rgds

coppelia
Site Admin
Posts: 7272
Joined: 14 Dec 2012, 00:25

Re: MatLab and VREP crashing

Post by coppelia » 10 Dec 2014, 00:15

Can you check at what point Matlab crashes? I guess it crashes after a specific instruction.
Also, make sure to use the Matlab remote API components from the last V-REP release (i.e. it is not good to mix the remote API client components with a different version of V-REP).

Cheers

kleinash
Posts: 112
Joined: 28 Sep 2014, 09:58

Re: MatLab crashing

Post by kleinash » 27 Jan 2015, 09:46

Hi,

It crashes when I run this from the remote API:

Code: Select all

res = vrep.simxSetUIButtonProperty(h.id, h.UIhandle, 20, vrep.sim_buttonproperty_isdown, vrep.simx_opmode_oneshot);
I use this to close the barrett hand from within V-REP

I made sure these where correct:

remoteApiProto.m
remApi.m
remoteApi.dll

Was really hoping that was the issue.. but unfortunately it still crashes.. and it seams to crash on my Linux machine too now.


EDIT: I fixed it :) Instead of using the button property to close and open the hand, I set an integer signal for the child script to read. i.e.
MatLab:

Code: Select all

res = vrep.simxSetIntegerSignal(h.id , 'closing', 0, vrep.simx_opmode_oneshot )
Child script:

Code: Select all

closing=simSetIntegerSignal("closing", signalValue)
and to open again from MatLab:

Code: Select all

res = vrep.simxSetIntegerSignal(h.id , 'closing', 1, vrep.simx_opmode_oneshot )
EDIT2: but now I cant get it to open again.. Previously I set the button down and then reopened but just rolling the button up - but now I dont have that option.. and I cannot see an easy way of opening the hand again.

coppelia
Site Admin
Posts: 7272
Joined: 14 Dec 2012, 00:25

Re: MatLab crashing

Post by coppelia » 27 Jan 2015, 20:13

Ashley,

can you tell me what crashes (V-REP, Matlab, both?), or if the Matlab program is simply causing an error. In that case what error is output?

Cheers

kleinash
Posts: 112
Joined: 28 Sep 2014, 09:58

Re: MatLab crashing

Post by kleinash » 28 Jan 2015, 11:19

So this morning its all back to crashing again - even with the changes I made. And I cannot get the closing/opening signal to register..

first issue:

Only matlab crashes.

Second issue:

I use this to close the barrett hand:

Code: Select all

res = vrep.simxSetIntegerSignal(h.id , 'closing',1 , vrep.simx_opmode_oneshot );
and this to open it:

Code: Select all

res = vrep.simxSetIntegerSignal(h.id , 'closing', 0, vrep.simx_opmode_oneshot )
I run it once - it closes at the right time but does not open.
I then restart everything and its as if VREP remembers that it was closing and just carries on - even when I just run the simulation from within VREP.
I need it to start and not close - and then close when I tell it to and open when I tell it to.

I printed the signal from within VREP and it does flip - but at odd times - and then I changed the timing signals - but that too does not work..

My error is somewhere in this script - at least if I take this area out then it does not crash.. and if I run it a couple times it is able to clear the closing signal - then I add this in and it crashes and sets the closing signal in and outside VREP.

Code: Select all

 
%% ===== grasp object 
   % child script: closing=simGetIntegerSignal("closing")
   res = vrep.simxSetIntegerSignal(h.id , 'closing',1 , vrep.simx_opmode_oneshot );
   pause(3)
    
   %% ==== test grasp by removing box 
   grasp_measure = test_grasp(h, vrep, pos_relative, object_position);
      
   % if grasp was successful then read hand position postion
   if grasp_measure
        for i = 1:6
            [res, bhand_fingerJoints(i, 1:3)]= vrep.simxGetObjectPosition(h.id, h.fingerJoints(i), pos_relative, vrep.simx_opmode_buffer);
        end
        db_output.bhand_closed = bhand_fingerJoints;
        % replace box   
        vrep.simxSetObjectPosition(h.id , h.box, -1, box_pos, vrep.simx_opmode_oneshot);
        pause(2) 
        %% open hand again
        res = vrep.simxSetIntegerSignal(h.id , 'closing', 0, vrep.simx_opmode_oneshot )
        pause(2)
        % change spread position for hand and re-test grasp
        for spr = 0:200:1000
           spread = spr;
           db_output.spread = spread;
           res = vrep.simxSetUISlider(h.id, h.UIhandle, 21, spread, vrep.simx_opmode_oneshot);  
% close the hand and repeat 
           res = vrep.simxSetIntegerSignal(h.id , 'closing',1 , vrep.simx_opmode_oneshot )
           pause(1)
        end
        
   else
        %% stop the simulation if unsuccessful
        res = vrep.simxStopSimulation(h.id, vrep.simx_opmode_oneshot)
   end   

Eric
Posts: 186
Joined: 11 Feb 2013, 16:39

Re: MatLab crashing

Post by Eric » 28 Jan 2015, 12:36

Hi

Are you cleaning the signal v-rep side, after you received a signal different than nil?
something like:

Code: Select all

res=simGetIntegerSignal('closing')
if res~=nil then
  simClearIntegerSignal('closing')
  if res==1 then
     --closing code
  else
     --opening code
  end
end
cheers
Eric

ps: not sure why you use

Code: Select all

    closing=simSetIntegerSignal("closing", signalValue)
in you child script... maybe you are confused with simGetIntegerSignal?

kleinash
Posts: 112
Joined: 28 Sep 2014, 09:58

Re: MatLab crashing

Post by kleinash » 28 Jan 2015, 14:24

Here is the total script from the child:

Code: Select all

res=simGetIntegerSignal('closing')

	if (closing) then 
        print("closing is true")
	elseif not (closing) then
        print("closing is false")
	end

	if res~=nil then
		simClearIntegerSignal('closing')
		if res==1 then
		for i=1,3,1 do
		if (closing)and(needFullOpening[1]~=2)and(needFullOpening[2]~=2)and(needFullOpening[3]~=2) then
			if (firstPartLocked[i]) then
				simSetJointTargetVelocity(jointHandles[i][3],closingVel/3)
			else
				t=simJointGetForce(firstPartTorqueSensorHandles[i])
				if (t)and(t<-firstPartMaxTorque) then
					firstPartTorqueOvershootCount[i]=firstPartTorqueOvershootCount[i]+1
				else
					firstPartTorqueOvershootCount[i]=0
				end
				if (firstPartTorqueOvershootCount[i]>=firstPartTorqueOvershootCountRequired) then
					needFullOpening[i]=1
					firstPartLocked[i]=true
					-- First joint is now locked and holding the position:
					simSetObjectIntParameter(jointHandles[i][2],2001,1)
					simSetJointForce(jointHandles[i][2],closingOpeningTorque*100)
					simSetJointTargetPosition(jointHandles[i][2],simGetJointPosition(jointHandles[i][2]))
					-- second joint is now not in position control anymore:
					simSetObjectIntParameter(jointHandles[i][3],2001,0)
					simSetJointTargetVelocity(jointHandles[i][3],closingVel/3)
				else
					simSetJointTargetVelocity(jointHandles[i][2],closingVel)
					simSetJointTargetPosition(jointHandles[i][3],(45*math.pi/180)+simGetJointPosition(jointHandles[i][2])/3)
				end
			end
		else
			if (needFullOpening[i]==1) then
				needFullOpening[i]=2
			end
			simSetJointTargetVelocity(jointHandles[i][3],openingVel/3)
			if (firstPartLocked[i]) then
				jv=simGetJointPosition(jointHandles[i][3])
				if (jv<45.5*math.pi/180) then
					firstPartLocked[i]=false -- we unlock the first part
					simSetObjectIntParameter(jointHandles[i][2],2001,0)
					simSetJointForce(jointHandles[i][2],closingOpeningTorque)
					simSetJointTargetVelocity(jointHandles[i][2],openingVel)
				end
			else
				if (needFullOpening[i]~=0) then
					jv3=simGetJointPosition(jointHandles[i][3])
					jv2=simGetJointPosition(jointHandles[i][2])
					if (jv3<45.5*math.pi/180)and(jv2<0.5*math.pi/180) then
						needFullOpening[i]=0
						-- second joint is now again in position control:
						simSetObjectIntParameter(jointHandles[i][3],2001,1)
						simSetJointTargetPosition(jointHandles[i][3],(45*math.pi/180)+simGetJointPosition(jointHandles[i][2])/3)
					end
				else
					simSetJointTargetVelocity(jointHandles[i][2],openingVel)
					simSetJointTargetPosition(jointHandles[i][3],(45*math.pi/180)+simGetJointPosition(jointHandles[i][2])/3)
				end
			end
		end
	end
	
I just pasted where I think that code you put in should go..

I set closing by:

Code: Select all

  res = vrep.simxSetIntegerSignal(h.id , 'closing',1 , vrep.simx_opmode_oneshot );
and opening by:

Code: Select all

res = vrep.simxSetIntegerSignal(h.id , 'closing', 0, vrep.simx_opmode_oneshot )
I do say simGetIntegerSignal("closing") rather than the Set one - that was a previous mistake that I hadnt cleaned in the comments.

Your solution solved the closing issue - but I still can't get it to open..
I deleted the hand and reimported another one which seamed to help
and it hasnt crashed since I made this change - but I thought I had fixed that yesterday..

Post Reply