Skip to content

Implement BeaconSeeker class - #311

Merged
ddemidov merged 2 commits into
developfrom
beacon-seeker
Mar 23, 2017
Merged

ddemidov merged 2 commits into
developfrom
beacon-seeker

Conversation

@ddemidov

Copy link
Copy Markdown
Member

See #302.

@fisherds, I went with separate class as opposed to adding the heading and distance methods to the InfraredSensor class. The reason is that the remote controller has four channels. With the separate BeaconSeeker class we can set the channel in the class constructor, and implement heading/distance as properties:

beacon = BeaconSeeker(channel=1)
print( beacon.heading_and_distance )

This is very similar to the way the RemoteControl class works.

If we extended the InfraredSensor class instead, we would have to specify channel on each call to heading/distance:

s = InfraredSensor()
print( s.beacon_heading(channel=1) )

What do you think?

@fisherds

Copy link
Copy Markdown

Yeah setting it once in the constructor is much cleaner. Totally on board with your approach now. Once you look at the resulting code I love the way you did it. Awesome! Thanks @ddemidov

@ddemidov

Copy link
Copy Markdown
Member Author

Added the new class to the documentation. Preview: http://ev3dev-lang.readthedocs.io/projects/python-ev3dev/en/beacon-seeker/other.html#beacon-seeker

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants