LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ''' from breezycreate2 import Robot import time # Create a Create2. This will automatically try to connect to your robot over serial bot = Robot() # Play a note to let us know you're alive! bot.playNote('A4', 100) # Tell the Create2 to turn right slowly bot.setTurnSpeed(-50) # Wait a second time.sleep(1) # Stop bot.setTurnSpeed(0) # Report bumper hits and wall proximity for 30 seconds start_time = time.time() while (time.time() - start_time) < 30: print('Bumpers: ' + str(bot.getBumpers()) + ' Wall: ' + str(bot.getWallSensor())) # Close the connection bot.close()
# bot.setTurnSpeed(x) # x = x-1 # time.sleep(0.01) #while (x < 50): # bot.setTurnSpeed(x) # x = x+1 # time.sleep(0.01) bot.setForwardSpeed(100) #bot.setTurnSpeed(0) time.sleep(10) #bot.setTurnSpeed(50) # Wait a second time.sleep(2) # Stop bot.setTurnSpeed(0) # Report bumper hits and wall proximity for 30 seconds start_time = time.time() while (time.time() - start_time) < 30: print('Bumpers: ' + str(bot.getBumpers()) + ' Wall: ' + str(bot.getWallSensor())) # Close the connection bot.close()
# Stop the robot bot.setTurnSpeed(0) # Report bumper hits and wall proximity for 30 sec #start_time = time.time() #while (time.time() - start_time) < 30: # print('Bumpers" ' + str(bot.getBumpers()) + ' Wall: ' + str(bot.getWallSensor())) clock = pygame.time.Clock() #Detect keypresses and hits while True: #Check for hit detections time.sleep(.75) bumpers = bot.getBumpers() print(str(bumpers)) if bumpers[0]: bot.setForwardSpeed(0) bot.setTurnSpeed(0) #playsound() bot.playNote('A4', 30) elif bumpers[1]: bot.setForwardSpeed(0) bot.setTurnSpeed(0) #playsound() bot.playNote('A4', 60) #configure walls later #handle keypresses handle_events()
from breezycreate2 import Robot import time # Create a Create2. This will automatically try to connect to your robot over serial bot = Robot() # Play a note to let us know you're alive! bot.playNote('A4', 100) # Tell the Create2 to turn right slowly bot.setTurnSpeed(-50) # Wait a second time.sleep(1) # Stop bot.setTurnSpeed(0) # Report bumper hits and wall proximity for 30 seconds start_time = time.time() while (time.time() - start_time) < 30: print('Bumpers: ' + str(bot.getBumpers()) + ' Wall: ' + str(bot.getWallSensor())) # Close the connection bot.close()