Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sensors stop working #1083

Open
mohammadguy opened this issue May 1, 2018 · 1 comment
Open

sensors stop working #1083

mohammadguy opened this issue May 1, 2018 · 1 comment
Labels
info needed This issue is blocked waiting a response from someone support Technical support request (not a bug or enhancement)

Comments

@mohammadguy
Copy link

mohammadguy commented May 1, 2018

after the while loop ends and starts again the sensors stop working
the robot starts moving forward but no longer corrects its direction based on the gyro sensor and no longer stops after 15cm.

#!/usr/bin/env python3

from ev3dev.ev3 import*

import ev3dev.ev3 as ev3

from time import sleep

mD = ev3.LargeMotor('outD')

mA = ev3.LargeMotor('outA')

btn = Button()

cl = ColorSensor()

cl.mode='COL-COLOR'

assert cl.connected

us = UltrasonicSensor()

assert us.connected

us.mode = 'US-DIST-CM'

units = us.units

gy = GyroSensor()

assert gy.connected

gy.mode = 'GYRO-ANG'

while btn.any()==False:
	sleep(.09)

def turn(a,d): 
	b = a*50
	c = b*-1
	e = 0
	while e != 320:
		print(str(e))
		e = e+1
		if gy.value() < d:
			mD.run_forever(speed_sp=b)
			mA.run_forever(speed_sp=c)
		if gy.value() > d:
			mD.run_forever(speed_sp=c)
			mA.run_forever(speed_sp=b)
		if gy.value() == d:
			mA.stop(stop_action="hold") 
			mD.stop(stop_action="hold")
	e = 0

def forward(f):
	while us.value() > 150 and cl.value() != 1:
		print(us.value())
		print(cl.value())
		print(gy.value())
		mD.run_forever(speed_sp=100)
		mA.run_forever(speed_sp=100)
		if us.value() < 150:
			mA.stop(stop_action="hold") 
			mD.stop(stop_action="hold")	
		if cl.value() == 1 or cl.value() == 3:
			mA.stop(stop_action="hold") 
			mD.stop(stop_action="hold")
		if gy.value() < f:
			mD.run_forever(speed_sp=45)
			mA.run_forever(speed_sp=-45)
		if gy.value() > f:
			mD.run_forever(speed_sp=-45)
			mA.run_forever(speed_sp=45)
gy.mode = 'GYRO-RATE'

sleep(0.09)

gy.mode = 'GYRO-ANG'

while True:

	forward(0)

	turn(1,90)

	forward(90)

	turn(1,0)

	forward(0)

	turn(1,-90)

	forward(-90)

	turn(1,0)

	forward(0)

	turn(1,180)

	forward(180)

	turn(1,0)
@dlech
Copy link
Member

dlech commented May 2, 2018

What is the date code stamped on your gyro sensor? e.g. "19N3"

@dlech dlech added the info needed This issue is blocked waiting a response from someone label May 3, 2018
@dlech dlech added the support Technical support request (not a bug or enhancement) label Nov 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
info needed This issue is blocked waiting a response from someone support Technical support request (not a bug or enhancement)
Projects
None yet
Development

No branches or pull requests

2 participants