Skip to content
This repository was archived by the owner on Feb 3, 2023. It is now read-only.

Adding color, distance, rotation sensors#459

Merged
Octogonapus merged 13 commits into
OkapiLib:developfrom
dcieslak19973:add-optical-distance-rotation-sensors
Nov 10, 2020
Merged

Adding color, distance, rotation sensors#459
Octogonapus merged 13 commits into
OkapiLib:developfrom
dcieslak19973:add-optical-distance-rotation-sensors

Conversation

@dcieslak19973
Copy link
Copy Markdown
Contributor

Allows chassis builder to reference new RotationSensor

Description of the Change

Add wrappers for newly supported PROS API for the Color, Distance, and Rotation sensors

Motivation

Allow Chassis to reference the new Rotation Sensor for odometry

Possible Drawbacks

N/A

Verification Process

Tested Color and Distance sensors physically

Applicable Issues

N/A

Copy link
Copy Markdown
Member

@theol0403 theol0403 left a comment

Choose a reason for hiding this comment

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

Thanks, and thanks again for making the PR! Though you could have just changed the target of the last PR, and then force-pushed your branch, which would have fixed the PR.

You need to change all the method names to camelCase to conform to okapi convention, I know it's a bit of a pain. I have it set up in vim to switch the case on command, so if you want I could do this for you.

I know a lot of my comment suggestions are not your fault, you just copied the PROS comments, but I think they should be fixed for okapi.

Thanks!

Comment thread include/okapi/impl/device/distanceSensor.hpp Outdated
Comment thread include/okapi/impl/device/distanceSensor.hpp Outdated
Comment thread include/okapi/impl/device/distanceSensor.hpp Outdated
Comment thread include/okapi/impl/device/distanceSensor.hpp Outdated
Comment thread include/okapi/impl/device/distanceSensor.hpp Outdated
Comment thread include/okapi/impl/device/opticalSensor.hpp Outdated
Comment thread include/okapi/impl/device/rotarysensor/rotation.hpp Outdated
Comment thread src/impl/device/distanceSensor.cpp Outdated
Comment thread src/impl/device/rotarysensor/rotation.cpp Outdated
Comment thread src/impl/device/rotarysensor/rotation.cpp Outdated
Comment thread CONTRIBUTING.md Outdated
@dcieslak19973
Copy link
Copy Markdown
Contributor Author

Bump - waiting on anything from me?

Comment thread src/impl/device/opticalSensor.cpp Outdated
@codecov
Copy link
Copy Markdown

codecov Bot commented Nov 8, 2020

Codecov Report

Merging #459 (f2e2c6d) into develop (6140590) will decrease coverage by 0.36%.
The diff coverage is n/a.

@@             Coverage Diff             @@
##           develop     #459      +/-   ##
===========================================
- Coverage    89.04%   88.69%   -0.36%     
===========================================
  Files          140      140              
  Lines         5878     5878              
===========================================
- Hits          5234     5213      -21     
- Misses         644      665      +21     

Copy link
Copy Markdown
Member

@theol0403 theol0403 left a comment

Choose a reason for hiding this comment

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

Thanks for fixing most of the issues!
I'll take a bigger look (in a few days), I'll just leave some comments now.

I've noticed that by making the comments more consise, some have lost the title. Doxygen needs a title to parse properly. Duplication is okay, for example:
image

Comment thread include/okapi/impl/device/distanceSensor.hpp
Comment thread include/okapi/impl/device/distanceSensor.hpp
Comment thread include/okapi/impl/device/opticalSensor.hpp Outdated
Comment thread include/okapi/impl/device/opticalSensor.hpp
Comment thread include/okapi/impl/device/opticalSensor.hpp Outdated
Comment thread include/okapi/impl/device/opticalSensor.hpp Outdated
Comment thread include/okapi/impl/device/opticalSensor.hpp Outdated
@Octogonapus Octogonapus self-assigned this Nov 9, 2020
@Octogonapus Octogonapus added the feature A brand new feature label Nov 9, 2020
theol0403
theol0403 previously approved these changes Nov 9, 2020
Copy link
Copy Markdown
Member

