예제 #1
0
    def __init__(self, node):
        self.node = node
        self.speed = 0
        self.target_speed = 0
        self.lateral_error = 0
        self.cmd = Control_Command()
        self.cmd.steer_angle = 0
        self.cmd.throttle = 0
        self.trajectory = Trajectory()
        self.sum_error_longi = 0
        self.node.create_reader("/chassis", Chassis, self.chassiscallback)
        self.node.create_reader("/control_reference", Control_Reference,
                                self.speedrefcallback)
        # /planning/trajectory\
        # /planning/control_trajectory
        self.node.create_reader("/perception/road_mean_point", Trajectory,
                                self.trajectorycallback)
        self.writer = self.node.create_writer("/control", Control_Command)

        signal.signal(signal.SIGINT, self.sigint_handler)
        signal.signal(signal.SIGHUP, self.sigint_handler)
        signal.signal(signal.SIGTERM, self.sigint_handler)
        self.is_sigint_up = False
        while True:
            time.sleep(0.05)
            self.lateral_controller(self.trajectory, self.lateral_error)
            self.longitude_controller(self.target_speed, self.speed)
            self.writer.write(self.cmd)
            if self.is_sigint_up:
                print("Exit")
                self.is_sigint_up = False
                return
예제 #2
0
    def __init__(self, node):
        self.node = node
        self.speed = 0
        self.target_speed = 0
        self.lateral_error = 0
        self.cmd = Control_Command()
        self.trajectory = Trajectory()
        self.node.create_reader("/chassis", Chassis, self.chassiscallback)
        self.node.create_reader("/control_reference", Control_Reference,
                                self.speedrefcallback)
        self.node.create_reader("/planning/dwa_trajectory", Trajectory,
                                self.trajectorycallback)
        self.writer = self.node.create_writer("/control", Control_Command)

        signal.signal(signal.SIGINT, self.sigint_handler)
        signal.signal(signal.SIGHUP, self.sigint_handler)
        signal.signal(signal.SIGTERM, self.sigint_handler)
        self.is_sigint_up = False
        while True:
            try:
                time.sleep(0.05)
                self.lateral_controller(self.trajectory, self.lateral_error)
                self.longitude_controller(self.target_speed, self.speed)
                self.writer.write(self.cmd)
                if self.is_sigint_up:
                    print("Exit")
                    self.is_sigint_up = False
                    return
            except Exception:
                break
예제 #3
0
 def __init__(self, node):
     self.msg = Control_Command()
     # create writer
     self.writer = node.create_writer(
         "/control", Control_Command)
     # keyboard event listen non blocking fashion
     listener= keyboard.Listener(on_press = self.onpress_w, 
                                 on_release = self.onrelease_w)
     listener.start()
     self.loop()
예제 #4
0
 def __init__(self, node):
     self.msg = Control_Command()
     # TODO 2 create writer
     self.writer = node.create_writer("/control", Control_Command)
     self.loop()