Beispiel #1
0
import breezycreate2
import time

robot = breezycreate2.Robot(port='/dev/ttyUSB1')

speed = lambda value: robot.setForwardSpeed(value)
turn = lambda value: robot.setTurnSpeed(value)
sleep = lambda value: time.sleep(value)

def u_turn(direction):
	if direction > 0:
                print "trying to turn clockwise"
		step(0, 200, 1)
		step(100, 0, 3)
		step(0, 200, 1)
	else:
                print "trying to turn anti-clockwise"
		step(0, -200, 1)
		step(100, 0, 3)
		step(0, -200, 1)
		


def step(speed_val, turn_val, time_val):
  if speed_val:
    turn(0)
    speed(speed_val)
  else:
    speed(0)
    turn(turn_val)
  sleep(time_val)
Beispiel #2
0
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.
'''

import breezycreate2
import time

# Create a Create2. This will automatically try to connect to your robot over serial
bot = breezycreate2.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

bot.setWheelSpeed(50, 20)

time.sleep(5)

bot.setWheelSpeed(20, 20)