Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CAT-1316 Sensor-type to GAMING; LIN.ACC.- and ROT.VECT. (inclin.,… #1325

Merged
merged 1 commit into from
Aug 8, 2015

Conversation

ghost
Copy link

@ghost ghost commented Aug 3, 2015

…compass-dir) sensor fallback

private float linearAcceleartionX = 0f;
private float linearAcceleartionY = 0f;
private float linearAcceleartionZ = 0f;
private float[] accelerationXYZ = new float [3];
Copy link
Contributor

Choose a reason for hiding this comment

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

Extraneous space between float and [3].

@aried3r
Copy link
Contributor

aried3r commented Aug 3, 2015

Please run the formatter on your files, there's quite a few formatting errors.

@martinbu
Copy link
Contributor

martinbu commented Aug 4, 2015

Everything works fine now on Moto G1.

@ghost ghost force-pushed the CAT-1316 branch from 71e8514 to e6cc802 Compare August 4, 2015 20:03
@ghost
Copy link
Author

ghost commented Aug 4, 2015

@aried3r: formatter run. Didn't think of it - but last time I ran the formatter @obusher had something against it:

obusher commented on May 18
I know the format of this class is not in best shape and it is compelling to use auto-format.
But i want to see a clean github-diff, so please do not use this magic. 🐰

I generally understand that - but it wouldn't be a problem when the formatter would be run automagically in every Android Studio on save - so the format wouldn't deteriorate in the first place.

@martinbu: Thanks for your help finding my copy/paste error - now the values in the Compute-Dialog in the formula-editor are correctly updated 👍

@aried3r
Copy link
Contributor

aried3r commented Aug 4, 2015

While I agree that there should be an option to format it automatically, there is an option to only format the lines you have changed.

reformat

And while I don't personally commit from within Android Studio, there is an option to format before committing.

screen shot 2015-08-04 at 22 58 28

@robertpainsi
Copy link
Member

edit: Dangle-it, @aried3r was faster! 😔

JFI: The comment you quoted is outdated :bowtie: and all java classes (except two lines [1] and [2]) are formatted according to the Android Studio formatter.
All new checkstyle rules are doing a great job, however, the approach mentioned by @aried3r should be used/preferred.

@ghost
Copy link
Author

ghost commented Aug 4, 2015

@aried3r : that's cool thanks - haven't tried committing from Android Studio yet.

@aried3r
Copy link
Contributor

aried3r commented Aug 4, 2015

All new checkstyle rules are doing a great job

Is there a way to have Jenkins run this and report back within a few minutes? If this isn't already the case. I don't want to comment every PR because of these things.

It seems GitHub can list multiple test runs on PRs. See here for an example.

@robertpainsi
Copy link
Member

Is there a way to have Jenkins run this and report back within a few minutes? If this isn't already the case. I don't want to comment every PR because of these things.

There is already an experimental jenkins job waiting to replace the current Catroid-Build-SourceTests-StaticChecks job. The new one will abort the complete PR testrun if there are any pmd, checkstyle or lint warnings. So, if a jenkins testrun takes only a few minutes, which you can check even without a jenkins account, it highly indicates new static code analyzing warnings. I'll ping you if the new job has been activated.

It seems GitHub can list multiple test runs on PRs. See here for an example.

Thanks for the tip! I like it and I'll write a (low priority) ticket for it. 😸

@ghost ghost force-pushed the CAT-1316 branch 2 times, most recently from 164e46b to 3c0530e Compare August 5, 2015 20:11

case COMPASS_DIRECTION:
float[] orientations = new float[3];
android.hardware.SensorManager.getRotationMatrixFromVector(instance.rotationMatrix,
instance.rotationVector);
if (!instance.useRotationVectorFallback) {
Copy link
Contributor

Choose a reason for hiding this comment

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

what happens here if useRotationVectorFallback is true? correct me if I'm wrong, but if there is no getRotationMatrixFromVector then the rotationMatrix is not initialised and hence you won't get any reasonable results anyway.

Copy link
Author

Choose a reason for hiding this comment

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

Hi!
If the useRotatitonVectorFallback is true - then the rotatiton-matrix is NOT obtained from the RotationVectorSensor (because this does not exist in this phone) but determined by means of the getRotationMatrix(float[],float[],float[],float[]) with accelerometer data AND macgnetic field data in line 303 in the onSensorChanged(...) method - when the MagneticField Sensor is present.
If NEITHER rotation-matrix sensor NOR magnetic field sensor are present compass direction does not work on this phone.

Copy link
Contributor

Choose a reason for hiding this comment

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

all right! got it! obviously I hadn't understood it properly before, thank you for clearing that up.

@thmq
Copy link
Contributor

thmq commented Aug 7, 2015

apart from the question regarding the compass direction the PR looks fine. any objections against merging it as soon as this has been cleared up? @robertpainsi @martinbu ?

float rawInclinationX = RADIAN_TO_DEGREE_CONST * (float) (Math.acos(instance.accelerationXYZ[0]));
float correctedInclinationX = 0;

// X-inclination: turn right direction
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think the comments are necessary.

Copy link
Author

Choose a reason for hiding this comment

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

true

@ghost ghost force-pushed the CAT-1316 branch from 3c0530e to 88ec2b4 Compare August 7, 2015 12:01
@ghost
Copy link
Author

ghost commented Aug 7, 2015

removed the two comments

@thmq
Copy link
Contributor

thmq commented Aug 7, 2015

retest this please

correctedInclinationX = -(180 + (90 - rawInclinationX));
}
} else
if (rawInclinationX >= 0 && rawInclinationX < 90) {
Copy link
Member

Choose a reason for hiding this comment

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

That's an interesting case of else-if coding style...
Do you read it as else { if (... (because a else block doesn't require braces) or as else if (...?
However, let's see what the android studio formatter does! 😉

Also removing comments, as suggested by @thmq, does not always end up by just removing them. Please take a look at Clean Code, "Don't use a comment when you can use a function or variable".

However, I prefer this example

// Bad:
// Check to see if the employee is eligible for full benefits
if ((employee.flags & HOURLY_FLAG) && (employee.age > 65))

// Good:
if (employee.isEligibleForFullBenefits())

@thmq
Copy link
Contributor

thmq commented Aug 7, 2015

@robertpainsi 's right about this. you should try to keep your code as well legible as possible. besides there seems to be a problem with the sensor test [1].

@avihric
Copy link
Contributor

avihric commented Aug 7, 2015

retest this please

@ghost
Copy link
Author

ghost commented Aug 7, 2015

@thmq damn this test uses "reflection"!
I was sure the test was green but... since the "accelerometerSensor" which was originally used in the SensorHandler was actually the "linearAccelerationSensor" AND
"linearAcceleration[X|Y|Z]" were misspelled as "linearAcceleartion[X|Y|Z]" ;-)

So this happens when correcting variable-names AFTER running the "final" tests which uses "reflection". 🙀 Shame on me that I didn't have a look at the test - so I would have known.

@ghost ghost force-pushed the CAT-1316 branch from 88ec2b4 to 2045020 Compare August 7, 2015 20:41
@avihric
Copy link
Contributor

avihric commented Aug 8, 2015

I will merge this because the Release is urgent, but you will have to refactor Sensorhandler as described by @robertpainsi

Btw: I will cherry-pick this commit into master

avihric added a commit that referenced this pull request Aug 8, 2015
CAT-1316 Fix sensor issues
@avihric avihric merged commit 3601b6a into Catrobat:develop Aug 8, 2015
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.

5 participants