Exemple #1
0
 def nav_working(self, left_speed, right_speed, run_duration=5):
     run_start_time = time.time()
     while((time.time() - run_start_time) <= run_duration):
         while(get_dist('fc') > 5):
             self.move(left_speed, right_speed)
             print "navigating: all good.. "
         print "obstacle!"
         self.pause()
     self.stop()
     print "run time up!"
Exemple #2
0
 def nav2(self, left_speed=50, right_speed=50, duration=20):
 #nav takes into account obstacle avoidance while
 #def r3_nav(self, 100, 100, 30):
     print "nav2 start"
     self.move(left_speed, right_speed, duration)
     while(get_dist('fc') > 20):
         #time.sleep(.5)
         print "all good.. going fwd"
     print "something in the way"
     self.stop()
     print "nav2 stop"
Exemple #3
0
 def nav(self, left_speed, right_speed, run_duration=5):
     move_command = get_move_command(left_speed, right_speed)
     run_start_time = time.time()
     while((time.time() - run_start_time) <= run_duration):
         self.move(left_speed, right_speed)
         print "navigating: all good.. "
         if(get_dist('fc') < 5 and (('FWD' in move_command) or ('PIVOT' in move_command))):
             print "obstacle!"
             self.pause()
             self.nav(-80,-80,2)
             self.pivot(5)
     self.stop()
     print "run time up!"
Exemple #4
0
 def nav(self, left_speed, right_speed, run_duration=5):
     move_command = self.get_move_command(left_speed, right_speed)
     run_start_time = time.time()
     print "nav start: ",move_command
     while((time.time() - run_start_time) <= run_duration):
         self.move(left_speed, right_speed)
         #print "navigating: all good.. "
         if(get_dist('fc') < 12 and (('FWD' in move_command) or ('PIVOTX' in move_command))):
             print "obstacle during nav: ", move_command
             #self.pause()
             self.nav(-220,-220,.5)
             self.pivot('left',2)
     #self.pause()
     print "nav pause (time up): ",move_command
Exemple #5
0
 def nav_deprecated(self, left_speed=50, right_speed=50, duration=20):
 #nav takes into account obstacle avoidance while
 #def r3_nav(self, 100, 100, 30):
     i = 0
     print "nav start"
     print 'move steps: ',(duration )
     for i in range(0, (duration)):
         while(get_dist('fc') > 20):
              self.move(left_speed, right_speed, 1)
              #print "move call from nav"
              i = i + 1
              #print "i is:",i
              #print "dist: ",get_dist('fc')
     self.stop()
     print "nav stop"
Exemple #6
0
    def nav(self, left_speed=50, right_speed=50, run_duration=2):

        run_start_time = time.time()
        current_time = time.time()
        print "run stats:"
        print run_duration
        print run_start_time
        print current_time
        while((current_time - run_start_time) <= run_duration):
            while(get_dist('fc') > 15):
                self.move(left_speed, right_speed)
                print "all good.. keep it movin' "
            self.pause()
            print "obstacle, waiting!"
            current_time = time.time()
        self.stop()
        print "time up! stopping"
Exemple #7
0
    def _left_speedxx(self, speed):
        """Set the speed of the left motor, taking into account its trim offset.
        """
        #assert 0 <= speed <= 255, 'Speed must be a value between 0 to 255 inclusive!'
        assert -255 <= speed <= 255, 'Speed must be a value between 0 to 255 inclusive!'
        speed += self._left_trim
        #speed = max(0, min(255, speed))  # Constrain speed to 0-255 after trimming.
        speed = max(-255, min(255, speed))  # Constrain speed to 0-255 after trimming.
        self._left_front.setSpeed(abs(speed))
        self._left_rear.setSpeed(abs(speed))

    def _right_speedxx(self, speed):
        """Set the speed of the right motor, taking into account its trim offset.
        """
        assert 0 <= speed <= 255, 'Speed must be a value between 0 to 255 inclusive!'
        speed += self._right_trim
        speed = max(0, min(255, speed))  # Constrain speed to 0-255 after trimming.
        self._right_front.setSpeed(speed)
        self._right_rear.setSpeed(speed)

    def nav-working(self, left_speed, right_speed, run_duration=5):
        run_start_time = time.time()
        while((time.time() - run_start_time) <= run_duration):
            while(get_dist('fc') > 5):
                self.move(left_speed, right_speed)
                print "navigating: all good.. "
            print "obstacle!"
            self.pause()
        self.stop()
        print "run time up!"
Exemple #8
0
import time
import r3c
from r3s import get_dist, get_sensorpin

print "test start, initializing chasis and sensors"
r = r3c.r3c()  #initialize chassis

print "@@@@@@@@@@ sensor readings start"
for x in range(0, 90):
    print "Reading #: ", x
    '''    get_dist('fl')
    time.sleep(1)
    get_dist('fc')
    time.sleep(1)
    get_dist('fr')
    time.sleep(1)'''
    get_dist('fc')
    print "\n\n"

print "@@@@@@@@@@ sensor readings end"