@theol0403 theol0403 left a comment

Choose a reason for hiding this comment

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

Everything looks good! However, I would still recommend implementing a user-side flag for the direction of the rotation sensor, like with okapi::Motor.

std::int8_t reversed{1};

return pros::c::motor_get_voltage(port) * reversed;

This prevents multiple instances of a RotationSensor with conflicting directions from messing each other up. One could even argue having two instances of a RotationSensor on the same port with opposite direction is a use-case, on a complex robot with different subsystems controlled by a single axle.

@dcieslak19973
Copy link
Copy Markdown
Contributor Author

This prevents multiple instances of a RotationSensor with conflicting directions from messing each other up. One could even argue having two instances of a RotationSensor on the same port with opposite direction is a use-case, on a complex robot with different subsystems controlled by a single axle.

I'm not clear on how this situation could happen, but perhaps I'm not understanding what PROS did under the hood. If I have:

RotationSensor rs = RotationSensor(1,false);
RotationSensor ls = RotationSensor(2,true);

Won't this currently behave as expected, assuming the sensors are oriented on the right as going forward and the left going reveresed? As the robot drove straight forward, wouldn't ls and rs both show positive values?

@theol0403
Copy link
Copy Markdown
Member

Yes, that example works fine.

What I am referring to is

auto one = RotationSensor(1,false);
auto two = RotationSensor(1,true);

Expected: one increases while the other decreases
Actual: in an undefined manner, both of them will show the same value

@dcieslak19973
Copy link
Copy Markdown
Contributor Author

Makes sense. I was thinking about 2 physical devices which couldn't be plugged into the same port....

@Octogonapus
Copy link
Copy Markdown
Member

@theol0403 That is implemented now.

@Octogonapus
Copy link
Copy Markdown
Member

@dcieslak19973 Do you have a rotation sensor to test this with? I saw you tested the optical and distance sensors.

@dcieslak19973
Copy link
Copy Markdown
Contributor Author

I do have 2 physical rotation sensors. I'll test them physically tonight

theol0403
theol0403 previously approved these changes Nov 10, 2020
@dcieslak19973
Copy link
Copy Markdown
Contributor Author

Only had 1 rotation sensor; confirmed that

auto one=RotationSensor({3,true});
auto two=RotationSensor({3,false});

Behaves as expected - one.get() and two.get() return the same value with opposite signs.

@Octogonapus
Copy link
Copy Markdown
Member

Only had 1 rotation sensor; confirmed that

auto one=RotationSensor({3,true});
auto two=RotationSensor({3,false});

Behaves as expected - one.get() and two.get() return the same value with opposite signs.

And the values are in degrees?

@dcieslak19973
Copy link
Copy Markdown
Contributor Author

Correct, the return values are in degrees for the RotationSensor

@Octogonapus Octogonapus merged commit deaab65 into OkapiLib:develop Nov 10, 2020
Octogonapus added a commit that referenced this pull request Nov 10, 2020
* Update kernel to 3.3.1

* Update build scripts (#457)

* Update build scripts

* Poke CI

* Use recursive submodule checkout

* Poke CI

* Use previous checkout behavior

* Run test on PR

* Adding color, distance, rotation sensors (#459)

* Adding color, distance, rotation sensors

Allows chassis builder to reference new RotationSensor

* Updated to camel-case per coding conventions

Updated documentation.

Attempted to re-format comments, but clang-format broke locally for me

* Cleaned up comments

* Remove contributing changes

* Fix various things

* Fix rotation sensor file name

* Fix messy range docs

* Fix getSelectedOutput return value

* Address review comments about docs and const qualifiers

* Optionally disable gestures when constructing the optical sensor

* Remove unnecessary virtual qualifiers

* Reverse RotationSensor without reversing the port

* Fix non-std uint8_t

Co-authored-by: Octogonapus <firey45@gmail.com>

* Add building instructions to CONTRIBUTING.md.

Thanks to @dcieslak19973

* Version bump

Co-authored-by: dcieslak19973 <dcieslak@hotmail.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

feature A brand new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants