{"action":"created","issue":{"url":"https://api.github.com/repos/ev3dev/ev3dev/issues/402","labels_url":"https://api.github.com/repos/ev3dev/ev3dev/issues/402/labels{/name}","comments_url":"https://api.github.com/repos/ev3dev/ev3dev/issues/402/comments","events_url":"https://api.github.com/repos/ev3dev/ev3dev/issues/402/events","html_url":"https://github.com/ev3dev/ev3dev/issues/402","id":108550414,"number":402,"title":"Resetting the gyro","user":{"login":"jurezabkar","id":13961324,"avatar_url":"https://avatars.githubusercontent.com/u/13961324?v=3","gravatar_id":"","url":"https://api.github.com/users/jurezabkar","html_url":"https://github.com/jurezabkar","followers_url":"https://api.github.com/users/jurezabkar/followers","following_url":"https://api.github.com/users/jurezabkar/following{/other_user}","gists_url":"https://api.github.com/users/jurezabkar/gists{/gist_id}","starred_url":"https://api.github.com/users/jurezabkar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jurezabkar/subscriptions","organizations_url":"https://api.github.com/users/jurezabkar/orgs","repos_url":"https://api.github.com/users/jurezabkar/repos","events_url":"https://api.github.com/users/jurezabkar/events{/privacy}","received_events_url":"https://api.github.com/users/jurezabkar/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/ev3dev/ev3dev/labels/question","name":"question","color":"cc317c"},{"url":"https://api.github.com/repos/ev3dev/ev3dev/labels/sensors","name":"sensors","color":"0052cc"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-09-27T17:47:12Z","updated_at":"2015-09-29T14:54:41Z","closed_at":null,"body":"I've been trying to reset the gyro in ev3dev but haven't found a way to do so.\r\nEvery time I start the program (see below), gyro's value is 0, but I\r\ncan't figure out how to reset it inside the program.\r\n```python\r\nfrom ev3dev import *\r\nfrom mindstorms_widgets import mindstorms_widgets\r\n\r\ngs = gyro_sensor();\r\nassert gs.connected\r\ngs.mode = 'GYRO-ANG'\r\n\r\nrobot = mindstorms_widgets()\r\nrobot.connect_motor( 'left' )\r\nrobot.connect_motor( 'right' )\r\n\r\npower = 15\r\nrobot.move_tank( 'on', lr_power=[power,-power] )\r\n# gs.value() ==0 here\r\nwhile gs.value()<90:\r\n    pass\r\nrobot.move_tank( 'off', brake_at_end=True )\r\nprint gs.value() # gs.value() == 90 here (approx.)\r\n\r\n# I thought this would reset the gyro, but it doesn't\r\ngs = gyro_sensor();\r\nassert gs.connected\r\ngs.mode = 'GYRO-ANG'\r\n\r\nprint gs.value() # gs.value() == 90 here\r\n```"},"comment":{"url":"https://api.github.com/repos/ev3dev/ev3dev/issues/comments/144085242","html_url":"https://github.com/ev3dev/ev3dev/issues/402#issuecomment-144085242","issue_url":"https://api.github.com/repos/ev3dev/ev3dev/issues/402","id":144085242,"user":{"login":"dlech","id":963645,"avatar_url":"https://avatars.githubusercontent.com/u/963645?v=3","gravatar_id":"","url":"https://api.github.com/users/dlech","html_url":"https://github.com/dlech","followers_url":"https://api.github.com/users/dlech/followers","following_url":"https://api.github.com/users/dlech/following{/other_user}","gists_url":"https://api.github.com/users/dlech/gists{/gist_id}","starred_url":"https://api.github.com/users/dlech/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dlech/subscriptions","organizations_url":"https://api.github.com/users/dlech/orgs","repos_url":"https://api.github.com/users/dlech/repos","events_url":"https://api.github.com/users/dlech/events{/privacy}","received_events_url":"https://api.github.com/users/dlech/received_events","type":"User","site_admin":false},"created_at":"2015-09-29T14:54:41Z","updated_at":"2015-09-29T14:54:41Z","body":"Switching modes actually calibrates the gyro in addition to reseting the angle to zero. This is how you have to calibrate the gyro in the official LEGO software as well. So, that may not be the best choice if your robot is moving.\r\n\r\nThe alternative is to record current value in an `offset` variable and use that to determine the angle. Due to the way EV3/UART sensors work, it doesn't really make sense to try to implement a reset command at the driver level. I think it would be best to add this at the library level. It looks like you are using <https://github.com/topikachu/python-ev3>, so I would suggest opening an issue there.\r\n\r\n"}}