SelectLaserPoints

PURPOSE ^

USAGE:

SYNOPSIS ^

function laserInd= SelectLaserPoints(angleVector,rangeVector)

DESCRIPTION ^

 USAGE:
   [laserRange,laserAngle] = SelectLaserPoints(laserRange,laserAngle)
   Displays a plot of the range data and prompts user to select
   a single region within.

 INPUTS:
     angleVector: 1xN vector; angleVector lists the angles for the ranges
     in rangeMatrix.
 
     rangeVector: 1xN vector; ranges of laser scan

 OUPUTS:
     laserInd: indices of the selected set.

 Written by James Underwood 10/07/06

 Modified by Abdallah Kassir 1/3/2010

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function laserInd= SelectLaserPoints(angleVector,rangeVector)
0002 % USAGE:
0003 %   [laserRange,laserAngle] = SelectLaserPoints(laserRange,laserAngle)
0004 %   Displays a plot of the range data and prompts user to select
0005 %   a single region within.
0006 %
0007 % INPUTS:
0008 %     angleVector: 1xN vector; angleVector lists the angles for the ranges
0009 %     in rangeMatrix.
0010 %
0011 %     rangeVector: 1xN vector; ranges of laser scan
0012 %
0013 % OUPUTS:
0014 %     laserInd: indices of the selected set.
0015 %
0016 % Written by James Underwood 10/07/06
0017 %
0018 % Modified by Abdallah Kassir 1/3/2010
0019 
0020 dispclstrscore(angleVector,rangeVector,ones(size(angleVector)));
0021 title('Select appropriate region in laser scan - bound 1');
0022 hold on;
0023 p=plot(0,0,'r');
0024 hold off;
0025 set(gcf, 'WindowButtonMotionFcn', {@linedispcallback,p});
0026 set(gcf,'Pointer','crosshair');
0027 % set(gcf, 'WindowButtonDownFcn', 'uiresume(gcbf)');
0028 % uiwait;
0029 b=waitforbuttonpress;
0030 if b~=0
0031     btnprsd=get(gcf,'CurrentCharacter');
0032     if btnprsd=='e'
0033         laserInd=0;
0034     else
0035         laserInd=[];
0036     end
0037     set(gcf, 'WindowButtonMotionFcn', '');
0038     return;
0039 end
0040 pt = get(gca, 'CurrentPoint');
0041 px(1)=pt(1,1);
0042 py(1)=pt(1,2);
0043 
0044 title('Select appropriate region in laser scan - bound 2');
0045 b=waitforbuttonpress;
0046 if b~=0
0047     btnprsd=get(gcf,'CurrentCharacter');
0048     if btnprsd=='e'
0049         laserInd=0;
0050     else
0051         laserInd=[];
0052     end
0053     set(gcf, 'WindowButtonMotionFcn', '');
0054     return;
0055 end
0056 pt = get(gca, 'CurrentPoint');
0057 px(2)=pt(1,1);
0058 py(2)=pt(1,2);
0059 
0060 % delete(T);
0061 ptheta=cart2pol(py,px);
0062 pthetamin=min(ptheta);
0063 pthetamax=max(ptheta);
0064 laserInd = angleVector>pthetamin & angleVector<pthetamax;
0065 % stop callback
0066 set(gcf, 'WindowButtonMotionFcn', '');
0067 
0068 function linedispcallback(src,event,p)
0069 
0070 % get mouse position
0071 pt = get(gca, 'CurrentPoint');
0072 x = pt(1, 1);
0073 y = pt(1, 2);
0074 
0075 % check if its within axes limits
0076 xLim = get(gca, 'XLim');    
0077 yLim = get(gca, 'YLim');
0078 if x < xLim(1)
0079     x=xLim(1);
0080 elseif x > xLim(2)
0081     x=xLim(2);
0082 end
0083 if y < yLim(1)
0084     y=yLim(1);
0085 elseif y>yLim(2)
0086     y=yLim(2);
0087 end
0088 set(p,'XData',[0,x],'YData',[0,y]);
0089 
0090 function getcoordscallback(src,event)
0091 % get mouse position
0092 pt = get(gca, 'CurrentPoint');
0093 x = pt(1, 1);
0094 y = pt(1, 2);
0095 
0096 % check if its within axes limits
0097 xLim = get(gca, 'XLim');    
0098 yLim = get(gca, 'YLim');
0099 if x < xLim(1)
0100     x=xLim(1);
0101 elseif x > xLim(2)
0102     x=xLim(2);
0103 end
0104 if y < yLim(1)
0105     y=yLim(1);
0106 elseif y>yLim(2)
0107     y=yLim(2);
0108 end
0109

Generated on Thu 08-Apr-2010 14:35:09 by m2html © 2005