Skip to content
This repository has been archived by the owner on Nov 13, 2023. It is now read-only.

Ported 'a's to python #224

Merged
merged 1 commit into from
Dec 6, 2016
Merged

Ported 'a's to python #224

merged 1 commit into from
Dec 6, 2016

Conversation

ArchdukeTim
Copy link
Contributor

No description provided.

self.analog.setAccumulatorCenter(self.center)
self.analog.resetAccumulator()
hal.setAnalogGyroParameters(self._gyroHandle, self.kDefaultVoltsPerDegreePerSecond, offset, center)
reset()
Copy link
Member

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:
Copy link
Member

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)
Copy link
Member

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

Copy link
Contributor Author

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)
Copy link
Member

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

Copy link
Contributor Author

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?

Copy link
Member

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.

Copy link
Contributor Author

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)
Copy link
Member

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
Copy link
Member

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

became private

Copy link
Member

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..

@ArchdukeTim ArchdukeTim force-pushed the startsWithA branch 2 times, most recently from fb3eb92 to 7213fa4 Compare December 4, 2016 04:39
@@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forgot one.

Copy link
Member

@virtuald virtuald left a 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
Copy link
Member

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.

@@ -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
Copy link
Member

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this here?

Copy link
Contributor Author

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
Copy link
Member

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
Copy link
Member

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
@virtuald virtuald merged commit 5f915c0 into robotpy:master Dec 6, 2016
@ArchdukeTim ArchdukeTim deleted the startsWithA branch December 25, 2017 21:39
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants