Update auto-drive.py#250
Conversation
fixed bugs in the code. is_pressed is a function, as well as proximity. Also when run_timed, you must set the speed not duty cycle.
| while not btn.any(): | ||
|
|
||
| if ts.is_pressed: | ||
| if ts.is_pressed(): |
There was a problem hiding this comment.
This is actually something that changed in our most recent release, which is not included in the most recent ev3dev image by default. See https://github.com/rhempel/ev3dev-lang-python/releases/tag/0.8.0 for details on that release. If you'd like to upgrade, you can also find instructions on doing so in the README.
|
|
||
| for m, p in zip(motors, power): | ||
| m.run_timed(duty_cycle_sp=p*75, time_sp=t) | ||
| m.run_timed(speed_sp=p*750, time_sp=t) |
There was a problem hiding this comment.
Good catch; I guess we didn't fix all cases of duty_cycle in the demos after we made that change in the library.
| # Sound backup alarm. | ||
| Sound.tone([(1000, 500, 500)] * 3) | ||
|
|
||
There was a problem hiding this comment.
Is this whitespace consistent with what we have in other places? While we're here, we should normalize this.
There was a problem hiding this comment.
There should be no trailing spaces in the code.
There was a problem hiding this comment.
can you explain the issue. This is a blank line, not sure I understand the objection
There was a problem hiding this comment.
@DrClick I think this looks good aside from the whitespace. If you can remove that (both here and two lines above it) I'd say it's ready!
There was a problem hiding this comment.
You're right, it has absolutely no effect on the code's functionality. I ask for those changes mainly because they make the diff easier to read and keep the file uniform. For example, if I find a new bug next week and want to use git's "blame" feature to figure out when this section of code was last modified, I would find that you were the last one to change the code, even though all you did was add some whitespace. Keeping those extraneous changes out of our commit history makes things like that significantly easier.
removed whitespace, reverted function calls to properties
| # Sound backup alarm. | ||
| Sound.tone([(1000, 500, 500)] * 3) | ||
|
|
||
There was a problem hiding this comment.
can you explain the issue. This is a blank line, not sure I understand the objection
|
Thanks! |
| ir = InfraredSensor(); assert ir.connected | ||
| ts = TouchSensor(); assert ts.connected | ||
|
|
||
| print('Robot Starting') |
There was a problem hiding this comment.
Since this is a demo, we could use this as an opportunity to demonstrate espeak functionality, and change the line to
Sound.speak('Robot starting').wait()It will also be easier to notice when launched from brickman interface.
There was a problem hiding this comment.
Is there a demo somewhere on how to vim a .sh file and chmod + x it so it can be launched? Or is there some other way to make these scripts executable on the brickman?
There was a problem hiding this comment.
It not, it would be a valuable edition to the readme.
There was a problem hiding this comment.
There could be something about it here:
https://sites.google.com/site/ev3python/putty
EDIT: wrong link
There was a problem hiding this comment.
Since this is a demo, we could use this as an opportunity to demonstrate espeak functionality, and change the line to
I can't say I'm particularly excited to talk at people every time they start his robot, but I suppose it could be a good way to help people discover this functionality.
Is there a demo somewhere on how to vim a .sh file and chmod + x it so it can be launched? Or is there some other way to make these scripts executable on the brickman?
I believe the README has a section on preparing Python files for execution.
fixed bugs in the code. is_pressed is a function, as well as proximity. Also when run_timed, you must set the speed not duty cycle. Thanks again for your work! You had as up and running and a great first day with ev3dev!