def threadfunc(values): # Connect to the Create2 bot = Robot() while True: # Convert [-1,+1] axis to [-500,+500] turn speed if abs(values[0]) > abs(values[1]): # Only turn bot.setTurnSpeed(500*values[0]) else: bot.setForwardSpeed(500*values[1]) # Yield to main thread sleep(.01)
all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 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()
('C4',11,0.3), ('C4',11,0.3), ('C4',32,0.7), ('G4',32,0.7), ('F4',11,0.3), ('E4',11,0.3), ('D4',11,0.3), ('C5',64,1.2), ('G4',40,0.7), ('F4',11,0.3), ('E4',11,0.3), ('D4',11,0.3), ('C5',64,1.2), ('G4',40,0.7), ('F4',11,0.3), ('E4',11,0.3), ('F4',11,0.3), ('D4',64,2) ] ''' # Create a Create2. This will automatically try to connect to your robot over serial bot = Robot() # Play the melody for triple in MELODY: bot.playNote(triple[0], triple[1]) time.sleep(triple[2]) # Close the connection bot.close()
speed2 = 15 runtime = 133.33 bot.robot.drive_straight(speed2) time.sleep(runtime) # Speed 100 = 0.1 m per second, 10 seconds to make 1 meter # does faster speed mean less accuracy? # stop after certain amount of time bot.robot.drive_straight(0) def move400(self): #double as fast, same time to get 2 times distance speed3 = 200 runtime2 = 20 bot.robot.drive_straight(speed3) time.sleep(runtime2) # stop after certain amount of time bot.robot.drive_straight(0) threads = [] if __name__ == '__main__': import sys, getopt #def main(): try: bot = Robot() movement = testMove() movement.move200() str('testgood') #return 0 except: str('test') #return 1
Threshold = 0.3 X = [ 0.73472, 1.92912, 3.1645, 4.38612, 0.71062, 1.94628, 3.16704, 4.38568, 0.7195, 1.91526, 3.17254, 4.39526, 0.6789, 1.89398, 3.1669, 4.38698 ] Y = [ -0.02102, -0.0125, 0.01, 0.0421, 1.1086, 1.18886, 1.20054, 1.21036, 2.41466, 2.45076, 2.38374, 2.40446, 3.62488, 3.66896, 3.572, 3.60554 ] plt.plot(X, Y, 'ro') i = 0 for x in range(0, len(X)): plt.annotate(i, xy=(X[x], Y[x])) i = i + 1 bot = Robot() hedge1 = MarvelmindHedge(tty="/dev/ttyACM0", adr=2, debug=False) hedge2 = MarvelmindHedge(tty="/dev/ttyACM1", adr=8, debug=False) hedge1.start() hedge2.start() sleep(1) for row in points: graph.add_node(rowNumber) rowNumber = rowNumber + 1 n = rowNumber # print(n) for i in range(0, n): for j in range(0, n): if points[i, j] != 0: graph.add_edge(i, j, points[i, j])
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 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 import numpy as np import math # 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 pre_right_encoder, pre_left_encoder = bot.getEncoderCounts() print pre_right_encoder, pre_left_encoder # bot.setTurnSpeed(-20) vl = 30 vr = 30 bot.setWheelSpeed(vr, vl) time.sleep(5) # bot.setTurnSpeed(20) # time.sleep(2)