Ejemplo n.º 1
0
	def lineDrawer(self,event,x,y,flags,param):
		if event == cv.CV_EVENT_LBUTTONDOWN:
			self.startPt = Geometry2D.Point(x,y)
		elif event == cv.CV_EVENT_LBUTTONUP:
			self.endPt = Geometry2D.Point(x,y)
			line = Geometry2D.DirectedLineSegment(self.startPt,self.endPt)
			self.addCVShape(CVDirectedLineSegment(cv.RGB(255,255,255),10,line,2))
		
		elif cv.CV_EVENT_FLAG_LBUTTON == flags-32:
			line = Geometry2D.DirectedLineSegment(self.startPt,Geometry2D.Point(x,y))
			self.addTempCVShape(CVDirectedLineSegment(cv.RGB(150,150,150),10,line,2))

		elif event == cv.CV_EVENT_RBUTTONDOWN:
			self.startPt = Geometry2D.Point(x,y)
		elif event == cv.CV_EVENT_RBUTTONUP:
			self.endPt = Geometry2D.Point(x,y)
			line = Geometry2D.DirectedLineSegment(self.startPt,self.endPt)
			self.addCVShape(CVDirectedLineSegment(cv.RGB(0,0,255),10,line,2))
		return
Ejemplo n.º 2
0
        self.count = self.count + 1
        return adjusted_foldline
        
    def adjustFoldline(self,intended):
        #intended.expand(10)
        start = self.convert_to_world_frame(intended.start())
        end = self.convert_to_world_frame(intended.end())
        try:
            srv = rospy.ServiceProxy('adjust_fold',AdjustFold)
            resp = srv(start,end)
        except rospy.ServiceException,e:
            rospy.loginfo("Service Call Failed: %s"%e)
            return False
        new_start = self.convert_from_world_frame(resp.start)
        new_end = self.convert_from_world_frame(resp.end)
        newfold = Geometry2D.DirectedLineSegment(new_start,new_end)
        newfold.expand(0.1)
        return newfold

    def send_traj(self,fold_traj):
        try:
            srv = rospy.ServiceProxy('execute_fold',ExecuteFold)
            resp = srv(ExecuteFoldRequest(fold_traj=fold_traj))
            return True
        except rospy.ServiceException,e:
            rospy.loginfo("Service Call Failed: %s"%e)
            return False
            
def main(args):
    rospy.init_node("poly_gui_bridge")
    pg = PolyGUIBridge()