REVrobotics / 2m-Distance-Sensor

Port of ST vl53l0x driver for roboRIO to operate the REV Robotics 2m Distance Sensor.
http://www.revrobotics.com/rev-31-1505/
BSD 3-Clause "New" or "Revised" License
6 stars 8 forks source link

Port to 2020 #6

Closed willtoth closed 4 years ago

willtoth commented 4 years ago

Need to make this work for 2020 image.

nathanmutin commented 4 years ago

+1

Wylwi commented 4 years ago

+1

john-doe-blip commented 4 years ago

Did you port it so it works for 2020, mines still not working for 2020

willtoth commented 4 years ago

We will close this issue once it is ported for 2020

chauser commented 4 years ago

As part of the porting for 2020, please change the include file path for I2C.h. It should be <hal/I2C.h> rather than <HAL/I2C.h>. I am able to compile things using the library successfully on Windows (case-insensitive filenames) but not on linux.

In file included from /home/hauser/sciborgs-2020/robot-2020/robot/src/subsystems/the_robot/trenchController.h:49:0,
                 from /home/hauser/sciborgs-2020/robot-2020/robot/src/subsystems/the_robot/TheRobotSetup.cpp:32:
/home/hauser/.gradle/caches/transforms-2/files-2.1/deb540110fe5084595fa2d5c06e4659b/DistanceSensor-cpp-0.0.6-headers/rev/Rev2mDistanceSensor.h:38:10: fatal error: HAL/I2C.h: No such file or directory
 #include <HAL/I2C.h>
          ^~~~~~~~~~~
compilation terminated.

Having a working vendordep.json for 2020 for this library and having it work on linux would greatly simplify our development and continuous integration tooling. Thanks.

willtoth commented 4 years ago

Now builds with 2020 tools, need to do some testing https://github.com/REVrobotics/2m-Distance-Sensor/commit/151486c8406f677908c315b3d0673b62c7f79835

willtoth commented 4 years ago

roboRIO Libraries available here, it will likely take a few days before I can fully test and mark as a release. https://github.com/REVrobotics/2m-Distance-Sensor/releases/tag/2020.0.1

chauser commented 4 years ago

Hi Will, Thanks for your work on this. Just as a data point in your testing: I download the .tar.gz file, did a gradlew build and gradlew publish. Then copied the files from build/repos/com/ tree to my wpilib/2020/maven/com tree and copied the file from vendordeps/ to my robot code's vendordeps/. After that my robot code built successfully. (All this on linux). I can't test its operation on a RoboRio until this evening which I will do.

Are you going to be able to store all this in a publicly accessible maven location referenced by the vendordeps file this year? That worked very well for the REV color sensor -- all of our build machines found and downloaded the necessary files automatically which is much easier than having to download a zip file and copy files into the the maven directory locally on each dev machine.

Carl

willtoth commented 4 years ago

Uploading to the maven location now, all files are stored on the released page here https://github.com/REVrobotics/2m-Distance-Sensor/releases/tag/v0.2.0

Examples tested and working

chauser commented 4 years ago

Thank you!

On Wed, Jan 29, 2020 at 12:17 PM William Toth notifications@github.com wrote:

Closed #6 https://github.com/REVrobotics/2m-Distance-Sensor/issues/6.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/REVrobotics/2m-Distance-Sensor/issues/6?email_source=notifications&email_token=AAGLUU7KWZND7XXEUXSMB7TRAHP7FA5CNFSM4KBOLDZKYY3PNVWWK3TUL52HS4DFWZEXG43VMVCXMZLOORHG65DJMZUWGYLUNFXW5KTDN5WW2ZLOORPWSZGOWJDC3BQ#event-2990943622, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAGLUU6TCS7PZRQO7HZTJQTRAHP7FANCNFSM4KBOLDZA .

chauser commented 4 years ago

Hi William, We added the distance sensor library to our c++ code. Everything now builds fine, but when deploying to the roborio, gradle does not deploy libDistanceSensorDriver.so and the code fails to start on the rio due to the missing library. I'm not familiar with the details of vendorDeps files but the only difference I see in the description of libDistanceSensorDriver vs libDistanceSensor is that in Rev2mDistanceSensor.json, sharedLibrary is set to true for the former and false for the latter. Or are we doing something else wrong? Carl

On Wed, Jan 29, 2020 at 12:17 PM William Toth notifications@github.com wrote:

Closed #6 https://github.com/REVrobotics/2m-Distance-Sensor/issues/6.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/REVrobotics/2m-Distance-Sensor/issues/6?email_source=notifications&email_token=AAGLUU7KWZND7XXEUXSMB7TRAHP7FA5CNFSM4KBOLDZKYY3PNVWWK3TUL52HS4DFWZEXG43VMVCXMZLOORHG65DJMZUWGYLUNFXW5KTDN5WW2ZLOORPWSZGOWJDC3BQ#event-2990943622, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAGLUU6TCS7PZRQO7HZTJQTRAHP7FANCNFSM4KBOLDZA .

chauser commented 4 years ago

Please ignore the previous message. It doesn't describe the situation accurately. -- Carl

On Sat, Feb 1, 2020 at 3:17 PM Carl Hauser carl.hauser@gmail.com wrote:

Hi William, We added the distance sensor library to our c++ code. Everything now builds fine, but when deploying to the roborio, gradle does not deploy libDistanceSensorDriver.so and the code fails to start on the rio due to the missing library. I'm not familiar with the details of vendorDeps files but the only difference I see in the description of libDistanceSensorDriver vs libDistanceSensor is that in Rev2mDistanceSensor.json, sharedLibrary is set to true for the former and false for the latter. Or are we doing something else wrong? Carl

On Wed, Jan 29, 2020 at 12:17 PM William Toth notifications@github.com wrote:

