-
Notifications
You must be signed in to change notification settings - Fork 60
Conversation
self.analog.setAccumulatorCenter(self.center) | ||
self.analog.resetAccumulator() | ||
hal.setAnalogGyroParameters(self._gyroHandle, self.kDefaultVoltsPerDegreePerSecond, offset, center) | ||
reset() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self.reset
?
if not hal.HALIsSimulation(): | ||
Timer.delay(1.0) | ||
|
||
if self._gyroHandle == 0: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this gets initialized before this line?
|
||
def free(self): | ||
""":see: :meth:`.Gyro.free`""" | ||
LiveWindow.removeComponent(self) | ||
if self.analog is not None and self.channelAllocated: | ||
self.analog.free() | ||
self.analog = None | ||
|
||
hal.freeAnalogGyro(self._gyroHandle) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should set handle to None after this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since the code above checks for 0 i'll set to 0
Timer.delay(1.0) | ||
|
||
if self._gyroHandle == 0: | ||
self._gyroHandle = hal.initializeAnalogGyro(self.analog.port) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By convention, we usually turn m_foo
into self.foo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it was a private variable so I added the _ just in case. Should I change it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've thought about using that convention, but I think the rest of the code doesn't do that, so let's not start now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lol
except IndexError as e: | ||
raise IndexError("Analog output channel %d is already allocated" % channel) from e | ||
|
||
SensorBase.checkANalogOutputChannel(channel) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo.
@@ -49,7 +49,7 @@ def __init__(self, channel, fullRange=1.0, offset=0.0): | |||
if not hasattr(channel, "getVoltage"): | |||
channel = AnalogInput(channel) | |||
self.analog_input = channel | |||
self.fullRange = fullRange | |||
self._fullRange = fullRange |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did this get changed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
became private
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, don't change it. Otherwise there's a LOT of things to change..
fb3eb92
to
7213fa4
Compare
@@ -60,7 +60,7 @@ def get(self): | |||
:returns: The current position of the potentiometer. | |||
:rtype: float | |||
""" | |||
return (self.analog_input.getVoltage() / hal.getUserVoltage5V()) * self.fullRange + self.offset | |||
return (self.analog_input.getVoltage() / hal.getUserVoltage5V()) * self._fullRange + self._offset |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Forgot one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good other than that.
@@ -37,7 +37,7 @@ class AnalogGyro(GyroBase): | |||
kDefaultVoltsPerDegreePerSecond = 0.007 | |||
|
|||
PIDSourceType = PIDSource.PIDSourceType | |||
|
|||
gyroHandle = 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spacing, should have at least one line above each function.
Also... this feels a bit odd to me. It's not wrong. But. I'd rather see this assigned in the constructor.
7213fa4
to
d2ff096
Compare
@@ -56,6 +56,9 @@ def __init__(self, channel, center=None, offset=None): | |||
:param offset: Preset uncalibrated value to use as the gyro offset | |||
:type offset: float | |||
""" | |||
|
|||
gyroHandle = 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self.gyroHandle
|
||
|
||
|
||
self.gyroHandle = 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
couldn't tell you
|
||
def free(self): | ||
""":see: :meth:`.Gyro.free`""" | ||
LiveWindow.removeComponent(self) | ||
if self.analog is not None and self.channelAllocated: | ||
self.analog.free() | ||
self.analog = None | ||
|
||
hal.freeAnalogGyro(self.gyroHandle) | ||
self.gyroHandle = 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since there are changes to be made... spacing!
@@ -60,7 +60,7 @@ def get(self): | |||
:returns: The current position of the potentiometer. | |||
:rtype: float | |||
""" | |||
return (self.analog_input.getVoltage() / hal.getUserVoltage5V()) * self.fullRange + self.offset | |||
return (self.analog_input.getVoltage() / hal.getUserVoltage5V()) * self.fullRange + self._offset |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Somehow I missed this (perhaps because of fullrange), but line 53 says that offset doesn't start with an underscore.
removed lock Edited HALReporting and HALUsage fixed typo Fixed typo and moved gyroHandle Fixed changes
d2ff096
to
b14bcb5
Compare
No description provided.