Closed #6 https://github.com/REVrobotics/2m-Distance-Sensor/issues/6.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/REVrobotics/2m-Distance-Sensor/issues/6?email_source=notifications&email_token=AAGLUU7KWZND7XXEUXSMB7TRAHP7FA5CNFSM4KBOLDZKYY3PNVWWK3TUL52HS4DFWZEXG43VMVCXMZLOORHG65DJMZUWGYLUNFXW5KTDN5WW2ZLOORPWSZGOWJDC3BQ#event-2990943622, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAGLUU6TCS7PZRQO7HZTJQTRAHP7FANCNFSM4KBOLDZA .

chauser commented 4 years ago

OK, better info now. It seems that libDistanceSensor.so refers to libDistanceSensorDriver.so but the vendorDeps file says that the DistanceSensorDriver is not a shared library. With Rev2mDistanceSensor.json as supplied I see a warning in the linker output about libDistanceSensorDriver.so, required by libDistanceSensor.so, not being found. When I change the sharedLibrary setting for the DistanceSensorDriver to true, the warning goes away. I expect that this would also be sufficient for gradle to deploy libDistanceSensorDriver.so to the roborio, but I can't check that until Monday evening when I have access to a rio.

While changing the setting may get rid of the errors, it may not be the right solution, since I don't know what the intention of having the driver library be static (libDistanceSensorDriver.a) was. But maybe all this will give you some insight into what needs to happen.

-- Carl

On Sat, Feb 1, 2020 at 4:04 PM Carl Hauser carl.hauser@gmail.com wrote:

Please ignore the previous message. It doesn't describe the situation accurately. -- Carl

On Sat, Feb 1, 2020 at 3:17 PM Carl Hauser carl.hauser@gmail.com wrote:

Hi William, We added the distance sensor library to our c++ code. Everything now builds fine, but when deploying to the roborio, gradle does not deploy libDistanceSensorDriver.so and the code fails to start on the rio due to the missing library. I'm not familiar with the details of vendorDeps files but the only difference I see in the description of libDistanceSensorDriver vs libDistanceSensor is that in Rev2mDistanceSensor.json, sharedLibrary is set to true for the former and false for the latter. Or are we doing something else wrong? Carl

On Wed, Jan 29, 2020 at 12:17 PM William Toth notifications@github.com wrote:

Closed #6 https://github.com/REVrobotics/2m-Distance-Sensor/issues/6.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/REVrobotics/2m-Distance-Sensor/issues/6?email_source=notifications&email_token=AAGLUU7KWZND7XXEUXSMB7TRAHP7FA5CNFSM4KBOLDZKYY3PNVWWK3TUL52HS4DFWZEXG43VMVCXMZLOORHG65DJMZUWGYLUNFXW5KTDN5WW2ZLOORPWSZGOWJDC3BQ#event-2990943622, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAGLUU6TCS7PZRQO7HZTJQTRAHP7FANCNFSM4KBOLDZA .

willtoth commented 4 years ago

It shouldn't really matter either way. When using C++ static linking should be fine. When using Java the lib is transferred anyway. Though there may be a flag in the build for you build.gradle to switch between static and shared?

Also there should not be any issue using shared or static.

chauser commented 4 years ago

OK. Then I think there is a small bug currently in that DistanceSensorDriver is expected to be static by the .json, but the provided libDistanceSensor.so already has a reference in it to libDistanceSensorDriver.so.

On Sun, Feb 2, 2020 at 9:36 AM William Toth notifications@github.com wrote:

It shouldn't really matter either way. When using C++ static linking should be fine. When using Java the lib is transferred anyway. Though there may be a flag in the build for you build.gradle to switch between static and shared?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/REVrobotics/2m-Distance-Sensor/issues/6?email_source=notifications&email_token=AAGLUU4MCGQFFJRKC4LWMIDRA4AAZA5CNFSM4KBOLDZKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEKR4LMI#issuecomment-581158321, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAGLUUYGPGVQ2XD5S3QGDLLRA4AAZANCNFSM4KBOLDZA .

SAinc commented 4 years ago

I am attempting to use this sensor in our robot in Java. I have downloaded and installed the 2020.0.3 library, but still get the link error: Unhandled exception instantiating robot com.revrobotics.jni.VL53L0XJNI java.lang.UnsatisfiedLinkError: 'void com.revrobotics.jni.VL53L0XJNI.Init(int, int)' Error at com.revrobotics.jni.VL53L0XJNI.Init(Native Method): Unhandled exception instantiating robot com.revrobotics.jni.VL53L0XJNI java.lang.UnsatisfiedLinkError: 'void com.revrobotics.jni.VL53L0XJNI.Init(int, int)' at com.revrobotics.jni.VL53L0XJNI.Init(Native Method) at com.revrobotics.Rev2mDistanceSensor.<init>(Rev2mDistanceSensor.java:96) at com.revrobotics.Rev2mDistanceSensor.<init>(Rev2mDistanceSensor.java:107) at frc.robot.subsystems.BallHandler.<init>(BallHandler.java:38) at frc.robot.Robot.<init>(Robot.java:83) at edu.wpi.first.wpilibj.RobotBase.runRobot(RobotBase.java:231) at edu.wpi.first.wpilibj.RobotBase.startRobot(RobotBase.java:348) at frc.robot.Main.main(Main.java:27)

The implementation is identical to that of the example code, but we are using CAN spark maxes. Also, the version reported by WPIlib is 0.0.6.

What can I do to fix it?

SAinc commented 4 years ago

I figured it out. I needed to copy the maven and vendordeps to C:\Users\Public\wpilib\2020. This should be changed in the instructions. Thanks for your work in supporting all your great hardware!