├── rc-action ├── .gitignore ├── src │ ├── main │ │ └── java │ │ │ ├── org │ │ │ └── rcdukes │ │ │ │ └── action │ │ │ │ ├── package-info.java │ │ │ │ ├── StartLightObserver.java │ │ │ │ └── Navigator.java │ │ │ └── stormbots │ │ │ ├── package-info.java │ │ │ └── Main.java │ └── test │ │ └── java │ │ └── org │ │ └── rcdukes │ │ └── action │ │ ├── TestSuite.java │ │ └── TestAction.java └── pom.xml ├── rc-app ├── .gitignore ├── src │ ├── main │ │ ├── java │ │ │ └── org │ │ │ │ └── rcdukes │ │ │ │ └── app │ │ │ │ ├── package-info.java │ │ │ │ ├── PositionDisplay.java │ │ │ │ ├── GUIDisplayer.java │ │ │ │ ├── CameraGUI.java │ │ │ │ └── SimulatorImageFetcher.java │ │ └── resources │ │ │ └── fx │ │ │ ├── labeledvalueslider.fxml │ │ │ ├── dukes.css │ │ │ ├── camera.fxml │ │ │ ├── startlightdetection.fxml │ │ │ ├── lanedetection.fxml │ │ │ └── navigation.fxml │ └── test │ │ └── java │ │ └── org │ │ └── rcdukes │ │ └── test │ │ └── app │ │ └── TestApp.java └── pom.xml ├── rc-car ├── .gitignore ├── src │ ├── main │ │ └── java │ │ │ └── org │ │ │ └── rcdukes │ │ │ └── car │ │ │ └── package-info.java │ └── test │ │ └── java │ │ └── org │ │ └── rcdukes │ │ └── car │ │ ├── TestSuite.java │ │ ├── TestCar.java │ │ └── TestHandlers.java └── pom.xml ├── rc-common ├── .gitignore ├── src │ ├── main │ │ └── java │ │ │ └── org │ │ │ └── rcdukes │ │ │ ├── error │ │ │ ├── package-info.java │ │ │ ├── ExceptionHandler.java │ │ │ └── ErrorHandler.java │ │ │ └── common │ │ │ ├── package-info.java │ │ │ ├── POJO.java │ │ │ ├── EventbusLogger.java │ │ │ ├── Events.java │ │ │ ├── ErrorHandler.java │ │ │ ├── GraphDatabase.java │ │ │ └── ServoCalibration.java │ └── test │ │ └── java │ │ └── org │ │ └── rcdukes │ │ └── common │ │ ├── TestSuite.java │ │ ├── TestErrorHandler.java │ │ ├── TestRxJava.java │ │ ├── TestPOJO.java │ │ ├── TestClusterStarter.java │ │ ├── TestCharacters.java │ │ ├── TestConfiguration.java │ │ └── TestGraphDatabase.java └── pom.xml ├── rc-detect ├── .gitignore ├── src │ ├── main │ │ ├── resources │ │ │ └── images │ │ │ │ ├── road.jpg │ │ │ │ ├── sudoku.jpg │ │ │ │ ├── edges_2020-01-29151752.jpg │ │ │ │ ├── 640px-4_lane_highway_roads_in_India_NH_48_Karnataka_3.jpg │ │ │ │ └── 640px-4_lane_highway_roads_in_India_NH_48_Karnataka_3.png │ │ └── java │ │ │ └── org │ │ │ └── rcdukes │ │ │ ├── detect │ │ │ ├── package-info.java │ │ │ ├── edgedectection │ │ │ │ ├── package-info.java │ │ │ │ ├── SobelEdgeDetector.java │ │ │ │ ├── WatershedEdgeDetector.java │ │ │ │ └── CannyEdgeDetector.java │ │ │ ├── stopzonedetection │ │ │ │ ├── package-info.java │ │ │ │ ├── StoppingZoneDetector.java │ │ │ │ └── DefaultStoppingZoneDetector.java │ │ │ ├── startlightdetection │ │ │ │ └── package-info.java │ │ │ ├── lanedetection │ │ │ │ ├── package-info.java │ │ │ │ └── DefaultLaneDetector.java │ │ │ ├── linedetection │ │ │ │ ├── package-info.java │ │ │ │ └── LineFilter.java │ │ │ ├── ImageObserver.java │ │ │ └── CameraConfig.java │ │ │ ├── objects │ │ │ ├── package-info.java │ │ │ ├── lane │ │ │ │ ├── package-info.java │ │ │ │ ├── BoundaryDefaults.java │ │ │ │ ├── LaneRightBoundary.java │ │ │ │ └── LaneLeftBoundary.java │ │ │ ├── stoppingzone │ │ │ │ ├── package-info.java │ │ │ │ ├── ZoneEndBoundary.java │ │ │ │ ├── ZoneStartBoundary.java │ │ │ │ └── StoppingZoneOrientation.java │ │ │ ├── StoppingZone.java │ │ │ ├── Boundary.java │ │ │ ├── ViewPort.java │ │ │ └── StartLight.java │ │ │ ├── detectors │ │ │ ├── package-info.java │ │ │ ├── EdgeDetector.java │ │ │ ├── LaneDetector.java │ │ │ ├── LineDetector.java │ │ │ └── StartLightDetector.java │ │ │ └── video │ │ │ ├── package-info.java │ │ │ ├── ImageSource.java │ │ │ ├── PointMapper.java │ │ │ ├── DenoiseByBlur.java │ │ │ ├── ColorFilter.java │ │ │ └── VideoRecorder.java │ └── test │ │ └── java │ │ └── org │ │ └── rcdukes │ │ └── detect │ │ ├── TestCannyConfig.java │ │ ├── TestSuite.java │ │ ├── BaseDetectTest.java │ │ ├── TestImageProcessing.java │ │ ├── TestImageCollector.java │ │ └── TestHoughLinesDetector.java └── pom.xml ├── rc-roi ├── .gitignore ├── src │ ├── test │ │ └── resources │ │ │ └── roi │ │ │ ├── dukes_roi_test_image.jpg │ │ │ └── logitech_test_stream.mjpg │ └── main │ │ └── java │ │ └── org │ │ └── rcdukes │ │ ├── opencv │ │ ├── package-info.java │ │ └── OsCheck.java │ │ └── roi │ │ ├── package-info.java │ │ └── ROI.java └── pom.xml ├── rc-server ├── .gitignore └── src │ ├── main │ └── java │ │ └── org │ │ └── rcdukes │ │ └── server │ │ └── package-info.java │ └── test │ └── java │ └── org │ └── rcsdukes │ └── server │ ├── TestSuite.java │ └── TestEventBusBridge.java ├── rc-coverage └── .gitignore ├── rc-geometry ├── .gitignore ├── src │ └── main │ │ └── java │ │ └── org │ │ └── rcdukes │ │ └── geometry │ │ ├── pointinplane │ │ ├── package-info.java │ │ ├── PointInPlane.java │ │ └── CrossingNumber.java │ │ ├── package-info.java │ │ ├── Point2D.java │ │ ├── Lane.java │ │ └── LaneDetectionResult.java └── pom.xml ├── rc-remotecar ├── .gitignore └── src │ ├── main │ └── java │ │ └── org │ │ └── rcdukes │ │ └── remotecar │ │ └── package-info.java │ └── test │ └── java │ └── org │ └── rcdukes │ └── remotecar │ ├── TestSuite.java │ └── TestRemoteCar.java ├── rc-watchdog ├── .gitignore ├── src │ ├── main │ │ └── java │ │ │ └── org │ │ │ └── rcdukes │ │ │ └── watchdog │ │ │ └── package-info.java │ └── test │ │ └── java │ │ └── org │ │ └── rcdukes │ │ └── watchdog │ │ ├── TestWatchDog.java │ │ └── TestAsync.java └── pom.xml ├── rc-webcontrol ├── .gitignore └── src │ └── main │ ├── resources │ └── web │ │ ├── images │ │ ├── camera.jpg │ │ ├── edges.jpg │ │ ├── lines.jpg │ │ ├── birdseye.jpg │ │ ├── noedges.png │ │ ├── nolines.png │ │ └── StreetLane.jpg │ │ ├── fonts │ │ ├── materialdesignicons-webfont.eot │ │ ├── materialdesignicons-webfont.ttf │ │ ├── materialdesignicons-webfont.woff │ │ └── materialdesignicons-webfont.woff2 │ │ ├── css │ │ └── themes │ │ │ └── base │ │ │ ├── images │ │ │ ├── ui-icons_444444_256x240.png │ │ │ └── ui-icons_555555_256x240.png │ │ │ └── fonts │ │ │ ├── materialdesignicons-webfont.eot │ │ │ ├── materialdesignicons-webfont.ttf │ │ │ ├── materialdesignicons-webfont.woff │ │ │ └── materialdesignicons-webfont.woff2 │ │ ├── bootstrap.html │ │ └── js │ │ └── starter.js │ └── java │ └── org │ └── rcdukes │ └── webcontrol │ ├── package-info.java │ └── WebControl.java ├── rc-drivecontrol ├── .gitignore ├── src │ ├── main │ │ └── java │ │ │ └── org │ │ │ └── rcdukes │ │ │ ├── car │ │ │ ├── package-info.java │ │ │ ├── LedMap.java │ │ │ ├── ServoCommand.java │ │ │ ├── Led.java │ │ │ ├── ServoMap.java │ │ │ ├── ServoRangeMap.java │ │ │ ├── Servo.java │ │ │ ├── Steering.java │ │ │ ├── Engine.java │ │ │ ├── ServoRange.java │ │ │ └── ServoBlaster.java │ │ │ └── drivecontrol │ │ │ ├── package-info.java │ │ │ ├── LedMap.java │ │ │ ├── ServoMap.java │ │ │ ├── SteeringMap.java │ │ │ └── EngineMap.java │ └── test │ │ ├── java │ │ └── org │ │ │ └── rcdukes │ │ │ └── drivecontrol │ │ │ ├── TestSuite.java │ │ │ └── ServoCommandDummy.java │ │ └── resources │ │ └── dukes │ │ └── dukes.ini ├── servo └── pom.xml ├── rc-imageview ├── .gitignore ├── src │ ├── main │ │ └── java │ │ │ └── org │ │ │ └── rcdukes │ │ │ └── imageview │ │ │ ├── package-info.java │ │ │ └── MJpegHandler.java │ └── test │ │ └── java │ │ └── org │ │ └── rcdukes │ │ └── imageview │ │ ├── OpenCVBasedTest.java │ │ └── TestSuite.java └── pom.xml ├── rc-camera-matrix ├── .gitignore ├── src │ ├── test │ │ ├── resources │ │ │ ├── cameramatrix │ │ │ │ ├── GOPR0032.jpg │ │ │ │ ├── GOPR0033.jpg │ │ │ │ ├── GOPR0034.jpg │ │ │ │ ├── GOPR0035.jpg │ │ │ │ ├── GOPR0036.jpg │ │ │ │ ├── GOPR0037.jpg │ │ │ │ ├── GOPR0038.jpg │ │ │ │ ├── GOPR0040.jpg │ │ │ │ ├── GOPR0041.jpg │ │ │ │ ├── GOPR0042.jpg │ │ │ │ ├── GOPR0043.jpg │ │ │ │ ├── GOPR0044.jpg │ │ │ │ ├── GOPR0045.jpg │ │ │ │ ├── GOPR0046.jpg │ │ │ │ ├── GOPR0047.jpg │ │ │ │ ├── GOPR0048.jpg │ │ │ │ ├── GOPR0049.jpg │ │ │ │ ├── GOPR0050.jpg │ │ │ │ ├── GOPR0051.jpg │ │ │ │ ├── GOPR0052.jpg │ │ │ │ ├── GOPR0053.jpg │ │ │ │ ├── GOPR0054.jpg │ │ │ │ ├── GOPR0055.jpg │ │ │ │ ├── GOPR0057.jpg │ │ │ │ ├── GOPR0058.jpg │ │ │ │ ├── GOPR0059.jpg │ │ │ │ ├── GOPR0060.jpg │ │ │ │ ├── GOPR0061.jpg │ │ │ │ ├── GOPR0062.jpg │ │ │ │ ├── GOPR0063.jpg │ │ │ │ ├── GOPR0064.jpg │ │ │ │ ├── GOPR0066.jpg │ │ │ │ ├── GOPR0067.jpg │ │ │ │ ├── GOPR0068.jpg │ │ │ │ ├── GOPR0069.jpg │ │ │ │ ├── GOPR0070.jpg │ │ │ │ └── test_image.jpg │ │ │ └── perspectiveshift │ │ │ │ ├── dukes_livingroom.jpeg │ │ │ │ ├── dukes_chessBoard008.png │ │ │ │ └── dukes_desk_screen_shot.png │ │ └── java │ │ │ └── org │ │ │ └── rcdukes │ │ │ └── camera │ │ │ ├── TestSuite.java │ │ │ ├── MatrixTestbase.java │ │ │ └── TestCameraMatrix.java │ └── main │ │ └── java │ │ └── org │ │ └── rcdukes │ │ └── camera │ │ ├── package-info.java │ │ ├── ImagePolygon.java │ │ └── PerspectiveShift.java └── pom.xml ├── lib ├── opencv-343.jar └── libopencv_java343.dylib ├── .idea ├── encodings.xml ├── vcs.xml ├── misc.xml └── modules.xml ├── scripts ├── subdirs.py ├── createpackageinfos ├── coverage └── install.sh ├── .travis.yml ├── dukes.iml └── .gitignore /rc-action/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /rc-app/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /rc-car/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /rc-common/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /rc-detect/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /rc-roi/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /rc-server/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /rc-coverage/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /rc-geometry/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /rc-remotecar/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /rc-watchdog/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /rc-webcontrol/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /rc-drivecontrol/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /rc-imageview/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | /bin/ 3 | -------------------------------------------------------------------------------- /rc-camera-matrix/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | /bin/ 3 | -------------------------------------------------------------------------------- /lib/opencv-343.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rc-dukes/dukes/HEAD/lib/opencv-343.jar -------------------------------------------------------------------------------- /lib/libopencv_java343.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rc-dukes/dukes/HEAD/lib/libopencv_java343.dylib -------------------------------------------------------------------------------- /rc-detect/src/main/resources/images/road.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rc-dukes/dukes/HEAD/rc-detect/src/main/resources/images/road.jpg -------------------------------------------------------------------------------- /rc-detect/src/main/resources/images/sudoku.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rc-dukes/dukes/HEAD/rc-detect/src/main/resources/images/sudoku.jpg -------------------------------------------------------------------------------- /rc-roi/src/test/resources/roi/dukes_roi_test_image.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rc-dukes/dukes/HEAD/rc-roi/src/test/resources/roi/dukes_roi_test_image.jpg -------------------------------------------------------------------------------- /rc-webcontrol/src/main/resources/web/images/camera.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rc-dukes/dukes/HEAD/rc-webcontrol/src/main/resources/web/images/camera.jpg -------------------------------------------------------------------------------- /rc-webcontrol/src/main/resources/web/images/edges.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rc-dukes/dukes/HEAD/rc-webcontrol/src/main/resources/web/images/edges.jpg -------------------------------------------------------------------------------- /rc-webcontrol/src/main/resources/web/images/lines.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rc-dukes/dukes/HEAD/rc-webcontrol/src/main/resources/web/images/lines.jpg -------------------------------------------------------------------------------- /rc-roi/src/test/resources/roi/logitech_test_stream.mjpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rc-dukes/dukes/HEAD/rc-roi/src/test/resources/roi/logitech_test_stream.mjpg -------------------------------------------------------------------------------- /rc-webcontrol/src/main/resources/web/images/birdseye.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rc-dukes/dukes/HEAD/rc-webcontrol/src/main/resources/web/images/birdseye.jpg -------------------------------------------------------------------------------- /rc-webcontrol/src/main/resources/web/images/noedges.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rc-dukes/dukes/HEAD/rc-webcontrol/src/main/resources/web/images/noedges.png -------------------------------------------------------------------------------- /rc-webcontrol/src/main/resources/web/images/nolines.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rc-dukes/dukes/HEAD/rc-webcontrol/src/main/resources/web/images/nolines.png -------------------------------------------------------------------------------- /rc-webcontrol/src/main/resources/web/images/StreetLane.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rc-dukes/dukes/HEAD/rc-webcontrol/src/main/resources/web/images/StreetLane.jpg -------------------------------------------------------------------------------- /rc-camera-matrix/src/test/resources/cameramatrix/GOPR0032.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rc-dukes/dukes/HEAD/rc-camera-matrix/src/test/resources/cameramatrix/GOPR0032.jpg -------------------------------------------------------------------------------- /rc-camera-matrix/src/test/resources/cameramatrix/GOPR0033.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rc-dukes/dukes/HEAD/rc-camera-matrix/src/test/resources/cameramatrix/GOPR0033.jpg -------------------------------------------------------------------------------- /rc-camera-matrix/src/test/resources/cameramatrix/GOPR0034.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rc-dukes/dukes/HEAD/rc-camera-matrix/src/test/resources/cameramatrix/GOPR0034.jpg -------------------------------------------------------------------------------- /rc-camera-matrix/src/test/resources/cameramatrix/GOPR0035.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rc-dukes/dukes/HEAD/rc-camera-matrix/src/test/resources/cameramatrix/GOPR0035.jpg -------------------------------------------------------------------------------- /rc-camera-matrix/src/test/resources/cameramatrix/GOPR0036.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rc-dukes/dukes/HEAD/rc-camera-matrix/src/test/resources/cameramatrix/GOPR0036.jpg -------------------------------------------------------------------------------- /rc-camera-matrix/src/test/resources/cameramatrix/GOPR0037.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rc-dukes/dukes/HEAD/rc-camera-matrix/src/test/resources/cameramatrix/GOPR0037.jpg -------------------------------------------------------------------------------- /rc-camera-matrix/src/test/resources/cameramatrix/GOPR0038.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rc-dukes/dukes/HEAD/rc-camera-matrix/src/test/resources/cameramatrix/GOPR0038.jpg -------------------------------------------------------------------------------- /rc-camera-matrix/src/test/resources/cameramatrix/GOPR0040.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rc-dukes/dukes/HEAD/rc-camera-matrix/src/test/resources/cameramatrix/GOPR0040.jpg -------------------------------------------------------------------------------- /rc-camera-matrix/src/test/resources/cameramatrix/GOPR0041.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rc-dukes/dukes/HEAD/rc-camera-matrix/src/test/resources/cameramatrix/GOPR0041.jpg -------------------------------------------------------------------------------- /rc-camera-matrix/src/test/resources/cameramatrix/GOPR0042.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rc-dukes/dukes/HEAD/rc-camera-matrix/src/test/resources/cameramatrix/GOPR0042.jpg -------------------------------------------------------------------------------- /rc-camera-matrix/src/test/resources/cameramatrix/GOPR0043.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rc-dukes/dukes/HEAD/rc-camera-matrix/src/test/resources/cameramatrix/GOPR0043.jpg -------------------------------------------------------------------------------- /rc-camera-matrix/src/test/resources/cameramatrix/GOPR0044.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rc-dukes/dukes/HEAD/rc-camera-matrix/src/test/resources/cameramatrix/GOPR0044.jpg -------------------------------------------------------------------------------- /rc-camera-matrix/src/test/resources/cameramatrix/GOPR0045.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rc-dukes/dukes/HEAD/rc-camera-matrix/src/test/resources/cameramatrix/GOPR0045.jpg -------------------------------------------------------------------------------- /rc-camera-matrix/src/test/resources/cameramatrix/GOPR0046.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rc-dukes/dukes/HEAD/rc-camera-matrix/src/test/resources/cameramatrix/GOPR0046.jpg -------------------------------------------------------------------------------- /rc-camera-matrix/src/test/resources/cameramatrix/GOPR0047.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rc-dukes/dukes/HEAD/rc-camera-matrix/src/test/resources/cameramatrix/GOPR0047.jpg -------------------------------------------------------------------------------- /rc-camera-matrix/src/test/resources/cameramatrix/GOPR0048.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rc-dukes/dukes/HEAD/rc-camera-matrix/src/test/resources/cameramatrix/GOPR0048.jpg -------------------------------------------------------------------------------- /rc-camera-matrix/src/test/resources/cameramatrix/GOPR0049.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rc-dukes/dukes/HEAD/rc-camera-matrix/src/test/resources/cameramatrix/GOPR0049.jpg -------------------------------------------------------------------------------- /rc-camera-matrix/src/test/resources/cameramatrix/GOPR0050.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rc-dukes/dukes/HEAD/rc-camera-matrix/src/test/resources/cameramatrix/GOPR0050.jpg -------------------------------------------------------------------------------- /rc-camera-matrix/src/test/resources/cameramatrix/GOPR0051.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rc-dukes/dukes/HEAD/rc-camera-matrix/src/test/resources/cameramatrix/GOPR0051.jpg -------------------------------------------------------------------------------- /rc-camera-matrix/src/test/resources/cameramatrix/GOPR0052.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rc-dukes/dukes/HEAD/rc-camera-matrix/src/test/resources/cameramatrix/GOPR0052.jpg -------------------------------------------------------------------------------- /rc-camera-matrix/src/test/resources/cameramatrix/GOPR0053.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rc-dukes/dukes/HEAD/rc-camera-matrix/src/test/resources/cameramatrix/GOPR0053.jpg -------------------------------------------------------------------------------- /rc-camera-matrix/src/test/resources/cameramatrix/GOPR0054.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rc-dukes/dukes/HEAD/rc-camera-matrix/src/test/resources/cameramatrix/GOPR0054.jpg -------------------------------------------------------------------------------- /rc-camera-matrix/src/test/resources/cameramatrix/GOPR0055.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rc-dukes/dukes/HEAD/rc-camera-matrix/src/test/resources/cameramatrix/GOPR0055.jpg -------------------------------------------------------------------------------- /rc-camera-matrix/src/test/resources/cameramatrix/GOPR0057.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rc-dukes/dukes/HEAD/rc-camera-matrix/src/test/resources/cameramatrix/GOPR0057.jpg -------------------------------------------------------------------------------- /rc-camera-matrix/src/test/resources/cameramatrix/GOPR0058.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rc-dukes/dukes/HEAD/rc-camera-matrix/src/test/resources/cameramatrix/GOPR0058.jpg -------------------------------------------------------------------------------- /rc-camera-matrix/src/test/resources/cameramatrix/GOPR0059.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rc-dukes/dukes/HEAD/rc-camera-matrix/src/test/resources/cameramatrix/GOPR0059.jpg -------------------------------------------------------------------------------- /rc-camera-matrix/src/test/resources/cameramatrix/GOPR0060.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rc-dukes/dukes/HEAD/rc-camera-matrix/src/test/resources/cameramatrix/GOPR0060.jpg -------------------------------------------------------------------------------- /rc-camera-matrix/src/test/resources/cameramatrix/GOPR0061.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rc-dukes/dukes/HEAD/rc-camera-matrix/src/test/resources/cameramatrix/GOPR0061.jpg -------------------------------------------------------------------------------- /rc-camera-matrix/src/test/resources/cameramatrix/GOPR0062.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rc-dukes/dukes/HEAD/rc-camera-matrix/src/test/resources/cameramatrix/GOPR0062.jpg -------------------------------------------------------------------------------- /rc-camera-matrix/src/test/resources/cameramatrix/GOPR0063.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rc-dukes/dukes/HEAD/rc-camera-matrix/src/test/resources/cameramatrix/GOPR0063.jpg -------------------------------------------------------------------------------- /rc-camera-matrix/src/test/resources/cameramatrix/GOPR0064.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rc-dukes/dukes/HEAD/rc-camera-matrix/src/test/resources/cameramatrix/GOPR0064.jpg -------------------------------------------------------------------------------- /rc-camera-matrix/src/test/resources/cameramatrix/GOPR0066.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rc-dukes/dukes/HEAD/rc-camera-matrix/src/test/resources/cameramatrix/GOPR0066.jpg -------------------------------------------------------------------------------- /rc-camera-matrix/src/test/resources/cameramatrix/GOPR0067.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rc-dukes/dukes/HEAD/rc-camera-matrix/src/test/resources/cameramatrix/GOPR0067.jpg -------------------------------------------------------------------------------- /rc-camera-matrix/src/test/resources/cameramatrix/GOPR0068.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rc-dukes/dukes/HEAD/rc-camera-matrix/src/test/resources/cameramatrix/GOPR0068.jpg -------------------------------------------------------------------------------- /rc-camera-matrix/src/test/resources/cameramatrix/GOPR0069.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rc-dukes/dukes/HEAD/rc-camera-matrix/src/test/resources/cameramatrix/GOPR0069.jpg -------------------------------------------------------------------------------- /rc-camera-matrix/src/test/resources/cameramatrix/GOPR0070.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rc-dukes/dukes/HEAD/rc-camera-matrix/src/test/resources/cameramatrix/GOPR0070.jpg -------------------------------------------------------------------------------- /rc-camera-matrix/src/test/resources/cameramatrix/test_image.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rc-dukes/dukes/HEAD/rc-camera-matrix/src/test/resources/cameramatrix/test_image.jpg -------------------------------------------------------------------------------- /rc-detect/src/main/java/org/rcdukes/detect/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * org.rcdukes.detect is part of the rc-detect module 3 | */ 4 | package org.rcdukes.detect; 5 | -------------------------------------------------------------------------------- /rc-detect/src/main/java/org/rcdukes/objects/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * org.rcdukes.objects is part of the rc-detect module 3 | */ 4 | package org.rcdukes.objects; 5 | -------------------------------------------------------------------------------- /rc-detect/src/main/resources/images/edges_2020-01-29151752.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rc-dukes/dukes/HEAD/rc-detect/src/main/resources/images/edges_2020-01-29151752.jpg -------------------------------------------------------------------------------- /rc-server/src/main/java/org/rcdukes/server/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * CarServer entry point to start cluster and webcontrol 3 | */ 4 | package org.rcdukes.server; 5 | -------------------------------------------------------------------------------- /rc-detect/src/main/java/org/rcdukes/detectors/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * org.rcdukes.detectors is part of the rc-detect module 3 | */ 4 | package org.rcdukes.detectors; 5 | -------------------------------------------------------------------------------- /rc-detect/src/main/java/org/rcdukes/objects/lane/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * org.rcdukes.objects.lane is part of the rc-detect module 3 | */ 4 | package org.rcdukes.objects.lane; 5 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /rc-camera-matrix/src/test/resources/perspectiveshift/dukes_livingroom.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rc-dukes/dukes/HEAD/rc-camera-matrix/src/test/resources/perspectiveshift/dukes_livingroom.jpeg -------------------------------------------------------------------------------- /rc-webcontrol/src/main/resources/web/fonts/materialdesignicons-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rc-dukes/dukes/HEAD/rc-webcontrol/src/main/resources/web/fonts/materialdesignicons-webfont.eot -------------------------------------------------------------------------------- /rc-webcontrol/src/main/resources/web/fonts/materialdesignicons-webfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rc-dukes/dukes/HEAD/rc-webcontrol/src/main/resources/web/fonts/materialdesignicons-webfont.ttf -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /rc-camera-matrix/src/test/resources/perspectiveshift/dukes_chessBoard008.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rc-dukes/dukes/HEAD/rc-camera-matrix/src/test/resources/perspectiveshift/dukes_chessBoard008.png -------------------------------------------------------------------------------- /rc-roi/src/main/java/org/rcdukes/opencv/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * com.bitplan.opencv is part of the rc-roi module 3 | * @TODO - add description 4 | */ 5 | package org.rcdukes.opencv; 6 | -------------------------------------------------------------------------------- /rc-webcontrol/src/main/resources/web/fonts/materialdesignicons-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rc-dukes/dukes/HEAD/rc-webcontrol/src/main/resources/web/fonts/materialdesignicons-webfont.woff -------------------------------------------------------------------------------- /rc-webcontrol/src/main/resources/web/fonts/materialdesignicons-webfont.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rc-dukes/dukes/HEAD/rc-webcontrol/src/main/resources/web/fonts/materialdesignicons-webfont.woff2 -------------------------------------------------------------------------------- /rc-camera-matrix/src/test/resources/perspectiveshift/dukes_desk_screen_shot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rc-dukes/dukes/HEAD/rc-camera-matrix/src/test/resources/perspectiveshift/dukes_desk_screen_shot.png -------------------------------------------------------------------------------- /rc-roi/src/main/java/org/rcdukes/roi/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * nl.vaneijndhoven.dukes.roi is part of the rc-roi module 3 | * Region of Interest handling 4 | */ 5 | package org.rcdukes.roi; 6 | -------------------------------------------------------------------------------- /rc-app/src/main/java/org/rcdukes/app/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Initial JavaFx apps for Lane and StartLight Detection 3 | * have been replaced by webcontrol in the meantime 4 | */ 5 | package org.rcdukes.app; -------------------------------------------------------------------------------- /rc-detect/src/main/java/org/rcdukes/objects/stoppingzone/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * org.rcdukes.objects.stoppingzone is part of the rc-detect module 3 | */ 4 | package org.rcdukes.objects.stoppingzone; 5 | -------------------------------------------------------------------------------- /rc-detect/src/main/java/org/rcdukes/video/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * nl.vaneijndhoven.opencv.video is part of the rc-detect module 3 | * @TODO - add description 4 | */ 5 | package org.rcdukes.video; 6 | -------------------------------------------------------------------------------- /rc-car/src/main/java/org/rcdukes/car/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * org.rcdukes.car is part of the rc-car module 3 | * Engine and Steering control on the device (Raspberry) 4 | */ 5 | package org.rcdukes.car; 6 | -------------------------------------------------------------------------------- /rc-detect/src/main/java/org/rcdukes/detect/edgedectection/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * org.rcdukes.detect.edgedectection is part of the rc-detect module 3 | */ 4 | package org.rcdukes.detect.edgedectection; 5 | -------------------------------------------------------------------------------- /rc-common/src/main/java/org/rcdukes/error/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * org.rcdukes.error is part of the rc-common module 3 | * ExceptionHandler interface and Errorhandler 4 | */ 5 | package org.rcdukes.error; 6 | -------------------------------------------------------------------------------- /rc-detect/src/main/java/org/rcdukes/detect/stopzonedetection/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * org.rcdukes.detect.stopzonedetection is part of the rc-detect module 3 | */ 4 | package org.rcdukes.detect.stopzonedetection; 5 | -------------------------------------------------------------------------------- /rc-webcontrol/src/main/resources/web/css/themes/base/images/ui-icons_444444_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rc-dukes/dukes/HEAD/rc-webcontrol/src/main/resources/web/css/themes/base/images/ui-icons_444444_256x240.png -------------------------------------------------------------------------------- /rc-webcontrol/src/main/resources/web/css/themes/base/images/ui-icons_555555_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rc-dukes/dukes/HEAD/rc-webcontrol/src/main/resources/web/css/themes/base/images/ui-icons_555555_256x240.png -------------------------------------------------------------------------------- /rc-webcontrol/src/main/resources/web/css/themes/base/fonts/materialdesignicons-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rc-dukes/dukes/HEAD/rc-webcontrol/src/main/resources/web/css/themes/base/fonts/materialdesignicons-webfont.eot -------------------------------------------------------------------------------- /rc-webcontrol/src/main/resources/web/css/themes/base/fonts/materialdesignicons-webfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rc-dukes/dukes/HEAD/rc-webcontrol/src/main/resources/web/css/themes/base/fonts/materialdesignicons-webfont.ttf -------------------------------------------------------------------------------- /rc-webcontrol/src/main/resources/web/css/themes/base/fonts/materialdesignicons-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rc-dukes/dukes/HEAD/rc-webcontrol/src/main/resources/web/css/themes/base/fonts/materialdesignicons-webfont.woff -------------------------------------------------------------------------------- /rc-camera-matrix/src/main/java/org/rcdukes/camera/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * org.rcdukes.camera.matrix is part of the rc-camera-matrix module 3 | * allows e.g. perspective shifting 4 | */ 5 | package org.rcdukes.camera; 6 | -------------------------------------------------------------------------------- /rc-detect/src/main/java/org/rcdukes/detect/startlightdetection/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * org.rcdukes.detect.startlightdetection is part of the rc-detect module 3 | */ 4 | package org.rcdukes.detect.startlightdetection; 5 | -------------------------------------------------------------------------------- /rc-detect/src/main/resources/images/640px-4_lane_highway_roads_in_India_NH_48_Karnataka_3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rc-dukes/dukes/HEAD/rc-detect/src/main/resources/images/640px-4_lane_highway_roads_in_India_NH_48_Karnataka_3.jpg -------------------------------------------------------------------------------- /rc-detect/src/main/resources/images/640px-4_lane_highway_roads_in_India_NH_48_Karnataka_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rc-dukes/dukes/HEAD/rc-detect/src/main/resources/images/640px-4_lane_highway_roads_in_India_NH_48_Karnataka_3.png -------------------------------------------------------------------------------- /rc-webcontrol/src/main/resources/web/css/themes/base/fonts/materialdesignicons-webfont.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rc-dukes/dukes/HEAD/rc-webcontrol/src/main/resources/web/css/themes/base/fonts/materialdesignicons-webfont.woff2 -------------------------------------------------------------------------------- /rc-imageview/src/main/java/org/rcdukes/imageview/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * org.dukes.imageview is part of the rc-imageview module 3 | * Has the DebugImageServer and VideoRecorder 4 | */ 5 | package org.rcdukes.imageview; 6 | -------------------------------------------------------------------------------- /rc-drivecontrol/src/main/java/org/rcdukes/car/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * org.rcdukes.car is part of the rc-drivecontrol module 3 | * it controls the servos for the vehicle e.g. Motor and Steering 4 | */ 5 | package org.rcdukes.car; 6 | -------------------------------------------------------------------------------- /rc-detect/src/main/java/org/rcdukes/detect/lanedetection/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * nl.vaneijndhoven.opencv.lanedetection is part of the rc-detect module 3 | * @TODO - add description 4 | */ 5 | package org.rcdukes.detect.lanedetection; 6 | -------------------------------------------------------------------------------- /rc-detect/src/main/java/org/rcdukes/detect/linedetection/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * nl.vaneijndhoven.opencv.linedetection is part of the rc-detect module 3 | * @TODO - add description 4 | */ 5 | package org.rcdukes.detect.linedetection; 6 | -------------------------------------------------------------------------------- /rc-drivecontrol/src/main/java/org/rcdukes/drivecontrol/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * org.rcdukes.drivecontrol is part of the rc-drivecontrol module 3 | * it contains the classes to control the vehicle 4 | */ 5 | package org.rcdukes.drivecontrol; 6 | -------------------------------------------------------------------------------- /rc-geometry/src/main/java/org/rcdukes/geometry/pointinplane/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * org.rcdukes.geometry.pointinplane is part of the rc-geometry module 3 | * Has PointIn Plane Interface 4 | */ 5 | package org.rcdukes.geometry.pointinplane; 6 | -------------------------------------------------------------------------------- /rc-detect/src/main/java/org/rcdukes/detectors/EdgeDetector.java: -------------------------------------------------------------------------------- 1 | package org.rcdukes.detectors; 2 | 3 | import org.opencv.core.Mat; 4 | 5 | /** 6 | * detector for edges 7 | */ 8 | public interface EdgeDetector { 9 | Mat detect(Mat image); 10 | } 11 | -------------------------------------------------------------------------------- /rc-drivecontrol/src/main/java/org/rcdukes/car/LedMap.java: -------------------------------------------------------------------------------- 1 | package org.rcdukes.car; 2 | 3 | /** 4 | * configures LED settings 5 | * @author wf 6 | * 7 | */ 8 | public interface LedMap extends ServoMap { 9 | int ledOff(); 10 | int ledOn(); 11 | } 12 | -------------------------------------------------------------------------------- /rc-remotecar/src/main/java/org/rcdukes/remotecar/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * org.rcdukes.remotecar is part of the rc-remotecar module 3 | * RemoteCar verticle to run on client to receive commands via network 4 | */ 5 | package org.rcdukes.remotecar; 6 | -------------------------------------------------------------------------------- /rc-action/src/main/java/org/rcdukes/action/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Action/Luke Verticle to control car based on detections 3 | * org.rcdukes.action is part of the rc-action module 4 | * StraightLaneNavigator 5 | */ 6 | package org.rcdukes.action; 7 | -------------------------------------------------------------------------------- /rc-common/src/main/java/org/rcdukes/common/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * org.rcdukes.common is part of the rc-common module 3 | * Configuration, DukesVerticle, Environment, ClusterStarter and Characters (e.g. Call-Signs) 4 | */ 5 | package org.rcdukes.common; 6 | -------------------------------------------------------------------------------- /rc-detect/src/main/java/org/rcdukes/objects/lane/BoundaryDefaults.java: -------------------------------------------------------------------------------- 1 | package org.rcdukes.objects.lane; 2 | 3 | public class BoundaryDefaults { 4 | public static double DEFAULT_LANE_BOUNDARY_ANGLE = 45; 5 | public static double DEFAULT_LANE_BOUNDARY_TOLERANCE = 30; 6 | } 7 | -------------------------------------------------------------------------------- /rc-webcontrol/src/main/java/org/rcdukes/webcontrol/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Web app to remotely control the RC car and e.g 3 | * start/stop autopilot watch live camera screen 4 | * and control engine, wheels and led 5 | */ 6 | package org.rcdukes.webcontrol; 7 | -------------------------------------------------------------------------------- /rc-detect/src/main/java/org/rcdukes/video/ImageSource.java: -------------------------------------------------------------------------------- 1 | package org.rcdukes.video; 2 | 3 | import io.reactivex.Observable; 4 | 5 | /** 6 | * allow access to images via Observable 7 | */ 8 | public interface ImageSource { 9 | Observable getImageObservable(); 10 | } 11 | -------------------------------------------------------------------------------- /rc-geometry/src/main/java/org/rcdukes/geometry/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Basic geometric algorithms for Polygon, Line and Point mostly in 2D 3 | * but expandable to 3D 4 | * 5 | * org.rcdukes.geometry is part of the rc-geometry module 6 | * @since 0.0.1 7 | */ 8 | package org.rcdukes.geometry; 9 | -------------------------------------------------------------------------------- /rc-app/src/main/java/org/rcdukes/app/PositionDisplay.java: -------------------------------------------------------------------------------- 1 | package org.rcdukes.app; 2 | 3 | import org.rcdukes.common.ServoPosition; 4 | 5 | /** 6 | * show a Servo Position in the GUI 7 | * @author wf 8 | * 9 | */ 10 | public interface PositionDisplay { 11 | public void showPosition(ServoPosition position); 12 | } 13 | -------------------------------------------------------------------------------- /rc-watchdog/src/main/java/org/rcdukes/watchdog/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * org.rcdukes.watchdog is part of the rc-watchdog module 3 | * The Watchdog controls power - it will automatically power off if no heartbeat signal 4 | * is received making sure the remote connection is alive 5 | */ 6 | package org.rcdukes.watchdog; 7 | -------------------------------------------------------------------------------- /rc-imageview/src/test/java/org/rcdukes/imageview/OpenCVBasedTest.java: -------------------------------------------------------------------------------- 1 | package org.rcdukes.imageview; 2 | 3 | import org.junit.BeforeClass; 4 | import org.rcdukes.opencv.NativeLibrary; 5 | 6 | public class OpenCVBasedTest { 7 | @BeforeClass 8 | public static void setup() throws Exception { 9 | NativeLibrary.load(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /rc-action/src/main/java/org/rcdukes/action/StartLightObserver.java: -------------------------------------------------------------------------------- 1 | package org.rcdukes.action; 2 | 3 | import io.vertx.core.json.JsonObject; 4 | import rx.Observable; 5 | 6 | /** 7 | * start light observer 8 | */ 9 | public class StartLightObserver { 10 | 11 | public Observable observe(JsonObject startLightDetection) { 12 | return Observable.empty(); 13 | } 14 | 15 | 16 | } 17 | -------------------------------------------------------------------------------- /rc-detect/src/main/java/org/rcdukes/detectors/LaneDetector.java: -------------------------------------------------------------------------------- 1 | package org.rcdukes.detectors; 2 | 3 | import org.rcdukes.geometry.Lane; 4 | import org.rcdukes.geometry.Line; 5 | import org.rcdukes.objects.ViewPort; 6 | 7 | import java.util.Collection; 8 | 9 | /** 10 | * detect for lanes 11 | * 12 | */ 13 | public interface LaneDetector { 14 | Lane detect(Collection lines, ViewPort viewPort); 15 | } 16 | -------------------------------------------------------------------------------- /rc-detect/src/main/java/org/rcdukes/detect/stopzonedetection/StoppingZoneDetector.java: -------------------------------------------------------------------------------- 1 | package org.rcdukes.detect.stopzonedetection; 2 | 3 | import org.rcdukes.geometry.Line; 4 | import org.rcdukes.objects.StoppingZone; 5 | 6 | import java.util.Collection; 7 | 8 | /** 9 | * detector for stopping zone 10 | */ 11 | public interface StoppingZoneDetector { 12 | 13 | StoppingZone detect(Collection lines); 14 | } 15 | -------------------------------------------------------------------------------- /rc-drivecontrol/servo: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # WF 2020-01-22 3 | # test servo with AdaFruit from commandline 4 | jar=target/rc-drivecontrol-0.0.2.jar 5 | cp=$jar 6 | m2rep=$HOME/.m2/repository 7 | for pkg in com/pi4j args4j org/slf4j/slf4j-api/1.7.16 8 | do 9 | for jar in $(find $m2rep/$pkg/ -name *.jar) 10 | do 11 | echo $jar 12 | cp="$cp:$jar" 13 | done 14 | done 15 | echo $cp 16 | java -cp $cp org.rcdukes.car.AdaFruit $@ 17 | -------------------------------------------------------------------------------- /rc-app/src/test/java/org/rcdukes/test/app/TestApp.java: -------------------------------------------------------------------------------- 1 | package org.rcdukes.test.app; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | 5 | import org.junit.Test; 6 | 7 | import javafx.geometry.Pos; 8 | 9 | /** 10 | * test the JavaFX App 11 | * @author wf 12 | * 13 | */ 14 | public class TestApp { 15 | 16 | @Test 17 | public void testGeometry() { 18 | assertEquals(3,Pos.CENTER_LEFT.ordinal()); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /scripts/subdirs.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python2.7 2 | #https://askubuntu.com/a/779372/129227 3 | import os 4 | import sys 5 | 6 | # get the first command line argument 7 | src = sys.argv[1] 8 | for root, dirs, files in os.walk(src): 9 | for dr in dirs: 10 | directory = root+"/"+dr 11 | if len([sub for sub in os.listdir(directory) \ 12 | if os.path.isdir(directory+"/"+sub)]) == 0: 13 | print(directory) 14 | -------------------------------------------------------------------------------- /rc-action/src/main/java/stormbots/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * stormbots is part of the rc-action module 3 | * {@link MiniPID} implementation for a 4 | * Proportional–integral–derivative controller (PID controller. or three-term controller) 5 | * derived from https://github.com/stormbots/MiniPID-Java 6 | */ 7 | package stormbots; 8 | -------------------------------------------------------------------------------- /rc-geometry/src/main/java/org/rcdukes/geometry/pointinplane/PointInPlane.java: -------------------------------------------------------------------------------- 1 | package org.rcdukes.geometry.pointinplane; 2 | 3 | import org.rcdukes.geometry.Point2D; 4 | import org.rcdukes.geometry.Polygon; 5 | 6 | /** 7 | * Created by jpoint on 16/08/16. 8 | */ 9 | public interface PointInPlane { 10 | 11 | // enum State { 12 | // IN, 13 | // OUT 14 | // } 15 | 16 | boolean isPointInPlane(Point2D point, Polygon polygon); 17 | } 18 | -------------------------------------------------------------------------------- /rc-detect/src/main/java/org/rcdukes/detectors/LineDetector.java: -------------------------------------------------------------------------------- 1 | package org.rcdukes.detectors; 2 | 3 | import java.util.Collection; 4 | 5 | import org.opencv.core.Mat; 6 | import org.rcdukes.geometry.Line; 7 | 8 | /** 9 | * detector for lines 10 | */ 11 | public interface LineDetector { 12 | /** 13 | * detect lines from the given image 14 | * 15 | * @param image 16 | * @return - the lines found 17 | */ 18 | Collection detect(Mat image); 19 | } 20 | -------------------------------------------------------------------------------- /rc-camera-matrix/src/test/java/org/rcdukes/camera/TestSuite.java: -------------------------------------------------------------------------------- 1 | package org.rcdukes.camera; 2 | 3 | 4 | import org.junit.runner.RunWith; 5 | import org.junit.runners.Suite; 6 | 7 | @RunWith(Suite.class) 8 | @Suite.SuiteClasses({ TestCameraMatrix.class, TestPerspectiveShift.class }) 9 | /** 10 | * TestSuite for camera-matrix aka cooter 11 | * 12 | * @author wf 13 | * 14 | * no content necessary - annotation has info 15 | */ 16 | public class TestSuite { 17 | } 18 | -------------------------------------------------------------------------------- /rc-common/src/main/java/org/rcdukes/common/POJO.java: -------------------------------------------------------------------------------- 1 | package org.rcdukes.common; 2 | import io.vertx.core.json.JsonObject; 3 | 4 | /** 5 | * Plain old Java Object handling interface to be used with vert.x 6 | * @author wf 7 | * 8 | */ 9 | public interface POJO { 10 | 11 | public default String asJson() { 12 | return this.asJsonObject().toString(); 13 | } 14 | 15 | public default JsonObject asJsonObject() { 16 | return JsonObject.mapFrom(this); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /rc-common/src/main/java/org/rcdukes/common/EventbusLogger.java: -------------------------------------------------------------------------------- 1 | package org.rcdukes.common; 2 | 3 | import io.vertx.core.json.JsonObject; 4 | 5 | /** 6 | * Eventbus logging functions 7 | * @author wf 8 | * 9 | */ 10 | public interface EventbusLogger { 11 | /** 12 | * log the given Event 13 | * @param address 14 | * @param jo 15 | */ 16 | public void logEvent(String address,JsonObject jo); 17 | 18 | /** 19 | * log the given message 20 | * @param msg 21 | */ 22 | public void log(String msg); 23 | } 24 | -------------------------------------------------------------------------------- /rc-drivecontrol/src/main/java/org/rcdukes/car/ServoCommand.java: -------------------------------------------------------------------------------- 1 | package org.rcdukes.car; 2 | 3 | /** 4 | * sends servo commands for controlling Servos and LEDs 5 | * 6 | */ 7 | public interface ServoCommand { 8 | /** 9 | * set the servo with the given gpioPin to the given value 10 | * @param ioId - the input/output id of the servo - the numbering 11 | * scheme is implementation dependent 12 | * @param value - the (raw) value to set for the servo 13 | */ 14 | public void setServo(int ioId, int value); 15 | } 16 | -------------------------------------------------------------------------------- /rc-common/src/test/java/org/rcdukes/common/TestSuite.java: -------------------------------------------------------------------------------- 1 | package org.rcdukes.common; 2 | 3 | import org.junit.runner.RunWith; 4 | import org.junit.runners.Suite; 5 | 6 | @RunWith(Suite.class) 7 | @Suite.SuiteClasses({ TestErrorHandler.class,TestPOJO.class,TestCharacters.class,TestEnvironment.class, TestConfiguration.class,TestRxJava.class, TestClusterStarter.class }) 8 | /** 9 | * TestSuite for common aka hazard county 10 | * 11 | * @author wf 12 | * 13 | * no content necessary - annotation has info 14 | */ 15 | public class TestSuite { 16 | } 17 | -------------------------------------------------------------------------------- /rc-detect/src/main/java/org/rcdukes/detectors/StartLightDetector.java: -------------------------------------------------------------------------------- 1 | package org.rcdukes.detectors; 2 | 3 | import org.rcdukes.objects.StartLight; 4 | import org.rcdukes.video.Image; 5 | import org.rcdukes.video.ImageCollector; 6 | 7 | /** 8 | * start light detection 9 | */ 10 | public interface StartLightDetector { 11 | /** 12 | * detect a StartLight from the given image 13 | * @param image 14 | * @return the StartLight 15 | */ 16 | StartLight detect(Image image); 17 | 18 | StartLightDetector withImageCollector(ImageCollector imageCollector); 19 | } 20 | -------------------------------------------------------------------------------- /rc-detect/src/main/java/org/rcdukes/video/PointMapper.java: -------------------------------------------------------------------------------- 1 | package org.rcdukes.video; 2 | 3 | import org.opencv.core.Point; 4 | 5 | import org.rcdukes.geometry.Point2D; 6 | 7 | /** 8 | * map an rc dukes geometry point to an openCV point 9 | * 10 | */ 11 | public class PointMapper { 12 | 13 | /** 14 | * convert the given rc dukes geometry 2D point to an openCV point 15 | * @param point - the 2D Point 16 | * @return - the corresponding openCV point 17 | */ 18 | public static Point toPoint(Point2D point) { 19 | return new Point(point.getX(), point.getY()); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /rc-geometry/src/main/java/org/rcdukes/geometry/Point2D.java: -------------------------------------------------------------------------------- 1 | package org.rcdukes.geometry; 2 | 3 | /** 4 | * represents a 2 dimensional point 5 | * 6 | */ 7 | public interface Point2D { 8 | 9 | /** 10 | * getter for x coordinate 11 | * 12 | * @return x coordinate 13 | */ 14 | double getX(); 15 | 16 | /** 17 | * getter for y coordinate 18 | * @return y coordinate 19 | */ 20 | double getY(); 21 | 22 | /** 23 | * calculate the distance to another point 24 | * @param other 25 | * @return the distance 26 | */ 27 | double distance(Point2D other); 28 | 29 | } 30 | -------------------------------------------------------------------------------- /rc-common/src/main/java/org/rcdukes/common/Events.java: -------------------------------------------------------------------------------- 1 | package org.rcdukes.common; 2 | 3 | /** 4 | * relevant Events 5 | */ 6 | public enum Events { 7 | CAMERA_CONFIG_UPDATE, 8 | CANNY_CONFIG_UPDATE, 9 | HOUGH_CONFIG_UPDATE, 10 | CAMERA_MATRIX_UPDATE, 11 | START_LANE_DETECTION, 12 | LANE_DETECTED, 13 | START_STARTLIGHT_DETECTION, 14 | STARTLIGHT_DETECTED, 15 | START_DRAG_NAVIGATION, 16 | STOP_NAVIGATION, START_RECORDING, STOP_RECORDING, PHOTO_SHOOT, 17 | SIMULATOR_IMAGE, REQUEST_CONFIG, START_CAR, STOP_CAR, ECHO, 18 | ECHO_REPLY, CAR_POSITION, VIDEO_STOPPED 19 | } 20 | -------------------------------------------------------------------------------- /rc-drivecontrol/src/main/java/org/rcdukes/car/Led.java: -------------------------------------------------------------------------------- 1 | package org.rcdukes.car; 2 | 3 | /** 4 | * @author wf 5 | * 6 | */ 7 | public class Led extends Servo { 8 | private LedMap ledMap; 9 | 10 | /** 11 | * create me from the given LedMap 12 | * @param ledMap 13 | */ 14 | public Led(LedMap ledMap) { 15 | super(ledMap); 16 | this.ledMap=ledMap; 17 | } 18 | 19 | public void statusLedOn() { 20 | LOG.debug("Setting status led ON"); 21 | super.setServo(ledMap.ledOn()); 22 | } 23 | 24 | public void statusLedOff() { 25 | LOG.debug("Setting status led OFF"); 26 | super.setServo(ledMap.ledOff()); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /rc-geometry/src/main/java/org/rcdukes/geometry/Lane.java: -------------------------------------------------------------------------------- 1 | package org.rcdukes.geometry; 2 | 3 | import java.util.Optional; 4 | 5 | /** 6 | * a lane 7 | */ 8 | public class Lane { 9 | 10 | Optional leftBoundary; 11 | Optional rightBoundary; 12 | 13 | public Lane(Optional leftBoundary, Optional rightBoundary) { 14 | this.leftBoundary = leftBoundary; 15 | this.rightBoundary = rightBoundary; 16 | } 17 | 18 | public Optional getLeftBoundary() { 19 | return leftBoundary; 20 | } 21 | 22 | public Optional getRightBoundary() { 23 | return rightBoundary; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /rc-app/src/main/resources/fx/labeledvalueslider.fxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 18 | -------------------------------------------------------------------------------- /rc-detect/src/main/java/org/rcdukes/objects/stoppingzone/ZoneEndBoundary.java: -------------------------------------------------------------------------------- 1 | package org.rcdukes.objects.stoppingzone; 2 | 3 | import org.rcdukes.detect.linedetection.LineFilter; 4 | import org.rcdukes.objects.Boundary; 5 | 6 | public class ZoneEndBoundary extends Boundary { 7 | 8 | public static final double DEFAULT_ANGLE = 0; 9 | public static final double DEFAULT_TOLERANCE = 5; 10 | 11 | public ZoneEndBoundary() { 12 | this(DEFAULT_ANGLE, DEFAULT_TOLERANCE, false); 13 | } 14 | 15 | public ZoneEndBoundary(double angle, double margin, boolean directional) { 16 | super(new LineFilter(angle, margin, directional)); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /rc-detect/src/main/java/org/rcdukes/objects/StoppingZone.java: -------------------------------------------------------------------------------- 1 | package org.rcdukes.objects; 2 | 3 | import java.util.Optional; 4 | 5 | import org.rcdukes.geometry.Line; 6 | 7 | /** 8 | * Stopping Zone 9 | * 10 | */ 11 | public class StoppingZone { 12 | 13 | private Optional entrance; 14 | private Optional exit; 15 | 16 | public StoppingZone(Optional entrance, Optional exit) { 17 | this.entrance = entrance; 18 | this.exit = exit; 19 | } 20 | 21 | public Optional getEntrance() { 22 | return entrance; 23 | } 24 | 25 | public Optional getExit() { 26 | return exit; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /rc-common/src/main/java/org/rcdukes/common/ErrorHandler.java: -------------------------------------------------------------------------------- 1 | package org.rcdukes.common; 2 | 3 | import java.io.PrintWriter; 4 | import java.io.StringWriter; 5 | 6 | /** 7 | * error handling utility 8 | * @author wf 9 | * 10 | */ 11 | public class ErrorHandler { 12 | /** 13 | * get the stack trace for the given exception 14 | * 15 | * @param th 16 | * @return - the stack trace 17 | */ 18 | public static String getStackTraceText(Throwable th) { 19 | StringWriter sw = new StringWriter(); 20 | PrintWriter pw = new PrintWriter(sw); 21 | th.printStackTrace(pw); 22 | String exceptionText = sw.toString(); 23 | return exceptionText; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /rc-car/src/test/java/org/rcdukes/car/TestSuite.java: -------------------------------------------------------------------------------- 1 | package org.rcdukes.car; 2 | 3 | import org.junit.runner.RunWith; 4 | import org.junit.runners.Suite; 5 | 6 | @RunWith(Suite.class) 7 | @Suite.SuiteClasses({ TestHandlers.class }) 8 | /** 9 | * TestSuite for car aka Bo 10 | * 11 | * @author wf 12 | * 13 | * no content necessary - annotation has info 14 | */ 15 | public class TestSuite { 16 | /** 17 | * check if we are in the Travis-CI environment 18 | * 19 | * @return true if Travis user was detected 20 | */ 21 | public static boolean isTravis() { 22 | String user = System.getProperty("user.name"); 23 | return user.equals("travis"); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /rc-common/src/test/java/org/rcdukes/common/TestErrorHandler.java: -------------------------------------------------------------------------------- 1 | package org.rcdukes.common; 2 | 3 | import static org.junit.Assert.*; 4 | 5 | import org.junit.Test; 6 | 7 | /** 8 | * test the ErrorHandler 9 | * 10 | * @author wf 11 | */ 12 | public class TestErrorHandler { 13 | 14 | @Test 15 | public void testErrorHandler() { 16 | String trace=null; 17 | try { 18 | throw new Exception("oops - a problem"); 19 | } catch (Throwable th) { 20 | trace=ErrorHandler.getStackTraceText(th); 21 | } 22 | assertNotNull(trace); 23 | assertTrue(trace.contains("oops - a problem")); 24 | assertTrue(trace.contains("TestErrorHandler.java:18")); 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /rc-remotecar/src/test/java/org/rcdukes/remotecar/TestSuite.java: -------------------------------------------------------------------------------- 1 | package org.rcdukes.remotecar; 2 | 3 | import org.junit.runner.RunWith; 4 | import org.junit.runners.Suite; 5 | 6 | @RunWith(Suite.class) 7 | @Suite.SuiteClasses({ TestRemoteCar.class }) 8 | /** 9 | * TestSuite for detect aka daisy 10 | * 11 | * @author wf 12 | * 13 | * no content necessary - annotation has info 14 | */ 15 | public class TestSuite { 16 | /** 17 | * check if we are in the Travis-CI environment 18 | * 19 | * @return true if Travis user was detected 20 | */ 21 | public static boolean isTravis() { 22 | String user = System.getProperty("user.name"); 23 | return user.equals("travis"); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /rc-server/src/test/java/org/rcsdukes/server/TestSuite.java: -------------------------------------------------------------------------------- 1 | package org.rcsdukes.server; 2 | 3 | import org.junit.runner.RunWith; 4 | import org.junit.runners.Suite; 5 | 6 | @RunWith(Suite.class) 7 | @Suite.SuiteClasses({ TestEventBus.class, TestEventBusBridge.class }) 8 | /** 9 | * TestSuite for detect aka daisy 10 | * 11 | * @author wf 12 | * 13 | * no content necessary - annotation has info 14 | */ 15 | public class TestSuite { 16 | /** 17 | * check if we are in the Travis-CI environment 18 | * 19 | * @return true if Travis user was detected 20 | */ 21 | public static boolean isTravis() { 22 | String user = System.getProperty("user.name"); 23 | return user.equals("travis"); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /rc-drivecontrol/src/test/java/org/rcdukes/drivecontrol/TestSuite.java: -------------------------------------------------------------------------------- 1 | package org.rcdukes.drivecontrol; 2 | 3 | import org.junit.runner.RunWith; 4 | import org.junit.runners.Suite; 5 | 6 | @RunWith(Suite.class) 7 | @Suite.SuiteClasses({ TestCar.class,TestServoMaps.class }) 8 | /** 9 | * TestSuite for detect aka daisy 10 | * 11 | * @author wf 12 | * 13 | * no content necessary - annotation has info 14 | */ 15 | public class TestSuite { 16 | /** 17 | * check if we are in the Travis-CI environment 18 | * 19 | * @return true if Travis user was detected 20 | */ 21 | public static boolean isTravis() { 22 | String user = System.getProperty("user.name"); 23 | return user.equals("travis"); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /rc-imageview/src/test/java/org/rcdukes/imageview/TestSuite.java: -------------------------------------------------------------------------------- 1 | package org.rcdukes.imageview; 2 | 3 | import org.junit.runner.RunWith; 4 | import org.junit.runners.Suite; 5 | 6 | @RunWith(Suite.class) 7 | @Suite.SuiteClasses({ TestVideoRecorder.class, TestDebugImageServer.class }) 8 | /** 9 | * TestSuite for detect aka daisy 10 | * 11 | * @author wf 12 | * 13 | * no content necessary - annotation has info 14 | */ 15 | public class TestSuite { 16 | /** 17 | * check if we are in the Travis-CI environment 18 | * 19 | * @return true if Travis user was detected 20 | */ 21 | public static boolean isTravis() { 22 | String user = System.getProperty("user.name"); 23 | return user.equals("travis"); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /rc-app/src/main/resources/fx/dukes.css: -------------------------------------------------------------------------------- 1 | .root{ 2 | -fx-font-size: 12pt; 3 | -fx-font-family: "Helvetica"; 4 | -icons-color: black; 5 | } 6 | .header { 7 | -fx-background-color: #3F51B5; 8 | -fx-padding: 4 4 4 4; 9 | } 10 | .headertext { 11 | -fx-fill: white; 12 | -fx-stroke: white; 13 | } 14 | 15 | .glyph-icon{ 16 | -fx-text-fill: -icons-color; 17 | -fx-fill: -icons-color; 18 | -glyph-size: 36px; 19 | } 20 | 21 | .glyph-icon:hover{ 22 | // -fx-fill: white; 23 | // https://openjfx.io/javadoc/11/javafx.graphics/javafx/scene/doc-files/cssref.html#typeeffect 24 | -fx-effect: dropshadow(three-pass-box, rgba(80,80,80,0.5), 10, 0.2, 4, 4); 25 | } 26 | 27 | .glyph-icon:pressed{ 28 | -fx-fill: black; 29 | } 30 | 31 | 32 | -------------------------------------------------------------------------------- /rc-geometry/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | 8 | org.rcdukes 9 | dukes 10 | 0.0.3 11 | 12 | 13 | org.rcdukes.dukes 14 | rc-geometry 15 | Geometry 16 | 17 | 18 | junit 19 | junit 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /rc-detect/src/test/java/org/rcdukes/detect/TestCannyConfig.java: -------------------------------------------------------------------------------- 1 | package org.rcdukes.detect; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | 5 | import org.junit.Test; 6 | import org.rcdukes.detect.edgedectection.CannyEdgeDetector; 7 | 8 | import io.vertx.core.json.JsonObject; 9 | 10 | public class TestCannyConfig { 11 | 12 | @Test 13 | public void testCannyConfig() { 14 | String json="{\n" + 15 | " \"threshold1\" : 87,\n" + 16 | " \"threshold2\" : 150\n" + 17 | "}"; 18 | JsonObject jo=new JsonObject(json); 19 | CannyEdgeDetector detector = jo.mapTo(CannyEdgeDetector.class); 20 | assertEquals(87,detector.getThreshold1(),0.1); 21 | assertEquals(150,detector.getThreshold2(),0.1); 22 | 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /rc-camera-matrix/src/test/java/org/rcdukes/camera/MatrixTestbase.java: -------------------------------------------------------------------------------- 1 | package org.rcdukes.camera; 2 | 3 | import org.junit.BeforeClass; 4 | import org.rcdukes.opencv.NativeLibrary; 5 | 6 | /** 7 | * common parts of opencv Matrix based tests 8 | * @author wf 9 | * 10 | */ 11 | public class MatrixTestbase { 12 | @BeforeClass 13 | public static void setup() throws Exception { 14 | NativeLibrary.load(); 15 | } 16 | 17 | String basePath = "./"; 18 | public static boolean debug=true; 19 | /** 20 | * check if we are in the Travis-CI environment 21 | * 22 | * @return true if Travis user was detected 23 | */ 24 | public boolean isTravis() { 25 | String user = System.getProperty("user.name"); 26 | return user.equals("travis"); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /rc-action/src/test/java/org/rcdukes/action/TestSuite.java: -------------------------------------------------------------------------------- 1 | package org.rcdukes.action; 2 | 3 | 4 | import org.junit.runner.RunWith; 5 | import org.junit.runners.Suite; 6 | 7 | @RunWith(Suite.class) 8 | @Suite.SuiteClasses({ TestAction.class, TestMiniPID.class,TestStraightLaneNavigator.class }) 9 | /** 10 | * TestSuite for action aka luke 11 | * 12 | * @author wf 13 | * 14 | * no content necessary - annotation has info 15 | */ 16 | public class TestSuite { 17 | public static boolean debug=false; 18 | /** 19 | * check if we are in the Travis-CI environment 20 | * 21 | * @return true if Travis user was detected 22 | */ 23 | public static boolean isTravis() { 24 | String user = System.getProperty("user.name"); 25 | return user.equals("travis"); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /rc-detect/src/main/java/org/rcdukes/objects/Boundary.java: -------------------------------------------------------------------------------- 1 | package org.rcdukes.objects; 2 | 3 | import static java.util.Optional.ofNullable; 4 | 5 | import java.util.Collection; 6 | import java.util.Optional; 7 | 8 | import org.rcdukes.detect.linedetection.LineFilter; 9 | import org.rcdukes.geometry.Line; 10 | 11 | /** 12 | * a Boundary 13 | */ 14 | public class Boundary { 15 | 16 | private LineFilter filter; 17 | 18 | public Boundary(LineFilter filter) { 19 | this.filter = filter; 20 | } 21 | 22 | public Optional boundary(Collection lines) { 23 | return ofNullable(Line.average(candidates(lines))); 24 | } 25 | 26 | public Collection candidates(Collection lines) { 27 | return filter.filter(lines); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /rc-detect/src/test/java/org/rcdukes/detect/TestSuite.java: -------------------------------------------------------------------------------- 1 | package org.rcdukes.detect; 2 | 3 | import org.junit.runner.RunWith; 4 | import org.junit.runners.Suite; 5 | 6 | @RunWith(Suite.class) 7 | @Suite.SuiteClasses({ TestCannyConfig.class,TestLaneDetection.class,TestImageCollector.class,TestImageFetcher.class,TestHoughLinesDetector.class }) 8 | /** 9 | * TestSuite for detect aka daisy 10 | * 11 | * @author wf 12 | * 13 | * no content necessary - annotation has info 14 | */ 15 | public class TestSuite { 16 | /** 17 | * check if we are in the Travis-CI environment 18 | * 19 | * @return true if Travis user was detected 20 | */ 21 | public static boolean isTravis() { 22 | String user = System.getProperty("user.name"); 23 | return user.equals("travis"); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /rc-detect/src/test/java/org/rcdukes/detect/BaseDetectTest.java: -------------------------------------------------------------------------------- 1 | package org.rcdukes.detect; 2 | 3 | import org.junit.BeforeClass; 4 | import org.opencv.core.Mat; 5 | import org.rcdukes.opencv.NativeLibrary; 6 | import org.rcdukes.video.ImageUtils; 7 | 8 | /** 9 | * base class for detection tests 10 | * 11 | * @author wf 12 | * 13 | */ 14 | public class BaseDetectTest { 15 | boolean debug = true; 16 | 17 | @BeforeClass 18 | public static void setup() throws Exception { 19 | NativeLibrary.load(); 20 | } 21 | 22 | /** 23 | * get a test image 24 | * @return the test image 25 | * @throws Exception 26 | */ 27 | public Mat getTestImage() throws Exception { 28 | String imagePath="images/road.jpg"; 29 | Mat frame = ImageUtils.fromResource(this.getClass(), imagePath); 30 | return frame; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /rc-detect/src/main/java/org/rcdukes/detect/edgedectection/SobelEdgeDetector.java: -------------------------------------------------------------------------------- 1 | package org.rcdukes.detect.edgedectection; 2 | 3 | import org.opencv.core.Mat; 4 | import org.opencv.imgproc.Imgproc; 5 | import org.rcdukes.detectors.EdgeDetector; 6 | 7 | import static org.opencv.core.CvType.CV_8UC1; 8 | 9 | public class SobelEdgeDetector implements EdgeDetector { 10 | 11 | int ddepth = CV_8UC1; 12 | int dx = 2; 13 | int dy = 2; 14 | 15 | public SobelEdgeDetector() {} 16 | 17 | public SobelEdgeDetector(int ddepth, int dx, int dy) { 18 | this.ddepth = ddepth; 19 | this.dx = dx; 20 | this.dy = dy; 21 | } 22 | 23 | @Override 24 | public Mat detect(Mat image) { 25 | Mat imgEdges = new Mat(); 26 | Imgproc.Sobel(image, imgEdges, ddepth, dx, dy); 27 | return imgEdges; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /rc-detect/src/main/java/org/rcdukes/objects/ViewPort.java: -------------------------------------------------------------------------------- 1 | package org.rcdukes.objects; 2 | 3 | import org.rcdukes.geometry.Point2D; 4 | 5 | /** 6 | * a viewport 7 | * 8 | */ 9 | public class ViewPort { 10 | 11 | private Point2D origin; 12 | private double width; 13 | private double height; 14 | 15 | 16 | /** 17 | * construct me 18 | * @param origin 19 | * @param width 20 | * @param height 21 | */ 22 | public ViewPort(Point2D origin, double width, double height) { 23 | this.origin = origin; 24 | this.width = width; 25 | this.height = height; 26 | } 27 | 28 | public Point2D getOrigin() { 29 | return origin; 30 | } 31 | 32 | public double getWidth() { 33 | return width; 34 | } 35 | 36 | public double getHeight() { 37 | return height; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /rc-detect/src/main/java/org/rcdukes/detect/stopzonedetection/DefaultStoppingZoneDetector.java: -------------------------------------------------------------------------------- 1 | package org.rcdukes.detect.stopzonedetection; 2 | 3 | import org.rcdukes.geometry.Line; 4 | import org.rcdukes.objects.StoppingZone; 5 | import org.rcdukes.objects.stoppingzone.ZoneEndBoundary; 6 | import org.rcdukes.objects.stoppingzone.ZoneStartBoundary; 7 | 8 | import java.util.Collection; 9 | import java.util.Optional; 10 | 11 | public class DefaultStoppingZoneDetector implements StoppingZoneDetector { 12 | 13 | 14 | @Override 15 | public StoppingZone detect(Collection lines) { 16 | Optional endLine = new ZoneEndBoundary().boundary(lines); 17 | Optional startLine = new ZoneStartBoundary().boundary(lines); 18 | 19 | StoppingZone stoppingZone = new StoppingZone(startLine, endLine); 20 | return stoppingZone; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | # use 16.04 2 | dist: xenial 3 | # this is a java project using maven 4 | language: java 5 | # we'll get java 11 or higher if we don't do this 6 | jdk: 7 | - openjdk8 8 | # switch off gpg handling 9 | # clean is mandatory to get opencv jar integrated 10 | # -D jacoco switches on code coverage 11 | install: 12 | - mvn clean install -D jacoco -Dgpg.skip=true 13 | # We need GraphViz to get uml diagrams with javadoc 14 | before_install: 15 | - sudo apt-get install graphviz openjfx 16 | # we need to install opencv 17 | # by compiling from source (takes some 15 minutes ...) 18 | # if you comment this out some tests will fail 19 | # so you might want to add -D skipTests above 20 | - scripts/opencvubuntu 21 | # see https://github.com/trautonen/coveralls-maven-plugin 22 | # put the coverage results on codecov.io 23 | after_success: 24 | - bash <(curl -s https://codecov.io/bash) 25 | -------------------------------------------------------------------------------- /rc-roi/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | 8 | org.rcdukes 9 | dukes 10 | 0.0.3 11 | 12 | 13 | 14 | org.rcdukes.dukes 15 | rc-roi 16 | Region of Interest 17 | 18 | 19 | 20 | org.opencv 21 | opencv-jar 22 | 23 | 24 | junit 25 | junit 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /rc-detect/src/main/java/org/rcdukes/video/DenoiseByBlur.java: -------------------------------------------------------------------------------- 1 | package org.rcdukes.video; 2 | 3 | import org.opencv.core.Mat; 4 | import org.opencv.core.Size; 5 | import org.opencv.imgproc.Imgproc; 6 | 7 | /** 8 | * denoise an image by blurring it 9 | * 10 | */ 11 | public class DenoiseByBlur { 12 | 13 | private int kWidth = 3; 14 | private int kHeight = 3; 15 | 16 | public DenoiseByBlur() {} 17 | 18 | /** 19 | * construct me with given widt and height parameters 20 | * @param kWidth 21 | * @param kHeight 22 | */ 23 | public DenoiseByBlur(int kWidth, int kHeight) { 24 | this(); 25 | this.kWidth = kWidth; 26 | this.kHeight = kHeight; 27 | } 28 | 29 | /** 30 | * apply my 31 | * @param image 32 | * @return 33 | */ 34 | public Mat denoise(Mat image) { 35 | Imgproc.blur(image, image, new Size(kWidth, kHeight)); 36 | return image; 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 1.7 18 | 19 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /rc-drivecontrol/src/main/java/org/rcdukes/car/ServoMap.java: -------------------------------------------------------------------------------- 1 | package org.rcdukes.car; 2 | 3 | import org.rcdukes.common.ServoPosition; 4 | 5 | /** 6 | * settings for a Servo 7 | * @author wf 8 | * 9 | */ 10 | public interface ServoMap { 11 | // gpioPin that controls the servo 12 | int gpioPin(); 13 | // command interface e.g. ServoBlaster or Adafruit servo shield 14 | ServoCommand servoCommand(); 15 | // return true if the orientation is turned (+) 16 | boolean turnedOrientation(); 17 | public ServoPosition getCurrentPosition(); 18 | public ServoPosition newPosition(ServoPosition newPosition); 19 | /** 20 | * configure the given servoMap 21 | * @param gpioPin - the gpio pin to use 22 | * @param servoCommand 23 | * @param orientation - do we have to switch left/right or forward/reverse commands +: do not switch -:switch 24 | */ 25 | public void configure(int gpioPin,ServoCommand servoCommand, String orientation); 26 | public void configureOrientation(); 27 | } 28 | -------------------------------------------------------------------------------- /dukes.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /rc-drivecontrol/src/main/java/org/rcdukes/car/ServoRangeMap.java: -------------------------------------------------------------------------------- 1 | package org.rcdukes.car; 2 | 3 | import org.rcdukes.common.ServoPosition; 4 | 5 | /** 6 | * a range based map 7 | * @author wf 8 | * 9 | */ 10 | public interface ServoRangeMap extends ServoMap { 11 | /** 12 | * get the range for this map 13 | * @return - the range 14 | */ 15 | public ServoRange getRange(); 16 | /** 17 | * return a servo position for the given percentual value 18 | * @param percent 19 | * @return the ServoPosition 20 | */ 21 | public ServoPosition atPercent(double percent); 22 | 23 | /** 24 | * return a servo position close to the given value 25 | * @param value 26 | * @return - the servoPosition 27 | */ 28 | public ServoPosition atValue(double value); 29 | /** 30 | * step the given number of steps -1, 1 31 | * @param servoStep 32 | */ 33 | public void step(int servoStep); 34 | /** 35 | * set the zero/center position 36 | */ 37 | public void setZero(); 38 | 39 | } 40 | -------------------------------------------------------------------------------- /rc-common/src/main/java/org/rcdukes/common/GraphDatabase.java: -------------------------------------------------------------------------------- 1 | package org.rcdukes.common; 2 | 3 | import java.io.File; 4 | 5 | import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; 6 | import org.apache.tinkerpop.gremlin.structure.Vertex; 7 | 8 | public interface GraphDatabase { 9 | /** 10 | * access the graph database 11 | * @return the graph traversal source 12 | */ 13 | public GraphTraversalSource g(); 14 | 15 | /** 16 | * write me to the given path 17 | * @param path 18 | */ 19 | public void writeGraph(String path); 20 | 21 | /** 22 | * load the given graphFile 23 | * @param graphFile 24 | */ 25 | public void loadGraph(File graphFile); 26 | /** 27 | * get an object from the given vertex 28 | * @param v 29 | * @param clazz 30 | * @return the object 31 | */ 32 | public T fromVertex(Vertex v,Class clazz); 33 | /** 34 | * add the given object as a vertex 35 | * @param o 36 | */ 37 | public void addVertex(Object o); 38 | } 39 | -------------------------------------------------------------------------------- /rc-drivecontrol/src/main/java/org/rcdukes/car/Servo.java: -------------------------------------------------------------------------------- 1 | package org.rcdukes.car; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | 6 | /** 7 | * common base class for Servos 8 | * @author wf 9 | * 10 | */ 11 | public class Servo { 12 | 13 | protected static final Logger LOG = LoggerFactory.getLogger(Servo.class); 14 | protected ServoMap servoMap; 15 | private int value; 16 | 17 | /** 18 | * construct this servo with the given Command interface and gpioPin 19 | * @param servoMap - configuration for interface an pin 20 | */ 21 | public Servo(ServoMap servoMap) { 22 | this.servoMap=servoMap; 23 | } 24 | 25 | /** 26 | * set the servo to the given value 27 | * @param value - the value to use 28 | */ 29 | public void setServo(int value) { 30 | // servo command and pin are configurable 31 | this.servoMap.servoCommand().setServo(this.servoMap.gpioPin(), value); 32 | this.value=value; 33 | } 34 | 35 | public int getServo() { 36 | return value; 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /scripts/createpackageinfos: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # WF 2019-06-26 3 | # create package-info.java files 4 | 5 | # 6 | # the template to be use 7 | # 8 | template() { 9 | local l_package="$1" 10 | local l_module="$2" 11 | local l_desc="$3" 12 | cat << EOF 13 | /** 14 | * $l_package is part of the $l_module module 15 | * $l_desc 16 | */ 17 | package $l_package; 18 | EOF 19 | } 20 | # 21 | # create inital package-info.java files 22 | # 23 | initialforempty() { 24 | mydir=$(dirname $0) 25 | for src in $(find . -name java -type d | grep "src/main/java") 26 | do 27 | module=$(echo $src | cut -f2 -d /) 28 | echo $module:$src 29 | # https://stackoverflow.com/a/27629943/1497139 30 | for packagepath in $($mydir/subdirs.py $src) 31 | do 32 | package=$(echo "${packagepath#$src/}" | sed 's/\//./g') 33 | pinfo=$packagepath/package-info.java 34 | if [ ! -f $pinfo ] 35 | then 36 | template $package $module "@TODO - add description" > $pinfo 37 | fi 38 | echo " $package: " 39 | cat $pinfo 40 | done 41 | done 42 | } 43 | 44 | initialforempty 45 | -------------------------------------------------------------------------------- /rc-app/src/main/java/org/rcdukes/app/GUIDisplayer.java: -------------------------------------------------------------------------------- 1 | package org.rcdukes.app; 2 | 3 | import org.opencv.core.Mat; 4 | import org.rcdukes.video.Image; 5 | import org.rcdukes.video.ImageCollector; 6 | import org.rcdukes.video.VideoRecorders; 7 | 8 | import javafx.beans.property.Property; 9 | 10 | /** 11 | * interface to make core gui display available for subGUIs 12 | * 13 | */ 14 | public interface GUIDisplayer { 15 | enum PictureStep{FIRST,PREV,NEXT,FORWARD}; 16 | void displayOriginal(Image image); 17 | void displayOriginal( Mat openCvImage); 18 | void display1(Image image); 19 | void display2(Image image); 20 | void display3(Image image); 21 | void displayImageCollector(ImageCollector collector); 22 | void setImageCollector(ImageCollector imageCollector); 23 | void setMessageText(String text); 24 | void setCameraButtonText(String text); 25 | void setVideoRecorders(VideoRecorders videoRecorders); 26 | Property getStartVideoProperty(); 27 | void showFrameIndex(long frameIndex); 28 | /** 29 | * handle the given error 30 | * @param th 31 | */ 32 | void handle(Throwable th); 33 | 34 | 35 | } 36 | -------------------------------------------------------------------------------- /rc-app/src/main/resources/fx/camera.fxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /scripts/coverage: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # WF 2019-06-26 3 | 4 | # 5 | # create test coverage report for coveralls 6 | # this didn't work as of 2019-07-01 7 | # 8 | coveralls() { 9 | # is the environment variable not set? 10 | if [ "$COVERALLS_TOKEN" = "" ] 11 | then 12 | tokenpath=$HOME/.dukes/coveralls.token 13 | if [ ! -f $tokenpath ] 14 | then 15 | echo "Script needs coveralls token in $tokenpath to or COVERALLS_TOKEN environment variable to work" 1>&2 16 | echo "Script can only be run successfully by project admins" 1>&2 17 | echo "see https://github.com/trautonen/coveralls-maven-plugin" 1>&2 18 | echo "see https://stackoverflow.com/a/56815300/1497139" 1>&2 19 | exit 1 20 | fi 21 | else 22 | export COVERALLS_TOKEN=$(cat $tokenpath) 23 | fi 24 | # the jacoco variable tries triggering a profile - check your pom.xml 25 | # for any profile being in use 26 | mvn clean test jacoco:report coveralls:report -D jacoco=true 27 | mvn clean test jacoco:report coveralls:report -D jacoco=true -DrepoToken=$token 28 | #mvn cobertura:cobertura coveralls:report 29 | #mvn cobertura:cobertura coveralls:report -DrepoToken=$COVERALLS_TOKEN 30 | } 31 | 32 | mvn clean test -D jacoco -D gpg.skip 33 | -------------------------------------------------------------------------------- /rc-detect/src/main/java/org/rcdukes/objects/stoppingzone/ZoneStartBoundary.java: -------------------------------------------------------------------------------- 1 | package org.rcdukes.objects.stoppingzone; 2 | 3 | import org.rcdukes.detect.linedetection.LineFilter; 4 | import org.rcdukes.geometry.Line; 5 | import org.rcdukes.objects.Boundary; 6 | 7 | import java.util.Collection; 8 | import java.util.Comparator; 9 | import java.util.Optional; 10 | 11 | public class ZoneStartBoundary extends Boundary { 12 | 13 | public static final double DEFAULT_ANGLE = 0; 14 | public static final double DEFAULT_TOLERANCE = 5; 15 | 16 | public ZoneStartBoundary() { 17 | this(DEFAULT_ANGLE, DEFAULT_TOLERANCE, false); 18 | } 19 | 20 | public ZoneStartBoundary(double angle, double margin, boolean directional) { 21 | super(new LineFilter(angle, margin, directional)); 22 | } 23 | 24 | public Optional boundary(Collection lines) { 25 | Comparator lineComparator = (line1, line2) -> Double.compare(line1.bottomMost().getY(), line2.bottomMost().getY()); 26 | lineComparator.reversed(); 27 | Optional nearest = candidates(lines).stream().sorted(lineComparator.reversed()).findFirst(); 28 | return nearest; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /rc-geometry/src/main/java/org/rcdukes/geometry/LaneDetectionResult.java: -------------------------------------------------------------------------------- 1 | package org.rcdukes.geometry; 2 | 3 | /** 4 | * Lane Detection Result 5 | * @author wf 6 | * 7 | */ 8 | public class LaneDetectionResult { 9 | 10 | public static boolean forceError=false; 11 | public Double left; 12 | public Double middle; 13 | public Double right; 14 | public Double distanceMiddle; 15 | public Double distanceLeft; 16 | public Double distanceRight; 17 | public Double courseRelativeToHorizon; 18 | public Double distanceToStoppingZone; 19 | public Double distanceToStoppingZoneEnd; 20 | public int frameIndex; 21 | public long milliTimeStamp; 22 | 23 | public void checkError() { 24 | if (forceError) 25 | throw new RuntimeException("error forced to debug"); 26 | } 27 | 28 | /** 29 | * get the debug info for me 30 | * @return - a string with navigation info 31 | */ 32 | public String debugInfo() { 33 | String msg=String.format("\n left: %s\nmiddle: %s\n right: %s\ncourse: %s", Line.angleString(left),Line.angleString(middle),Line.angleString(right),courseRelativeToHorizon==null?"?":Line.angleString(Math.toDegrees(courseRelativeToHorizon))); 34 | return msg; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /rc-app/src/main/resources/fx/startlightdetection.fxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /rc-detect/src/main/java/org/rcdukes/objects/StartLight.java: -------------------------------------------------------------------------------- 1 | package org.rcdukes.objects; 2 | 3 | /** 4 | * enumeration representing the StartLight state machine 5 | * 6 | */ 7 | public enum StartLight { 8 | OFF { 9 | @Override 10 | public StartLight off() { 11 | return OFF; 12 | } 13 | }, 14 | LIT { 15 | @Override 16 | public StartLight off() { 17 | nrOfOffs++; 18 | if (nrOfOffs >= DIMMED_DETECTION_THRESHOLD) { 19 | return DIMMED; 20 | } else { 21 | return this; 22 | } 23 | } 24 | }, 25 | DIMMED { 26 | @Override 27 | public StartLight on() { 28 | return DIMMED; 29 | } 30 | 31 | @Override 32 | public boolean started() { 33 | return true; 34 | } 35 | }; 36 | 37 | private static final int DIMMED_DETECTION_THRESHOLD = 3; 38 | protected int nrOfOffs = 0; 39 | 40 | public static StartLight init() { 41 | return OFF; 42 | } 43 | 44 | public StartLight on() { 45 | nrOfOffs = 0; 46 | return LIT; 47 | } 48 | 49 | public StartLight off() { 50 | return DIMMED; 51 | } 52 | 53 | public boolean started() { 54 | return false; 55 | } 56 | } -------------------------------------------------------------------------------- /rc-remotecar/src/test/java/org/rcdukes/remotecar/TestRemoteCar.java: -------------------------------------------------------------------------------- 1 | package org.rcdukes.remotecar; 2 | 3 | import org.junit.Test; 4 | import org.rcdukes.common.Characters; 5 | import org.rcdukes.common.ClusterStarter; 6 | import org.rcdukes.common.Config; 7 | import org.rcdukes.common.DukesVerticle; 8 | import org.rcdukes.common.DukesVerticle.Status; 9 | import org.rcdukes.common.Environment; 10 | 11 | import io.vertx.core.json.JsonObject; 12 | 13 | /** 14 | * test the remote car handling 15 | * 16 | * @author wf 17 | * 18 | */ 19 | public class TestRemoteCar { 20 | 21 | @Test 22 | public void testRemoteCar() throws Exception { 23 | Environment.mock(); 24 | ClusterStarter clusterStarter = new ClusterStarter(); 25 | clusterStarter.prepare(); 26 | RemoteCar remoteCar = new RemoteCar(); 27 | clusterStarter.deployVerticles(remoteCar); 28 | DukesVerticle.debug=true; 29 | remoteCar.waitStatus(Status.started, ClusterStarter.MAX_START_TIME, 10); 30 | 31 | JsonObject configJo=Config.getEnvironment().asJsonObject(); 32 | remoteCar.send(Characters.GENERAL_LEE,configJo); 33 | Thread.sleep(ClusterStarter.MAX_START_TIME); 34 | } 35 | 36 | @Test 37 | public void testRemoteCarCommandLine() { 38 | Environment.mock(); 39 | String args[]= {}; 40 | RemoteCar.main(args); 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /rc-action/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | org.rcdukes 8 | dukes 9 | 0.0.3 10 | 11 | 12 | org.rcdukes.dukes 13 | rc-action 14 | Processing image analysis results into actions 15 | 16 | 17 | io.vertx 18 | vertx-rx-java 19 | 20 | 21 | org.rcdukes.dukes 22 | rc-common 23 | 0.0.3 24 | 25 | 26 | org.rcdukes.dukes 27 | rc-geometry 28 | 0.0.3 29 | 30 | 31 | org.rcdukes.dukes 32 | rc-detect 33 | 0.0.3 34 | 35 | 36 | ch.qos.logback 37 | logback-classic 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /rc-detect/src/main/java/org/rcdukes/objects/lane/LaneRightBoundary.java: -------------------------------------------------------------------------------- 1 | package org.rcdukes.objects.lane; 2 | 3 | import org.rcdukes.detect.linedetection.LineFilter; 4 | import org.rcdukes.geometry.Line; 5 | import org.rcdukes.objects.Boundary; 6 | 7 | import java.util.Collection; 8 | import java.util.Comparator; 9 | import java.util.Optional; 10 | 11 | public class LaneRightBoundary extends Boundary { 12 | 13 | public static final double DEFAULT_ANGLE = BoundaryDefaults.DEFAULT_LANE_BOUNDARY_ANGLE; 14 | public static final double DEFAULT_TOLERANCE = BoundaryDefaults.DEFAULT_LANE_BOUNDARY_TOLERANCE; 15 | 16 | public LaneRightBoundary() { 17 | this(DEFAULT_ANGLE, DEFAULT_TOLERANCE, false); 18 | } 19 | 20 | public LaneRightBoundary(double angle, double margin, boolean directional) { 21 | super(new LineFilter(angle, margin, directional)); 22 | } 23 | 24 | public Optional boundary(Collection lines) { 25 | Comparator yComparator = (line1, line2) -> Double.compare(line1.bottomMost().getY(), line2.bottomMost().getY()); 26 | Comparator xComparator = (line1, line2) -> Double.compare(line1.bottomMost().getX(), line2.bottomMost().getX()); 27 | Comparator lineComparator = yComparator.thenComparing(xComparator.reversed()); 28 | Optional nearest = candidates(lines).stream().sorted(lineComparator).findFirst(); 29 | return nearest; 30 | } 31 | } -------------------------------------------------------------------------------- /rc-common/src/test/java/org/rcdukes/common/TestRxJava.java: -------------------------------------------------------------------------------- 1 | package org.rcdukes.common; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | import static org.junit.Assert.assertFalse; 5 | import static org.junit.Assert.assertNotNull; 6 | import static org.junit.Assert.assertTrue; 7 | 8 | import java.util.ArrayList; 9 | import java.util.List; 10 | 11 | import org.junit.Test; 12 | 13 | import rx.Observable; 14 | import rx.Subscription; 15 | 16 | public class TestRxJava { 17 | @Test 18 | public void testSubscribe() { 19 | List lens=new ArrayList(); 20 | Observable o = Observable.just("one", "ten", "hundred", "thousand"); 21 | Observable m = o.map(String::length); 22 | Observable f = m.filter(it -> it > 6); 23 | Subscription s = f.subscribe(l -> lens.add(l)); 24 | assertNotNull(s); 25 | assertTrue(s.isUnsubscribed()); 26 | assertEquals(2,lens.size()); 27 | assertEquals(Integer.valueOf(7),lens.get(0)); 28 | assertEquals(Integer.valueOf(8),lens.get(1)); 29 | } 30 | @Test 31 | public void testSubscribeOneLiner() { 32 | List lens=new ArrayList(); 33 | Observable.just("one", "ten", "hundred", "thousand") 34 | .map(String::length) 35 | .filter(it -> it > 6) 36 | .subscribe(l -> lens.add(l)); 37 | assertEquals(2,lens.size()); 38 | assertEquals(Integer.valueOf(7),lens.get(0)); 39 | assertEquals(Integer.valueOf(8),lens.get(1)); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /rc-detect/src/main/java/org/rcdukes/objects/lane/LaneLeftBoundary.java: -------------------------------------------------------------------------------- 1 | package org.rcdukes.objects.lane; 2 | 3 | import org.rcdukes.detect.linedetection.LineFilter; 4 | import org.rcdukes.geometry.Line; 5 | import org.rcdukes.objects.Boundary; 6 | 7 | import java.util.Collection; 8 | import java.util.Comparator; 9 | import java.util.Optional; 10 | 11 | public class LaneLeftBoundary extends Boundary { 12 | 13 | public static final double DEFAULT_ANGLE = -BoundaryDefaults.DEFAULT_LANE_BOUNDARY_ANGLE; 14 | public static final double DEFAULT_TOLERANCE = BoundaryDefaults.DEFAULT_LANE_BOUNDARY_TOLERANCE; 15 | 16 | public LaneLeftBoundary() { 17 | this(DEFAULT_ANGLE, DEFAULT_TOLERANCE, false); 18 | } 19 | 20 | public LaneLeftBoundary(double angle, double margin, boolean directional) { 21 | super(new LineFilter(angle, margin, directional)); 22 | } 23 | 24 | public Optional boundary(Collection lines) { 25 | Comparator yComparator = (line1, line2) -> Double.compare(line1.bottomMost().getY(), line2.bottomMost().getY()); 26 | Comparator xComparator = (line1, line2) -> Double.compare(line1.bottomMost().getX(), line2.bottomMost().getX()); 27 | Comparator lineComparator = yComparator.thenComparing(xComparator); 28 | Optional nearest = candidates(lines).stream().sorted(lineComparator).findFirst(); 29 | return nearest; 30 | // return Line.average(candidates(lines)); 31 | } 32 | } -------------------------------------------------------------------------------- /rc-webcontrol/src/main/resources/web/bootstrap.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | Hello, world! 13 | 14 | 15 | 16 |
17 |
18 |
19 | left 20 |
21 |
22 | right 23 |
24 |
25 |
26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /rc-webcontrol/src/main/java/org/rcdukes/webcontrol/WebControl.java: -------------------------------------------------------------------------------- 1 | package org.rcdukes.webcontrol; 2 | 3 | import org.rcdukes.common.Characters; 4 | import org.rcdukes.common.Config; 5 | import org.rcdukes.common.DukesVerticle; 6 | import org.rcdukes.common.Environment; 7 | import org.rcdukes.common.WebStarter; 8 | 9 | import io.vertx.rxjava.ext.web.Router; 10 | import io.vertx.rxjava.ext.web.handler.StaticHandler; 11 | 12 | /** 13 | * Manual UI web based control (Boss Hogg) 14 | * 15 | */ 16 | public class WebControl extends DukesVerticle { 17 | 18 | /** 19 | * construct me 20 | */ 21 | public WebControl() { 22 | super(Characters.BOSS_HOGG); 23 | } 24 | 25 | @Override 26 | public void start() throws Exception { 27 | super.preStart(); 28 | int port = Config.getEnvironment().getInteger(Config.WEBCONTROL_PORT); 29 | WebStarter webStarter=new WebStarter(vertx,port); 30 | webStarter.mountEventBus(".*", ".*"); 31 | // @TODO decide about sse support for configuration 32 | // router.route("/configsse/*") 33 | Router router = webStarter.getRouter(); 34 | router.route() 35 | .handler(StaticHandler.create("web").setCachingEnabled(false)); 36 | String media = Environment.dukesHome + "media"; 37 | router.route("/media/*") 38 | .handler(StaticHandler.create().setAllowRootFileSystemAccess(true) 39 | .setWebRoot(media).setCachingEnabled(false) 40 | .setDirectoryListing(true)); 41 | webStarter.startHttpServer(); 42 | super.postStart(); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /rc-imageview/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | org.rcdukes 8 | dukes 9 | 0.0.3 10 | 11 | 12 | org.rcdukes.dukes 13 | rc-imageview 14 | Lane detection debug image web server 15 | 16 | 17 | io.vertx 18 | vertx-rx-java 19 | 20 | 21 | 22 | io.reactivex 23 | rxjava-string 24 | 25 | 26 | org.rcdukes.dukes 27 | rc-common 28 | 0.0.3 29 | 30 | 31 | ch.qos.logback 32 | logback-classic 33 | 34 | 35 | org.opencv 36 | opencv-jar 37 | 38 | 39 | org.rcdukes.dukes 40 | rc-detect 41 | 0.0.3 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /rc-common/src/main/java/org/rcdukes/error/ExceptionHandler.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * This file is part of the https://github.com/BITPlan/com.bitplan.gui open source project 4 | * 5 | * Copyright 2017 BITPlan GmbH https://github.com/BITPlan 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * 10 | * You may obtain a copy of the License at 11 | * 12 | * http:www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | */ 21 | package org.rcdukes.error; 22 | 23 | /** 24 | * Exception Handler 25 | * @author wf 26 | * 27 | */ 28 | public interface ExceptionHandler { 29 | 30 | /** 31 | * handle the given Throwable with the given hint 32 | * @param th - the throwable 33 | * @param hint - the hint to give to the user how to potentially fix this 34 | */ 35 | public void handle(Throwable th, String hint); 36 | 37 | /** 38 | * handle the given Throwable with no hint 39 | * @param th - the throwable to handle 40 | */ 41 | public void handle(Throwable th); 42 | 43 | /** 44 | * warn with the given message 45 | * @param msg - the message 46 | */ 47 | public void warn(String msg); 48 | } 49 | -------------------------------------------------------------------------------- /rc-drivecontrol/src/main/java/org/rcdukes/drivecontrol/LedMap.java: -------------------------------------------------------------------------------- 1 | package org.rcdukes.drivecontrol; 2 | 3 | import org.rcdukes.car.ServoCommand; 4 | 5 | import org.rcdukes.error.ErrorHandler; 6 | 7 | import org.rcdukes.common.Config; 8 | import org.rcdukes.common.Environment; 9 | 10 | /** 11 | * configure the LED with the given parameters 12 | * @author wf 13 | * 14 | */ 15 | public class LedMap extends ServoMap 16 | implements org.rcdukes.car.LedMap { 17 | private static int LED_ON = 250; 18 | private static int LED_OFF = 0; 19 | private static int LED_GPIO= 24; 20 | 21 | /** 22 | * construct me from the given ServoCommand 23 | * @param servoCommand 24 | */ 25 | public LedMap(ServoCommand servoCommand) { 26 | Environment env = Config.getEnvironment(); 27 | try { 28 | LED_ON = env.getInteger(Config.LED_ON); 29 | LED_OFF = env.getInteger(Config.LED_OFF); 30 | LED_GPIO = env.getInteger(Config.LED_GPIO); 31 | } catch (Exception e) { 32 | ErrorHandler.getInstance().handle(e,"you might want to check you settings"); 33 | } 34 | LOG.info(String.format("LED gpio: %3d off: %3d on: %3d", 35 | LED_GPIO,LED_OFF,LED_ON)); 36 | super.configure(LED_GPIO, servoCommand,"+"); 37 | } 38 | 39 | @Override 40 | public int ledOff() { 41 | return LED_OFF; 42 | } 43 | 44 | @Override 45 | public int ledOn() { 46 | return LED_ON; 47 | } 48 | 49 | /** 50 | * not needed here 51 | */ 52 | @Override 53 | public void configureOrientation() { 54 | 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /rc-common/src/test/java/org/rcdukes/common/TestPOJO.java: -------------------------------------------------------------------------------- 1 | package org.rcdukes.common; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | 5 | import org.junit.Test; 6 | import org.rcdukes.common.ServoCalibration; 7 | 8 | import com.google.gson.Gson; 9 | 10 | import io.vertx.core.json.JsonObject; 11 | 12 | /** 13 | * test Plain Old Java Object conversion with vert.x 14 | * @author wf 15 | * 16 | */ 17 | public class TestPOJO { 18 | boolean debug=true; 19 | @Test 20 | /** 21 | * test Vert.x pojo support 22 | * see 50 && i%4==0)target=target+(Math.random()-.5)*50; 41 | 42 | output = miniPID.getOutput(actual, target); 43 | actual = actual + output; 44 | 45 | //System.out.printf("Current: %3.2f , Actual: %3.2f, Error: %3.2f\n",actual, output, (target-actual)); 46 | String line=String.format(Locale.ENGLISH,"%6.2f | %6.2f | %6.2f | %6.2f", target, actual, output, (target-actual)); 47 | System.err.println(line); 48 | 49 | //if(i>80 && i%5==0)actual+=(Math.random()-.5)*20; 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /rc-detect/src/main/java/org/rcdukes/detect/ImageObserver.java: -------------------------------------------------------------------------------- 1 | package org.rcdukes.detect; 2 | 3 | import org.opencv.core.Mat; 4 | import org.rcdukes.common.ErrorHandler; 5 | import org.rcdukes.video.Image; 6 | 7 | import io.reactivex.Observer; 8 | import io.reactivex.disposables.Disposable; 9 | 10 | /** 11 | * a subscriber for OpenCV images 12 | * @author wf 13 | * 14 | */ 15 | public class ImageObserver implements Observer { 16 | 17 | public Throwable error; 18 | public int cols = 0; 19 | public int rows=0; 20 | public boolean completed = false; 21 | public boolean debug = false; 22 | public String stackTraceText; 23 | private Disposable disposable; 24 | 25 | @Override 26 | public void onComplete() { 27 | completed = true; 28 | } 29 | 30 | @Override 31 | public void onError(Throwable th) { 32 | stackTraceText=ErrorHandler.getStackTraceText(th); 33 | error = th; 34 | } 35 | 36 | @Override 37 | public void onNext(Image image) { 38 | Mat mat=image.getFrame(); 39 | cols = mat.cols(); 40 | rows = mat.rows(); 41 | if (cols==0 || rows==0) 42 | System.err.println("invalid frame "+image.getFrameIndex()); 43 | if (debug && image.getFrameIndex()%25==0) { 44 | String msg = String.format("%6d:%4dx%d", image.getFrameIndex(), cols, rows); 45 | System.out.println(msg); 46 | } 47 | } 48 | 49 | @Override 50 | public void onSubscribe(Disposable d) { 51 | this.disposable=d; 52 | } 53 | 54 | public void stop() { 55 | if (disposable!=null) 56 | this.disposable.dispose(); 57 | } 58 | 59 | }; 60 | -------------------------------------------------------------------------------- /rc-camera-matrix/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | 8 | org.rcdukes 9 | dukes 10 | 0.0.3 11 | 12 | 13 | org.rcdukes.dukes 14 | rc-camera-matrix 15 | 16 | Responsible for interfacing with controllers 17 | 18 | 19 | 20 | 21 | io.vertx 22 | vertx-rx-java 23 | 24 | 25 | org.rcdukes.dukes 26 | rc-geometry 27 | 0.0.3 28 | 29 | 30 | org.rcdukes.dukes 31 | rc-roi 32 | 0.0.3 33 | 34 | 35 | org.opencv 36 | opencv-jar 37 | 38 | 39 | junit 40 | junit 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /rc-camera-matrix/src/test/java/org/rcdukes/camera/TestCameraMatrix.java: -------------------------------------------------------------------------------- 1 | package org.rcdukes.camera; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | 5 | import java.nio.file.Files; 6 | import java.nio.file.Paths; 7 | import java.util.ArrayList; 8 | 9 | import org.junit.Test; 10 | import org.opencv.core.Mat; 11 | import org.opencv.imgcodecs.Imgcodecs; 12 | 13 | /** 14 | * test for camera matrix 15 | * 16 | */ 17 | public class TestCameraMatrix extends MatrixTestbase { 18 | 19 | String testPath = basePath + "target/test-classes/cameramatrix/"; 20 | 21 | @Test 22 | public void testCalculation() throws Exception { 23 | CameraMatrix matrix = new CameraMatrix(8, 6); 24 | 25 | ArrayList images = new ArrayList<>(); 26 | Files 27 | .newDirectoryStream(Paths.get(testPath), 28 | path -> path.getFileName().toString().startsWith("GOPR")) 29 | .forEach(path -> { 30 | System.out.println("reading: " + path); 31 | String substring = path.toString(); 32 | Mat image = Imgcodecs.imread(substring); 33 | matrix.calibrate(image); 34 | }); 35 | 36 | images.forEach(Mat::release); 37 | 38 | System.out.println(matrix.serialize()); 39 | 40 | CameraMatrix deserializedMatrix = CameraMatrix 41 | .deserizalize(matrix.serialize()); 42 | 43 | Mat image = Imgcodecs.imread(testPath + "/test_image.jpg"); 44 | 45 | assertEquals(matrix.serialize(), deserializedMatrix.serialize()); 46 | 47 | Mat undistorted = deserializedMatrix.apply(image); 48 | 49 | System.out.println(deserializedMatrix.serialize()); 50 | 51 | if (debug) 52 | Imgcodecs.imwrite(testPath + "debug.jpg", undistorted); 53 | } 54 | 55 | } -------------------------------------------------------------------------------- /rc-action/src/main/java/org/rcdukes/action/Navigator.java: -------------------------------------------------------------------------------- 1 | package org.rcdukes.action; 2 | 3 | import org.rcdukes.common.DukesVerticle; 4 | import org.rcdukes.common.GraphDatabase; 5 | import org.rcdukes.geometry.LaneDetectionResult; 6 | import org.rcdukes.video.VideoRecorders.VideoInfo; 7 | 8 | import io.vertx.core.json.JsonObject; 9 | import io.vertx.rxjava.core.eventbus.Message; 10 | 11 | /** 12 | * navigation interface 13 | * @author wf 14 | * 15 | */ 16 | public interface Navigator extends GraphDatabase { 17 | 18 | public DukesVerticle getSender(); 19 | public void setSender(DukesVerticle sender); 20 | /** 21 | * convert a lane detection result Json Object to a LaneDetectionResult 22 | * @param ldrJo 23 | * @return the lane detection result 24 | */ 25 | public LaneDetectionResult fromJsonObject(JsonObject ldrJo); 26 | /** 27 | * get a navigation instruction 28 | * based on the given LaneDetectionResult 29 | */ 30 | public JsonObject getNavigationInstruction(LaneDetectionResult ldr); 31 | /** 32 | * navigate based on the given instruction 33 | * @param navigationInstruction 34 | */ 35 | public void navigateWithInstruction(JsonObject navigationInstruction); 36 | 37 | /** 38 | * navigate with the given vert.x eventbus message 39 | * @param ldrMessage 40 | */ 41 | public void navigateWithMessage(Message ldrMessage); 42 | 43 | /** 44 | * navigate with the given LaneDetectionResult 45 | * @param ldr 46 | */ 47 | public void navigateWithLaneDetectionResult(LaneDetectionResult ldr); 48 | 49 | /** 50 | * handle a stopped video 51 | * @param videoInfo 52 | */ 53 | public void videoStopped(VideoInfo videoInfo); 54 | 55 | } 56 | -------------------------------------------------------------------------------- /rc-car/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | 8 | org.rcdukes 9 | dukes 10 | 0.0.3 11 | 12 | 13 | org.rcdukes.dukes 14 | rc-car 15 | 16 | 17 | Vert.x verticle 18 | 19 | 20 | 21 | 22 | io.vertx 23 | vertx-core 24 | 25 | 26 | io.vertx 27 | vertx-rx-java 28 | 29 | 30 | org.rcdukes.dukes 31 | rc-camera-matrix 32 | 0.0.3 33 | 34 | 35 | org.rcdukes.dukes 36 | rc-common 37 | 0.0.3 38 | 39 | 40 | org.rcdukes.dukes 41 | rc-drivecontrol 42 | 0.0.3 43 | 44 | 45 | org.rcdukes.dukes 46 | rc-drivecontrol 47 | test-jar 48 | 0.0.3 49 | test 50 | 51 | 52 | junit 53 | junit 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /rc-common/src/main/java/org/rcdukes/common/ServoCalibration.java: -------------------------------------------------------------------------------- 1 | package org.rcdukes.common; 2 | 3 | import java.util.Map; 4 | import java.util.TreeMap; 5 | 6 | import io.vertx.core.json.JsonObject; 7 | 8 | /** 9 | * holds value for servo calibration 10 | * @author wf 11 | * 12 | */ 13 | public class ServoCalibration implements POJO { 14 | 15 | private String vehicle; 16 | 17 | private String type; 18 | private String unit; 19 | 20 | Map valueMap; 21 | 22 | /** 23 | * a servomap 24 | */ 25 | public ServoCalibration() { 26 | valueMap = new TreeMap(); 27 | } 28 | 29 | public static ServoCalibration fromJo(JsonObject jo) { 30 | return jo.mapTo(ServoCalibration.class); 31 | } 32 | 33 | public String toString() { 34 | return this.asJson(); 35 | } 36 | 37 | public String getVehicle() { 38 | return vehicle; 39 | } 40 | 41 | public void setVehicle(String vehicle) { 42 | this.vehicle = vehicle; 43 | } 44 | 45 | /** 46 | * @return the type 47 | */ 48 | public String getType() { 49 | return type; 50 | } 51 | 52 | /** 53 | * @param type 54 | * the type to set 55 | */ 56 | public void setType(String type) { 57 | this.type = type; 58 | } 59 | 60 | /** 61 | * @return the unit 62 | */ 63 | public String getUnit() { 64 | return unit; 65 | } 66 | 67 | /** 68 | * @param unit 69 | * the unit to set 70 | */ 71 | public void setUnit(String unit) { 72 | this.unit = unit; 73 | } 74 | 75 | public Map getValueMap() { 76 | return valueMap; 77 | } 78 | 79 | public void setValueMap(Map valueMap) { 80 | this.valueMap = valueMap; 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /rc-detect/src/main/java/org/rcdukes/detect/lanedetection/DefaultLaneDetector.java: -------------------------------------------------------------------------------- 1 | package org.rcdukes.detect.lanedetection; 2 | 3 | import java.util.Collection; 4 | import java.util.Optional; 5 | 6 | import org.rcdukes.detectors.LaneDetector; 7 | import org.rcdukes.geometry.Lane; 8 | import org.rcdukes.geometry.Line; 9 | import org.rcdukes.geometry.Point; 10 | import org.rcdukes.geometry.Point2D; 11 | import org.rcdukes.objects.ViewPort; 12 | import org.rcdukes.objects.lane.LaneLeftBoundary; 13 | import org.rcdukes.objects.lane.LaneRightBoundary; 14 | 15 | /** 16 | * the default lane detector 17 | * @author wf 18 | * 19 | */ 20 | public class DefaultLaneDetector implements LaneDetector { 21 | 22 | @Override 23 | public Lane detect(Collection lines, ViewPort viewPort) { 24 | Optional leftLine = new LaneLeftBoundary().boundary(lines); 25 | Optional rightLine = new LaneRightBoundary().boundary(lines); 26 | 27 | final Line bottom = new Line(new Point(0d, viewPort.getHeight()), new Point(viewPort.getWidth(), viewPort.getHeight())); 28 | final Line horizon = new Line(new Point(0d, 0d), new Point((double) viewPort.getWidth(), 0d)); 29 | 30 | Optional leftBoundary = leftLine.map(line -> stretch(line, bottom, horizon)); 31 | Optional rightBoundary = rightLine.map(line -> stretch(line, bottom, horizon)); 32 | 33 | Lane lane = new Lane(leftBoundary, rightBoundary); 34 | 35 | return lane; 36 | } 37 | 38 | private Line stretch(Line line, Line bottom, Line horizon) { 39 | Point2D lineTop = horizon.intersect(line).get(); 40 | Point2D lineBottom = bottom.intersect(line).get(); 41 | return new Line(lineBottom, lineTop); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /rc-common/src/test/java/org/rcdukes/common/TestClusterStarter.java: -------------------------------------------------------------------------------- 1 | package org.rcdukes.common; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | 5 | import org.junit.Test; 6 | import org.rcdukes.common.Characters; 7 | import org.rcdukes.common.ClusterStarter; 8 | import org.rcdukes.common.DukesVerticle; 9 | import org.rcdukes.common.DukesVerticle.Status; 10 | import org.rcdukes.common.Environment; 11 | import org.slf4j.Logger; 12 | import org.slf4j.LoggerFactory; 13 | 14 | /** 15 | * test the ClusterStarter 16 | * 17 | * @author wf 18 | * 19 | */ 20 | public class TestClusterStarter { 21 | private static final Logger LOG = LoggerFactory.getLogger(TestClusterStarter.class); 22 | 23 | public static boolean debug = false; 24 | 25 | static class TestVerticle extends DukesVerticle { 26 | public TestVerticle() { 27 | super(Characters.BO); 28 | } 29 | 30 | int counter = 0; 31 | public static int TEST_INTERVAL_MS = 20; 32 | 33 | @Override 34 | public void start() { 35 | super.preStart(); 36 | LOG.info("Starting TestVerticle"); 37 | vertx.setPeriodic(TEST_INTERVAL_MS, id -> periodic()); 38 | super.postStart(); 39 | } 40 | 41 | public void periodic() { 42 | LOG.trace(String.format("periodic call %d", ++counter)); 43 | } 44 | } 45 | 46 | @Test 47 | public void testClusterStarter() throws Exception { 48 | Environment.mock(); 49 | ClusterStarter starter = new ClusterStarter(); 50 | TestVerticle testVerticle = new TestVerticle(); 51 | starter.deployVerticles(testVerticle); 52 | testVerticle.waitStatus(Status.started, ClusterStarter.MAX_START_TIME, 10); 53 | int minLoops=5; 54 | while (testVerticle.counter <=minLoops) { 55 | Thread.sleep(TestVerticle.TEST_INTERVAL_MS); 56 | } 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /rc-drivecontrol/src/main/java/org/rcdukes/car/Steering.java: -------------------------------------------------------------------------------- 1 | package org.rcdukes.car; 2 | 3 | import org.rcdukes.common.ServoPosition; 4 | import org.rcdukes.drivecontrol.Car; 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | 8 | /** 9 | * the steering Servo 10 | * 11 | * @author wf 12 | * 13 | */ 14 | public class Steering extends Servo { 15 | 16 | ServoRangeMap steeringMap; 17 | 18 | private static final Logger LOG = LoggerFactory.getLogger(Steering.class); 19 | 20 | private Car car; 21 | 22 | /** 23 | * construct me from the given Steering Map 24 | * 25 | * @param steeringMap 26 | */ 27 | public Steering(Car car,ServoRangeMap steeringMap) { 28 | super(steeringMap); 29 | this.car=car; 30 | this.steeringMap = steeringMap; 31 | } 32 | 33 | public void center() { 34 | boolean force = false; 35 | setWheelPosition(steeringMap.getRange().getZeroPosition(), force); 36 | } 37 | 38 | public void forceCenter() { 39 | boolean force = true; 40 | setWheelPosition(steeringMap.getRange().getZeroPosition(), force); 41 | } 42 | 43 | /** 44 | * set the wheel Position to the given position 45 | */ 46 | public void setWheelPosition(ServoPosition position) { 47 | boolean force = false; 48 | setWheelPosition(position, force); 49 | } 50 | 51 | private void setWheelPosition(ServoPosition position, boolean force) { 52 | if (!car.powerIsOn() && !force) { 53 | LOG.debug("Not setting servo value; power is off and force is false."); 54 | return; 55 | } 56 | LOG.debug("Setting servo to value " + position); 57 | this.servoMap.newPosition(position); 58 | super.setServo(position.getServoPos()); 59 | } 60 | 61 | public ServoRangeMap getSteeringMap() { 62 | return steeringMap; 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /rc-car/src/test/java/org/rcdukes/car/TestCar.java: -------------------------------------------------------------------------------- 1 | package org.rcdukes.car; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | import static org.junit.Assert.assertNotNull; 5 | 6 | import org.junit.Test; 7 | import org.rcdukes.car.CarVerticle; 8 | 9 | import org.rcdukes.common.ClusterStarter; 10 | import org.rcdukes.common.Environment; 11 | import org.rcdukes.common.ServoPosition; 12 | import org.rcdukes.common.DukesVerticle.Status; 13 | 14 | import io.vertx.core.json.JsonObject; 15 | 16 | /** 17 | * test the car verticle 18 | * @author wf 19 | * 20 | */ 21 | public class TestCar { 22 | public static boolean debug=true; 23 | @Test 24 | public void testCar() throws Exception { 25 | int TIME_OUT=40000; 26 | Environment.mock(); 27 | ClusterStarter clusterStarter=new ClusterStarter(); 28 | CarVerticle carVerticle = new CarVerticle(); 29 | clusterStarter.deployVerticles(carVerticle); 30 | carVerticle.waitStatus(Status.started,TIME_OUT,10); 31 | if (!TestSuite.isTravis()) { 32 | clusterStarter.undeployVerticle(carVerticle); 33 | carVerticle.waitStatus(Status.stopped,TIME_OUT,10); 34 | } 35 | } 36 | 37 | @Test 38 | public void testServoPositionMapping() { 39 | ServoPosition[] poss= {new ServoPosition(154,10,"°","steering"),new ServoPosition(130,0,"m/s","motor")}; 40 | for (ServoPosition pos:poss) { 41 | JsonObject jo=JsonObject.mapFrom(pos); 42 | String json=jo.encodePrettily(); 43 | assertNotNull(json); 44 | if (debug) 45 | System.out.println(json); 46 | ServoPosition rpos=jo.mapTo(ServoPosition.class); 47 | assertEquals(pos.kind,rpos.kind); 48 | assertEquals(pos.getServoPos(),rpos.getServoPos()); 49 | assertEquals(pos.getValue(),rpos.getValue(),0.001); 50 | assertEquals(pos.unit,rpos.unit); 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /rc-common/src/test/java/org/rcdukes/common/TestCharacters.java: -------------------------------------------------------------------------------- 1 | package org.rcdukes.common; 2 | 3 | import java.util.Arrays; 4 | import java.util.Comparator; 5 | 6 | import org.apache.commons.lang3.text.WordUtils; 7 | import org.junit.Test; 8 | 9 | /** 10 | * test Characters 11 | * @author wf 12 | * 13 | */ 14 | public class TestCharacters { 15 | 16 | public String spc(int numberOfSpaces) { 17 | return String.format(String.format("%%%ds", numberOfSpaces), ""); 18 | } 19 | 20 | public String capitalize(String name) { 21 | // return name.substring(0,1).toUpperCase() + name.substring(1).toLowerCase(); 22 | return WordUtils.capitalizeFully(name.replace("_"," ")).replace(" ",""); 23 | } 24 | 25 | public void output(String format,Object ...args) { 26 | System.out.println(String.format(format, args)); 27 | } 28 | @Test 29 | public void testWikiMarkup() { 30 | Characters[] chars = Characters.values(); 31 | Arrays.sort(chars, Comparator.comparing(Characters::getModule)); 32 | 33 | for (Characters c : chars) { 34 | String name=c.module.replace("-",""); 35 | String uml="https://rc-dukes.github.io/dukes/dukes/apidocs/nl/vaneijndhoven/dukes/%s/package-summary.html"; 36 | output(" %-14s[",name); 37 | output(" %s label=\" \"",spc(14)); 38 | output(" %s image=\"%s\"",spc(14),capitalize(c.name())+".png"); 39 | output(" %s fontcolor=white",spc(14)); 40 | output(" %s URL=\"%s\"",spc(14),c.getUrl()); 41 | output(" %s]",spc(14)); 42 | output(" %-14s[",name+"label"); 43 | output(" %s shape=\"note\"",spc(14)); 44 | output(" %s label=\"%s\\n%s\"",spc(14),c.module,c.name()); 45 | output(" %s URL=\""+uml+"\"",spc(14),c.module); 46 | output(" %s]",spc(14)); 47 | output(" dukes--%slabel--%s",name,name); 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /rc-detect/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | 8 | org.rcdukes 9 | dukes 10 | 0.0.3 11 | 12 | 13 | org.rcdukes.dukes 14 | rc-detect 15 | Detectors - e.g. Lane and StartLight 16 | 17 | 18 | 19 | org.rcdukes.dukes 20 | rc-common 21 | 0.0.3 22 | 23 | 24 | org.rcdukes.dukes 25 | rc-geometry 26 | 0.0.3 27 | 28 | 29 | org.rcdukes.dukes 30 | rc-roi 31 | 0.0.3 32 | 33 | 34 | org.rcdukes.dukes 35 | rc-camera-matrix 36 | 0.0.3 37 | 38 | 39 | org.opencv 40 | opencv-jar 41 | 42 | 43 | io.vertx 44 | vertx-rx-java 45 | 46 | 47 | ch.qos.logback 48 | logback-classic 49 | 50 | 51 | 52 | commons-io 53 | commons-io 54 | 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /rc-drivecontrol/src/main/java/org/rcdukes/drivecontrol/ServoMap.java: -------------------------------------------------------------------------------- 1 | package org.rcdukes.drivecontrol; 2 | 3 | import org.rcdukes.car.ServoCommand; 4 | import org.rcdukes.common.ServoPosition; 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | 8 | /** 9 | * servo gpioPin and command 10 | * 11 | * @author wf 12 | * 13 | */ 14 | public abstract class ServoMap implements org.rcdukes.car.ServoMap { 15 | protected static final Logger LOG = LoggerFactory 16 | .getLogger(ServoMap.class); 17 | 18 | protected ServoCommand servoCommand; 19 | protected int gpioPin; 20 | protected boolean turnedOrientation; 21 | ServoPosition currentPosition; 22 | 23 | public ServoPosition getCurrentPosition() { 24 | return currentPosition; 25 | } 26 | 27 | public void setCurrentPosition(ServoPosition currentPosition) { 28 | this.currentPosition = currentPosition; 29 | } 30 | 31 | /** 32 | * set a new Position 33 | * @param newPosition 34 | */ 35 | @Override 36 | public ServoPosition newPosition(ServoPosition newPosition) { 37 | ServoPosition sp=new ServoPosition(newPosition.getServoPos(),newPosition.getValue()); 38 | this.setCurrentPosition(sp); 39 | return sp; 40 | } 41 | 42 | @Override 43 | public int gpioPin() { 44 | return gpioPin; 45 | } 46 | 47 | @Override 48 | public ServoCommand servoCommand() { 49 | return servoCommand; 50 | } 51 | 52 | @Override 53 | public void configure(int gpioPin, ServoCommand servoCommand, 54 | String orientation) { 55 | boolean turnedOrientation = orientation.trim().equals("-"); 56 | this.gpioPin = gpioPin; 57 | this.servoCommand = servoCommand; 58 | this.turnedOrientation = turnedOrientation; 59 | configureOrientation(); 60 | } 61 | 62 | @Override 63 | public boolean turnedOrientation() { 64 | return turnedOrientation; 65 | } 66 | 67 | } 68 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /rc-app/src/main/java/org/rcdukes/app/CameraGUI.java: -------------------------------------------------------------------------------- 1 | package org.rcdukes.app; 2 | 3 | import org.rcdukes.detect.CameraConfig; 4 | 5 | import javafx.fxml.FXML; 6 | import javafx.scene.control.CheckBox; 7 | import javafx.scene.image.ImageView; 8 | 9 | /** 10 | * camera GUI 11 | * 12 | * @author wf 13 | */ 14 | public class CameraGUI extends BaseGUI { 15 | // the FXML area for showing the current frame 16 | @FXML ImageView originalFrame; 17 | @FXML ImageView processedImage1; 18 | @FXML ImageView processedImage2; 19 | @FXML ImageView processedImage3; 20 | 21 | // make my config visible 22 | CameraConfig cameraConfig; 23 | // will be configured by main GUI and not via @FXML 24 | public LabeledValueSlider roiy; 25 | public LabeledValueSlider roih; 26 | public LabeledValueSlider angleOffset; 27 | public int imageWidth=800; 28 | public CheckBox showStoppingZone; 29 | @FXML 30 | public void initialize() { 31 | int fitWidth = (int)(BaseGUI.getScreenWidth()/1920.0*imageWidth); 32 | this.configureImageDisplaySize(fitWidth); 33 | } 34 | 35 | public CameraGUI() { 36 | super(); 37 | cameraConfig=new CameraConfig(); 38 | } 39 | 40 | /** 41 | * configure the image display size to the given fitWidth 42 | * @param fitWidth 43 | */ 44 | private void configureImageDisplaySize(int fitWidth) { 45 | this.imageViewProperties(this.originalFrame, fitWidth); 46 | this.imageViewProperties(this.processedImage1, fitWidth*3/4); 47 | this.imageViewProperties(this.processedImage2, fitWidth*3/4); 48 | this.imageViewProperties(this.processedImage3, fitWidth*3/4); 49 | } 50 | 51 | public void applySliderValues() { 52 | cameraConfig.setAngleOffset(angleOffset.getValue()); 53 | cameraConfig.setRoih(roih.getValue()); 54 | cameraConfig.setRoiy(roiy.getValue()); 55 | cameraConfig.setShowStoppingZone(showStoppingZone.isSelected()); 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /rc-drivecontrol/src/main/java/org/rcdukes/car/Engine.java: -------------------------------------------------------------------------------- 1 | package org.rcdukes.car; 2 | 3 | import org.rcdukes.common.ServoPosition; 4 | import org.rcdukes.drivecontrol.Car; 5 | 6 | /** 7 | * drive control for the engine 8 | */ 9 | public class Engine extends Servo { 10 | 11 | private ServoRangeMap engineMap; 12 | private Car car; 13 | 14 | /** 15 | * configure the engine from the given mapping and car 16 | * @param mapping - servo settings to use 17 | * @param car - the car 18 | */ 19 | public Engine(Car car,ServoRangeMap engineMap) { 20 | super(engineMap); 21 | this.engineMap=engineMap; 22 | this.car=car; 23 | } 24 | 25 | public void neutral() { 26 | boolean force = false; 27 | neutral(force); 28 | } 29 | 30 | /** 31 | * force the car to neutral 32 | */ 33 | public void forceInNeutral() { 34 | boolean force = true; 35 | neutral(force); 36 | } 37 | 38 | /** 39 | * set the speed to the given servo Position 40 | * @param speed 41 | */ 42 | public void setSpeed(ServoPosition speed) { 43 | boolean force = false; 44 | setSpeed(speed, force); 45 | } 46 | 47 | /** 48 | * switch to neutral 49 | * @param force 50 | */ 51 | public void neutral(boolean force) { 52 | setSpeed(engineMap.getRange().getZeroPosition(), force); 53 | } 54 | 55 | /** 56 | * 57 | * @param speed 58 | * @param force 59 | */ 60 | private void setSpeed(ServoPosition speed, boolean force) { 61 | if (!car.powerIsOn() && !force) { 62 | String msg=String.format("Not setting motor value to %s; power is off and force is false.",speed); 63 | LOG.debug(msg); 64 | return; 65 | } 66 | LOG.debug("Setting motor to value " + speed); 67 | this.engineMap.newPosition(speed); 68 | super.setServo(speed.getServoPos()); 69 | } 70 | 71 | public ServoRangeMap getEngineMap() { 72 | return engineMap; 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /rc-common/src/test/java/org/rcdukes/common/TestConfiguration.java: -------------------------------------------------------------------------------- 1 | package org.rcdukes.common; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | import static org.junit.Assert.assertTrue; 5 | 6 | import java.io.File; 7 | import java.util.Iterator; 8 | import java.util.List; 9 | import java.util.Map; 10 | 11 | import org.apache.tinkerpop.gremlin.structure.Vertex; 12 | import org.apache.tinkerpop.gremlin.structure.VertexProperty; 13 | import org.junit.Test; 14 | 15 | /** 16 | * test the configuration handling 17 | * @author wf 18 | * 19 | */ 20 | public class TestConfiguration { 21 | 22 | public Configuration getMockConfiguration() throws Exception { 23 | Environment.mock(); 24 | File tempConfig=File.createTempFile("config",".json"); 25 | // make sure the config does not exist so we do not read it 26 | tempConfig.delete(); 27 | // do not read ini files 28 | Configuration config=new Configuration(tempConfig.getAbsolutePath(),false); 29 | // add the mock environment 30 | config.addEnv(Environment.getInstance()); 31 | return config; 32 | } 33 | 34 | @Test 35 | public void testConfiguration() throws Exception { 36 | Configuration config=getMockConfiguration(); 37 | long nodeCount = config.g().V().count().next().longValue(); 38 | assertEquals(1,nodeCount); 39 | config.write(); 40 | assertTrue(config.getGraphFile().canRead()); 41 | // clean up 42 | config.getGraphFile().delete(); 43 | } 44 | 45 | @Test 46 | public void testQuery() throws Exception { 47 | Configuration config=getMockConfiguration(); 48 | config.write(); 49 | Map envMap = config.getEnvironments(); 50 | assertEquals(1,envMap.size()); 51 | Environment env = envMap.values().iterator().next(); 52 | assertEquals("pi.doe.com",env.getString(Config.REMOTECAR_HOST)); 53 | // clean up 54 | config.getGraphFile().delete(); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /rc-camera-matrix/src/main/java/org/rcdukes/camera/ImagePolygon.java: -------------------------------------------------------------------------------- 1 | package org.rcdukes.camera; 2 | 3 | import org.opencv.core.Rect; 4 | import org.opencv.core.Size; 5 | import org.rcdukes.geometry.Point; 6 | import org.rcdukes.geometry.Polygon; 7 | import org.rcdukes.roi.ROI; 8 | 9 | /** 10 | * a polygon defined from an OpenCV image 11 | * 12 | * @author wf 13 | * 14 | */ 15 | public class ImagePolygon extends Polygon { 16 | 17 | /** 18 | * construct me from relative values 19 | * 20 | * @param size 21 | * @param rx1 22 | * @param ry1 23 | * @param rx2 24 | * @param ry2 25 | * @param rx3 26 | * @param ry3 27 | * @param rx4 28 | * @param ry4 29 | */ 30 | public ImagePolygon(Size size, double rx1, double ry1, double rx2, double ry2, 31 | double rx3, double ry3, double rx4, double ry4) { 32 | double w = size.width; 33 | double h = size.height; 34 | init( 35 | new Point(rx1 * w, ry1 * h), 36 | new Point(rx2 * w, ry2 * h), 37 | new Point(rx3 * w, ry3 * h), 38 | new Point(rx4 * w, ry4 * h) 39 | ); 40 | } 41 | 42 | /** 43 | * construct me from the given corner points 44 | * @param corners 45 | * - corner points 46 | */ 47 | public ImagePolygon(org.opencv.core.Point[] corners) { 48 | init( 49 | new Point(corners[0].x, corners[0].y), 50 | new Point(corners[1].x, corners[1].y), 51 | new Point(corners[2].x, corners[2].y), 52 | new Point(corners[3].x, corners[3].y) 53 | ); 54 | } 55 | 56 | /** 57 | * create an ImagePolygon for the given roi 58 | * @param size 59 | * @param roi 60 | */ 61 | public ImagePolygon(Size size, ROI roi) { 62 | Rect r = roi.roiRect(size); 63 | init( 64 | new Point(r.x,r.y), 65 | new Point(r.x+r.width,r.y), 66 | new Point(r.x+r.width,r.y+r.height), 67 | new Point(r.x,r.y+r.height) 68 | ); 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /rc-drivecontrol/src/main/java/org/rcdukes/drivecontrol/SteeringMap.java: -------------------------------------------------------------------------------- 1 | package org.rcdukes.drivecontrol; 2 | 3 | import org.rcdukes.car.ServoCommand; 4 | import org.rcdukes.car.ServoRange; 5 | import org.rcdukes.car.ServoSide; 6 | import org.rcdukes.common.Config; 7 | import org.rcdukes.common.Environment; 8 | import org.rcdukes.common.ServoPosition; 9 | import org.rcdukes.error.ErrorHandler; 10 | 11 | /** 12 | * steering map which is vehicle dependent 13 | * 14 | */ 15 | public class SteeringMap extends ServoRangeMap { 16 | 17 | /** 18 | * steering mapping 19 | * 20 | * @param servoCommand 21 | */ 22 | public SteeringMap(ServoCommand servoCommand) { 23 | Environment env = Config.getEnvironment(); 24 | try { 25 | int WHEEL_STEP_SIZE = env.getInteger(Config.WHEEL_STEP_SIZE); 26 | int WHEEL_GPIO = env.getInteger(Config.WHEEL_GPIO); 27 | String WHEEL_ORIENTATION = env.getString(Config.WHEEL_ORIENTATION); 28 | ServoPosition leftMax = new ServoPosition(Config.WHEEL_MAX_LEFT, Config.WHEEL_MAX_LEFT_ANGLE); 29 | ServoPosition leftMin = new ServoPosition(Config.WHEEL_CENTER, Config.ZERO); 30 | ServoPosition rightMax = new ServoPosition(Config.WHEEL_MAX_RIGHT, Config.WHEEL_MAX_RIGHT_ANGLE); 31 | ServoPosition rightMin = new ServoPosition(Config.WHEEL_CENTER,Config.ZERO); 32 | ServoSide sideP=new ServoSide("right",1,rightMin,rightMax); 33 | ServoSide sideN=new ServoSide("left",-1,leftMin,leftMax); 34 | ServoPosition center = new ServoPosition(Config.WHEEL_CENTER,Config.ZERO); 35 | setRange(new ServoRange(WHEEL_STEP_SIZE, sideN, center,sideP)); 36 | setUnit("°"); 37 | setName("Steering"); 38 | super.configure(WHEEL_GPIO, servoCommand, 39 | WHEEL_ORIENTATION); 40 | check(); 41 | } catch (Exception e) { 42 | ErrorHandler.getInstance().handle(e, 43 | "you might want to check you settings"); 44 | } 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /rc-detect/src/test/java/org/rcdukes/detect/TestImageProcessing.java: -------------------------------------------------------------------------------- 1 | package org.rcdukes.detect; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | 5 | import org.junit.BeforeClass; 6 | import org.junit.Test; 7 | import org.opencv.core.Core; 8 | import org.opencv.core.Mat; 9 | import org.opencv.imgproc.Imgproc; 10 | import org.rcdukes.video.ColorFilter; 11 | import org.rcdukes.video.DenoiseByBlur; 12 | import org.rcdukes.video.ImageUtils; 13 | 14 | /** 15 | * test the image Processing functions 16 | */ 17 | public class TestImageProcessing extends BaseDetectTest { 18 | public static boolean show = false; 19 | 20 | @BeforeClass 21 | public static void setUp() { 22 | // travis is headless - switch off show in any case 23 | if (TestSuite.isTravis()) show=false; 24 | } 25 | 26 | @Test 27 | public void testDenoiseByBlur() throws Exception { 28 | DenoiseByBlur dbb = new DenoiseByBlur(9,9); 29 | Mat frame = getTestImage(); 30 | Mat blur = dbb.denoise(frame); 31 | assertEquals(blur.width(), frame.width()); 32 | if (show) { 33 | ImageUtils.show(getTestImage()); 34 | ImageUtils.show(blur); 35 | } 36 | } 37 | 38 | @Test 39 | public void testColorFilter() throws Exception { 40 | ColorFilter cf=new ColorFilter(); 41 | cf.setMinColorRGB( 65, 85, 85); 42 | cf.setMaxColorRGB(140, 140, 140); 43 | Mat frame = getTestImage(); 44 | Mat gray=new Mat(); 45 | Imgproc.cvtColor(frame, gray, Imgproc.COLOR_BGR2GRAY); 46 | assertEquals(2458261,Core.countNonZero(gray)); 47 | Mat colorFiltered = cf.filter(frame); 48 | assertEquals(colorFiltered.width(), frame.width()); 49 | Mat cfGray=new Mat(); 50 | Imgproc.cvtColor(colorFiltered, cfGray, Imgproc.COLOR_BGR2GRAY); 51 | assertEquals(173768,Core.countNonZero(cfGray)); 52 | if (show) { 53 | ImageUtils.show(getTestImage()); 54 | ImageUtils.show(gray); 55 | ImageUtils.show(colorFiltered); 56 | } 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /scripts/install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # install the dukes software 3 | # WF 2019-09-18: check opencv.jar 4 | 5 | #ansi colors 6 | #http://www.csc.uvic.ca/~sae/seng265/fall04/tips/s265s047-tips/bash-using-colors.html 7 | blue='\033[0;34m' 8 | red='\033[0;31m' 9 | green='\033[0;32m' # '\e[1;32m' is too bright for white bg. 10 | endColor='\033[0m' 11 | 12 | # 13 | # a colored message 14 | # params: 15 | # 1: l_color - the color of the message 16 | # 2: l_msg - the message to display 17 | # 18 | color_msg() { 19 | local l_color="$1" 20 | local l_msg="$2" 21 | echo -e "${l_color}$l_msg${endColor}" 22 | } 23 | 24 | # error 25 | # 26 | # show an error message and exit 27 | # 28 | # params: 29 | # 1: l_msg - the message to display 30 | error() { 31 | local l_msg="$1" 32 | # use ansi red for error 33 | color_msg $red "Error: $l_msg" 1>&2 34 | } 35 | 36 | # 37 | # show usage 38 | # 39 | usage() { 40 | echo "usage: $(basename $0) [-d|-f|-j|-q]* [-h]?" 41 | echo "" 42 | echo " -d |--debug : debug this script" 43 | echo " -f |--fatjar : create a fat jar" 44 | echo " -j |--javadoc : with javadoc (default is without)" 45 | echo " -q |--quick : no tests, no javadoc" 46 | echo "" 47 | echo " -h |--help : show this usage" 48 | exit 1 49 | } 50 | 51 | mvnOptions="clean install" 52 | javaDoc="-Dmaven.javadoc.skip=true" 53 | # commandline option 54 | while [ "$1" != "" ] 55 | do 56 | option=$1 57 | shift 58 | 59 | # optionally show usage 60 | case $option in 61 | -d|--debug) 62 | set -x 63 | debug=true; 64 | ;; 65 | 66 | -f|--fatjar) 67 | mvnOptions="$mvnOptions -D createAssembly=true" 68 | ;; 69 | -j|--javadoc) 70 | javaDoc="" 71 | ;; 72 | 73 | -h|--help) 74 | usage 75 | exit 0 76 | ;; 77 | 78 | -q) 79 | mvnOptions="$mvnOptions -D skipTests -D gpg.skip" 80 | ;; 81 | esac 82 | done 83 | mvn $mvnOptions $javaDoc 84 | -------------------------------------------------------------------------------- /rc-app/src/main/java/org/rcdukes/app/SimulatorImageFetcher.java: -------------------------------------------------------------------------------- 1 | package org.rcdukes.app; 2 | 3 | import java.io.IOException; 4 | 5 | import org.opencv.core.Mat; 6 | import org.rcdukes.error.ErrorHandler; 7 | import org.rcdukes.video.Image; 8 | import org.rcdukes.video.ImageUtils; 9 | import org.slf4j.Logger; 10 | import org.slf4j.LoggerFactory; 11 | 12 | import io.reactivex.Observable; 13 | import io.reactivex.subjects.ReplaySubject; 14 | import io.vertx.rxjava.core.eventbus.Message; 15 | 16 | /** 17 | * supplies images from the simulator 18 | * @author wf 19 | * 20 | */ 21 | public class SimulatorImageFetcher { 22 | public static boolean debug=false; 23 | private int frameIndex; 24 | // http://reactivex.io/RxJava/javadoc/rx/subjects/ReplaySubject.html 25 | ReplaySubject subject; 26 | protected static final Logger LOG = LoggerFactory 27 | .getLogger(SimulatorImageFetcher.class); 28 | Image Empty=new Image(null,"simulator",-1,0); 29 | 30 | /** 31 | * construct me 32 | */ 33 | public SimulatorImageFetcher() { 34 | frameIndex=0; 35 | subject=ReplaySubject.create(); 36 | } 37 | 38 | /** 39 | * receive an image from the simulator 40 | */ 41 | protected void receiveSimulatorImage(Message message) { 42 | String imgData = message.body(); // in DataURL format ... 43 | try { 44 | Mat frame=ImageUtils.matFromDataUrl(imgData, "jpg"); 45 | long milliTimeStamp = System.currentTimeMillis(); 46 | Image image = new Image(frame, "simulator", frameIndex++, 47 | milliTimeStamp); 48 | if (debug) { 49 | String msg=image.debugInfo(); 50 | LOG.info(msg); 51 | } 52 | subject.onNext(image); 53 | } catch (IOException e) { 54 | ErrorHandler.getInstance().handle(e); 55 | } 56 | } 57 | 58 | /** 59 | * get my Observable 60 | * @return my observable 61 | */ 62 | public Observable toObservable() { 63 | return subject; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /rc-watchdog/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | 8 | org.rcdukes 9 | dukes 10 | 0.0.3 11 | 12 | 13 | org.rcdukes.dukes 14 | rc-watchdog 15 | Heartbeat controller watchdog 16 | 17 | 18 | 19 | io.vertx 20 | vertx-core 21 | 22 | 23 | io.vertx 24 | vertx-rx-java 25 | 26 | 27 | 28 | io.vertx 29 | vertx-unit 30 | test 31 | 32 | 33 | 34 | org.rcdukes.dukes 35 | rc-common 36 | 0.0.3 37 | 38 | 39 | org.rcdukes.dukes 40 | rc-camera-matrix 41 | 0.0.3 42 | 43 | 44 | org.rcdukes.dukes 45 | rc-drivecontrol 46 | 0.0.3 47 | 48 | 49 | org.rcdukes.dukes 50 | rc-drivecontrol 51 | 0.0.3 52 | test-jar 53 | test 54 | 55 | 56 | 57 | ch.qos.logback 58 | logback-classic 59 | 60 | 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /rc-detect/src/test/java/org/rcdukes/detect/TestImageCollector.java: -------------------------------------------------------------------------------- 1 | package org.rcdukes.detect; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | import static org.junit.Assert.assertNotNull; 5 | import static org.junit.Assert.assertTrue; 6 | 7 | import org.junit.BeforeClass; 8 | import org.junit.Test; 9 | import org.rcdukes.opencv.NativeLibrary; 10 | import org.rcdukes.video.Image; 11 | import org.rcdukes.video.ImageCollector; 12 | import org.rcdukes.video.ImageCollector.ImageType; 13 | 14 | import io.reactivex.Observable; 15 | 16 | /** 17 | * test the image Collector 18 | * @author wf 19 | * 20 | */ 21 | public class TestImageCollector { 22 | @BeforeClass 23 | public static void setup() throws Exception { 24 | NativeLibrary.load(); 25 | } 26 | 27 | @Test 28 | public void testImageCollector() { 29 | ImageCollector imageCollector=new ImageCollector(); 30 | for (ImageType imageType:ImageType.values()) { 31 | Image testImage = imageCollector.getTestImage(imageType); 32 | assertNotNull(testImage); 33 | assertEquals(imageType.name(),testImage.getName()); 34 | assertEquals(0,testImage.getFrameIndex()); 35 | assertTrue(testImage.getMilliTimeStamp()<=System.currentTimeMillis()); 36 | } 37 | } 38 | 39 | @Test 40 | public void testImageCollectorObservable() throws InterruptedException { 41 | ImageType imageType=ImageType.camera; 42 | ImageCollector imageCollector=new ImageCollector(); 43 | Observable imageObservable = imageCollector.createObservable(imageType); 44 | String imageName[]= {"?","?"}; 45 | imageObservable.subscribe(image->{ 46 | imageName[0]=image.getName(); 47 | }); 48 | imageObservable.subscribe(image->{ 49 | imageName[1]=image.getName(); 50 | }); 51 | Image testImage = imageCollector.getTestImage(imageType); 52 | imageCollector.addImage(testImage, imageType); 53 | assertEquals("camera",imageName[0]); 54 | assertEquals("camera",imageName[1]); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /rc-action/src/test/java/org/rcdukes/action/TestAction.java: -------------------------------------------------------------------------------- 1 | package org.rcdukes.action; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | import static org.junit.Assert.assertNull; 5 | 6 | import org.junit.Test; 7 | import org.rcdukes.common.ClusterStarter; 8 | import org.rcdukes.common.DukesVerticle.Status; 9 | import org.rcdukes.common.Environment; 10 | import org.rcdukes.geometry.LaneDetectionResult; 11 | 12 | import io.vertx.core.json.JsonObject; 13 | 14 | /** 15 | * test Action/Luke 16 | * 17 | */ 18 | public class TestAction { 19 | public static boolean debug = true; 20 | 21 | /** 22 | * check the navigation result 23 | * 24 | * @param nav 25 | * - the navigation instrucion 26 | * @param nameValues 27 | * - an array of name - value object pairs 28 | */ 29 | public void check(JsonObject nav, String... nameValues) { 30 | if (nameValues.length % 2 != 0) 31 | throw new IllegalArgumentException( 32 | "nameValue parameter list length may not be odd"); 33 | if (debug) { 34 | for (String key : nav.fieldNames()) { 35 | System.out.println(String.format("%s=%s", key, nav.getValue(key))); 36 | } 37 | } 38 | for (int i = 0; i < nameValues.length; i += 2) { 39 | String name = nameValues[i].toString(); 40 | String value = nameValues[i + 1].toString(); 41 | String foundValue = nav.getValue(name).toString(); 42 | assertEquals(value, foundValue); 43 | } 44 | } 45 | 46 | @Test 47 | public void testAction() throws Exception { 48 | int TIME_OUT = 20000; 49 | Environment.mock(); 50 | ClusterStarter clusterStarter = new ClusterStarter(); 51 | ActionVerticle action = new ActionVerticle(); 52 | clusterStarter.deployVerticles(action); 53 | action.waitStatus(Status.started, TIME_OUT, 10); 54 | if (!TestSuite.isTravis()) { 55 | clusterStarter.undeployVerticle(action); 56 | action.waitStatus(Status.stopped, TIME_OUT, 10); 57 | } 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /rc-roi/src/main/java/org/rcdukes/roi/ROI.java: -------------------------------------------------------------------------------- 1 | package org.rcdukes.roi; 2 | 3 | import java.util.Locale; 4 | 5 | import org.opencv.core.Mat; 6 | import org.opencv.core.Point; 7 | import org.opencv.core.Rect; 8 | import org.opencv.core.Size; 9 | 10 | /** 11 | * a region of interest relative to the screen 12 | * 13 | */ 14 | public class ROI { 15 | double rx, ry, rw, rh; 16 | String name; 17 | 18 | /** 19 | * construct me with the given relative 20 | * 21 | * @param rx 22 | * - relative x 0-1 23 | * @param ry 24 | * - relative y 0-1 25 | * @param rw 26 | * - relative width 0-1 27 | * @param rh 28 | * - relative height 0-1 29 | */ 30 | public ROI(String name,double rx, double ry, double rw, double rh) { 31 | this.name=name; 32 | this.rx = rx; 33 | this.ry = ry; 34 | this.rw = rw; 35 | this.rh = rh; 36 | } 37 | 38 | /** 39 | * create a rectangle based on the given OpenCV Size 40 | * 41 | * @param base 42 | * - the base size to use 43 | * @return - the rectangle 44 | */ 45 | public Rect roiRect(Size base) { 46 | double roiX = base.width * rx; 47 | double roiY = base.height * ry; 48 | double roiWidth = base.width * rw; 49 | double roiHeight = base.height * rh; 50 | 51 | Point origin = new Point(roiX, roiY); 52 | Size roiSize = new Size(roiWidth, roiHeight); 53 | 54 | return new Rect(origin, roiSize); 55 | } 56 | 57 | /** 58 | * construct the region of interest image from the given base image 59 | * 60 | * @param image 61 | * @return the region of interest image 62 | */ 63 | public Mat region(Mat image) { 64 | // Use 2-arg constructor to create region image backed by original image 65 | // data 66 | Rect roiRect = roiRect(image.size()); 67 | return new Mat(image,roiRect); 68 | } 69 | 70 | public String toString() { 71 | String text=String.format(Locale.ENGLISH,"pos (%.1f x %.1f) - size (%.1f x %.1f)",rx,ry,rw,rh); 72 | return text; 73 | } 74 | 75 | } 76 | -------------------------------------------------------------------------------- /rc-drivecontrol/src/main/java/org/rcdukes/drivecontrol/EngineMap.java: -------------------------------------------------------------------------------- 1 | package org.rcdukes.drivecontrol; 2 | 3 | import org.rcdukes.car.ServoCommand; 4 | import org.rcdukes.car.ServoRange; 5 | import org.rcdukes.car.ServoSide; 6 | import org.rcdukes.error.ErrorHandler; 7 | 8 | import org.rcdukes.common.Config; 9 | import org.rcdukes.common.Environment; 10 | import org.rcdukes.common.ServoPosition; 11 | 12 | /** 13 | * engine parameters which are vehicle dependent 14 | * 15 | */ 16 | public class EngineMap extends ServoRangeMap { 17 | 18 | /** 19 | * configure me from the given ServoCommand 20 | * 21 | * @param servoCommand 22 | */ 23 | public EngineMap(ServoCommand servoCommand) { 24 | Environment env = Config.getEnvironment(); 25 | try { 26 | int ENGINE_GPIO = env.getInteger(Config.ENGINE_GPIO); 27 | int SPEED_STEP_SIZE = env.getInteger(Config.ENGINE_STEP_SIZE); 28 | String ENGINE_ORIENTATION = env.getString(Config.ENGINE_ORIENTATION); 29 | super.configure(ENGINE_GPIO, servoCommand,ENGINE_ORIENTATION); 30 | ServoPosition minforward = new ServoPosition(Config.ENGINE_MIN_SPEED_FORWARD,Config.ENGINE_MIN_VELOCITY_FORWARD); 31 | ServoPosition maxforward = new ServoPosition(Config.ENGINE_MAX_SPEED_FORWARD,Config.ENGINE_MAX_VELOCITY_FORWARD); 32 | ServoPosition minreverse = new ServoPosition(Config.ENGINE_MIN_SPEED_REVERSE,Config.ENGINE_MIN_VELOCITY_REVERSE); 33 | ServoPosition maxreverse = new ServoPosition(Config.ENGINE_MAX_SPEED_REVERSE,Config.ENGINE_MAX_VELOCITY_REVERSE); 34 | ServoSide sideN=new ServoSide("reverse",-1,minreverse,maxreverse); 35 | ServoSide sideP=new ServoSide("forward",1,minforward,maxforward); 36 | ServoPosition neutral = new ServoPosition(Config.ENGINE_SPEED_ZERO,Config.ZERO); 37 | setRange(new ServoRange(SPEED_STEP_SIZE, sideN, neutral, sideP)); 38 | setName("Engine"); 39 | setUnit(" m/s"); 40 | check(); 41 | } catch (Exception e) { 42 | ErrorHandler.getInstance().handle(e, 43 | "you might want to check you settings"); 44 | } 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /rc-camera-matrix/src/main/java/org/rcdukes/camera/PerspectiveShift.java: -------------------------------------------------------------------------------- 1 | package org.rcdukes.camera; 2 | 3 | import java.util.List; 4 | import java.util.function.UnaryOperator; 5 | import java.util.stream.Collectors; 6 | 7 | import org.opencv.core.Mat; 8 | import org.opencv.core.MatOfPoint2f; 9 | import org.opencv.core.Point; 10 | import org.opencv.imgproc.Imgproc; 11 | import org.rcdukes.geometry.Polygon; 12 | 13 | /** 14 | * perspective shift 15 | */ 16 | public class PerspectiveShift implements UnaryOperator { 17 | 18 | final Polygon imagePolygon; 19 | final Polygon worldPolygon; 20 | List imagePoints; 21 | List worldPoints; 22 | Mat perspectiveTransform; 23 | 24 | /** 25 | * construct me from the given image and worl polygon 26 | * @param imagePolygon - image 27 | * @param worldPolygon - world 28 | */ 29 | public PerspectiveShift(Polygon imagePolygon, Polygon worldPolygon) { 30 | this.imagePolygon = imagePolygon; 31 | this.worldPolygon = worldPolygon; 32 | buildPerspectiveTransform(); 33 | } 34 | 35 | /** 36 | * create the perspective transform 37 | */ 38 | private void buildPerspectiveTransform() { 39 | 40 | imagePoints = this.imagePolygon.getPointsCounterClockwise().stream().map(point -> new Point(point.getX(), point.getY())).collect(Collectors.toList()); 41 | worldPoints = this.worldPolygon.getPointsCounterClockwise().stream().map(point -> new Point(point.getX(), point.getY())).collect(Collectors.toList()); 42 | 43 | MatOfPoint2f imagePointsMat = new MatOfPoint2f(); 44 | MatOfPoint2f worldPointsMat = new MatOfPoint2f(); 45 | 46 | imagePointsMat.fromList(imagePoints); 47 | worldPointsMat.fromList(worldPoints); 48 | 49 | this.perspectiveTransform = Imgproc.getPerspectiveTransform(worldPointsMat, imagePointsMat); 50 | } 51 | 52 | @Override 53 | public Mat apply(Mat srcImage) { 54 | Mat destImage = new Mat(); 55 | Imgproc.warpPerspective(srcImage, destImage, perspectiveTransform, srcImage.size()); 56 | return destImage; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /rc-common/src/test/java/org/rcdukes/common/TestGraphDatabase.java: -------------------------------------------------------------------------------- 1 | package org.rcdukes.common; 2 | 3 | import static org.junit.Assert.*; 4 | 5 | import java.io.File; 6 | import java.io.IOException; 7 | 8 | import org.apache.tinkerpop.gremlin.structure.Vertex; 9 | import org.junit.Test; 10 | 11 | /** 12 | * test the graph database 13 | * @author wf 14 | * 15 | */ 16 | public class TestGraphDatabase { 17 | /** 18 | * example class to test object mapping 19 | * @author wf 20 | * 21 | */ 22 | public static class Person { 23 | public String name; 24 | public int age; 25 | public Person() {} 26 | public Person(String name, int age) { 27 | super(); 28 | this.name = name; 29 | this.age = age; 30 | } 31 | 32 | } 33 | 34 | @Test 35 | public void testTinkerPopDatabase() throws IOException { 36 | TinkerPopDatabase tpd = new TinkerPopDatabase(); 37 | tpd.addVertex(new Person("marko",29)); 38 | long milliTimeStamp=System.currentTimeMillis(); 39 | tpd.addVertex(new ServoPosition(154,0.5,"m/s","motor")); 40 | assertEquals(2,tpd.g().V().count().next().longValue()); 41 | File gFile = File.createTempFile("gremlin", ".json"); 42 | tpd.writeGraph(gFile.getPath()); 43 | TinkerPopDatabase tpd2=new TinkerPopDatabase(); 44 | tpd2.debug=true; 45 | tpd2.loadGraph(gFile); 46 | assertEquals(2,tpd2.g().V().count().next().longValue()); 47 | Vertex markoVertex=tpd2.g().V().has("name","marko").next(); 48 | assertNotNull(markoVertex); 49 | Person marko=tpd2.fromVertex(markoVertex, Person.class); 50 | assertNotNull(marko); 51 | assertEquals("marko",marko.name); 52 | assertEquals(29,marko.age); 53 | Vertex servoPosVertex=tpd2.g().V().hasLabel("ServoPosition").next(); 54 | assertNotNull(servoPosVertex); 55 | ServoPosition pos2=tpd2.fromVertex(servoPosVertex, ServoPosition.class); 56 | assertEquals(154,pos2.getServoPos()); 57 | assertEquals(0.5,pos2.getValue(),0.001); 58 | assertEquals("m/s",pos2.unit); 59 | assertEquals("motor",pos2.kind); 60 | assertEquals(milliTimeStamp*1.0,pos2.milliTimeStamp*1.0,2); 61 | gFile.delete(); 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /rc-detect/src/test/java/org/rcdukes/detect/TestHoughLinesDetector.java: -------------------------------------------------------------------------------- 1 | package org.rcdukes.detect; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | 5 | import java.util.Collection; 6 | 7 | import org.junit.Test; 8 | import org.opencv.core.Mat; 9 | import org.opencv.imgproc.Imgproc; 10 | import org.rcdukes.detect.linedetection.HoughLinesLineDetector; 11 | import org.rcdukes.geometry.Line; 12 | import org.rcdukes.video.ImageUtils; 13 | import org.rcdukes.video.ImageUtils.CVColor; 14 | 15 | /** 16 | * test for hough lines detection 17 | * 18 | * @author wf 19 | * 20 | */ 21 | public class TestHoughLinesDetector extends BaseDetectTest { 22 | 23 | public Mat getCanny(Mat frame, double treshold1, double treshold2, 24 | int apertureSize) { 25 | Mat mGray = new Mat(); 26 | Imgproc.cvtColor(frame, mGray, Imgproc.COLOR_BGR2GRAY); 27 | Mat canny = new Mat(); 28 | Imgproc.Canny(mGray, canny, treshold1, treshold2, apertureSize, false); 29 | return canny; 30 | } 31 | 32 | public Mat getTestImage2() throws Exception { 33 | Mat frame = ImageUtils.fromResource(this.getClass(), "images/sudoku.jpg"); 34 | return frame; 35 | } 36 | 37 | @Test 38 | public void testProbabilisticHoughLinesDetector() throws Exception { 39 | HoughLinesLineDetector hld = new HoughLinesLineDetector(); 40 | Mat frame = getTestImage2(); 41 | Mat canny = getCanny(frame, 50, 200, 3); // 772,65 42 | Collection lines = hld.detect(canny); 43 | assertEquals(192, lines.size()); 44 | ImageUtils iu = new ImageUtils(); 45 | iu.writeImageWithLines(frame, lines, "houghlinesp.jpg", CVColor.red); 46 | } 47 | 48 | @Test 49 | public void testHoughLinesDetector() throws Exception { 50 | HoughLinesLineDetector hld = new HoughLinesLineDetector(); 51 | hld.setProbabilistic(false); 52 | hld.setThreshold(150); 53 | Mat frame = getTestImage2(); 54 | Mat canny = getCanny(frame, 50,200,3); 55 | Collection lines = hld.detect(canny); 56 | assertEquals(62, lines.size()); 57 | ImageUtils iu = new ImageUtils(); 58 | iu.writeImageWithLines(frame, lines, "houghlines.jpg", CVColor.dodgerblue); 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /rc-common/src/main/java/org/rcdukes/error/ErrorHandler.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * This file is part of the https://github.com/BITPlan/com.bitplan.gui open source project 4 | * 5 | * Copyright 2017 BITPlan GmbH https://github.com/BITPlan 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * 10 | * You may obtain a copy of the License at 11 | * 12 | * http:www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | */ 21 | package org.rcdukes.error; 22 | 23 | import java.io.PrintWriter; 24 | import java.io.StringWriter; 25 | 26 | import org.slf4j.Logger; 27 | import org.slf4j.LoggerFactory; 28 | 29 | /** 30 | * simple ErrorHandler 31 | * @author wf 32 | * 33 | */ 34 | public class ErrorHandler implements ExceptionHandler { 35 | private static final Logger LOG=LoggerFactory.getLogger(ErrorHandler.class); 36 | 37 | @Override 38 | public void handle(Throwable th, String msg) { 39 | if (msg==null) { 40 | msg=""; 41 | } else { 42 | msg="("+msg+")"; 43 | } 44 | LOG.warn("Error " + th.getClass().getName()+msg+":"+ th.getMessage()); 45 | StringWriter sw = new StringWriter(); 46 | th.printStackTrace(new PrintWriter(sw)); 47 | LOG.warn("Stacktrace: " + sw.toString()); 48 | } 49 | 50 | @Override 51 | public void warn(String msg) { 52 | LOG.warn(msg); 53 | } 54 | 55 | @Override 56 | public void handle(Throwable th) { 57 | handle(th,null); 58 | } 59 | private static ErrorHandler instance; 60 | private ErrorHandler() { 61 | 62 | } 63 | 64 | /** 65 | * singleton access 66 | * @return the singleton 67 | */ 68 | public static ErrorHandler getInstance() { 69 | if (instance==null) 70 | instance=new ErrorHandler(); 71 | return instance; 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /rc-app/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | 8 | org.rcdukes 9 | dukes 10 | 0.0.3 11 | 12 | 13 | org.rcdukes.dukes 14 | rc-app 15 | JavaFX app to monitor the car 16 | 17 | 18 | org.rcdukes.app.DukesFxApp 19 | 20 | 21 | 22 | 23 | args4j 24 | args4j 25 | 26 | 27 | org.rcdukes.dukes 28 | rc-common 29 | 0.0.3 30 | 31 | 32 | org.rcdukes.dukes 33 | rc-detect 34 | 0.0.3 35 | 36 | 37 | org.rcdukes.dukes 38 | rc-action 39 | 0.0.3 40 | 41 | 42 | io.vertx 43 | vertx-rx-java 44 | 45 | 46 | io.vertx 47 | vertx-web 48 | 49 | 50 | ch.qos.logback 51 | logback-classic 52 | 53 | 54 | de.jensd 55 | fontawesomefx 56 | 8.9 57 | 58 | 59 | 60 | eu.hansolo 61 | Medusa 62 | 8.2 63 | 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /rc-geometry/src/main/java/org/rcdukes/geometry/pointinplane/CrossingNumber.java: -------------------------------------------------------------------------------- 1 | package org.rcdukes.geometry.pointinplane; 2 | 3 | import org.rcdukes.geometry.Point2D; 4 | import org.rcdukes.geometry.Polygon; 5 | 6 | /** 7 | * Created by jpoint on 16/08/16. 8 | */ 9 | public class CrossingNumber implements PointInPlane { 10 | @Override 11 | public boolean isPointInPlane(Point2D point, Polygon polygon) { 12 | return crossingNumber(point, polygon.getPoints().toArray(new Point2D[]{})) != 0; 13 | } 14 | 15 | // Copyright 2000 softSurfer, 2012 Dan Sunday 16 | // This code may be freely used and modified for any purpose 17 | // providing that this copyright notice is included with it. 18 | // SoftSurfer makes no warranty for this code, and cannot be held 19 | // liable for any real or imagined damage resulting from its use. 20 | // Users of this code must verify correctness for their application. 21 | 22 | /** 23 | * crossingNumber(): crossing number test for a point in a polygon 24 | * Input: P = a point, 25 | * V[] = vertex points of a polygon V[n+1] with V[n]=V[0] 26 | * Return: 0 = outside, 1 = inside 27 | * This code is patterned after [Franklin, 2000] 28 | */ 29 | int crossingNumber(Point2D P, Point2D[] V) { 30 | int cn = 0; // the crossing number counter 31 | 32 | // loop through all edges of the polygon 33 | for (int i=0; i P.getY())) // an upward crossing 35 | || ((V[i].getY() > P.getY()) && (V[i+1].getY() <= P.getY()))) { // a downward crossing 36 | // compute the actual edge-ray intersect x-coordinate 37 | double vt = (P.getY() - V[i].getY()) / (V[i+1].getY() - V[i].getY()); 38 | if (P.getX() < V[i].getX() + vt * (V[i+1].getX() - V[i].getX())) // P.getX() < intersect 39 | ++cn; // a valid crossing of y=P.getY() right of P.getX() 40 | } 41 | } 42 | return (cn&1); // 0 if even (out), and 1 if odd (in) 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /rc-watchdog/src/test/java/org/rcdukes/watchdog/TestWatchDog.java: -------------------------------------------------------------------------------- 1 | package org.rcdukes.watchdog; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | import static org.junit.Assert.assertNotNull; 5 | import static org.junit.Assert.assertTrue; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | import org.rcdukes.watchdog.WatchDog; 10 | import org.slf4j.Logger; 11 | import org.slf4j.LoggerFactory; 12 | 13 | import io.vertx.core.Vertx; 14 | import io.vertx.ext.unit.junit.VertxUnitRunner; 15 | import org.rcdukes.common.Characters; 16 | import org.rcdukes.common.ClusterStarter; 17 | import org.rcdukes.common.Config; 18 | import org.rcdukes.common.Environment; 19 | import org.rcdukes.common.DukesVerticle.Status; 20 | import org.rcdukes.drivecontrol.Car; 21 | import org.rcdukes.drivecontrol.TestCar; 22 | 23 | /** 24 | * test the WatchDog Verticle 25 | * 26 | * @author wf 27 | * 28 | */ 29 | @RunWith(VertxUnitRunner.class) 30 | public class TestWatchDog { 31 | private static final Logger LOG = LoggerFactory.getLogger(TestWatchDog.class); 32 | @Test 33 | public void testWatchDog() throws Exception { 34 | ClusterStarter clusterStarter=new ClusterStarter(); 35 | // sideffect is to use dummy configuration 36 | // which also effects watchdog 37 | Car car=TestCar.getCar(); 38 | Environment env = Config.getEnvironment(); 39 | int heartBeatInterval=env.getInteger(Config.WATCHDOG_HEARTBEAT_INTERVAL_MS); 40 | assertEquals(20,heartBeatInterval); 41 | int maxMissedBeats=env.getInteger(Config.WATCHDOG_MAX_MISSED_BEATS); 42 | assertEquals(2,maxMissedBeats); 43 | 44 | WatchDog watchDog=new WatchDog(car); 45 | 46 | clusterStarter.deployVerticles(watchDog); 47 | watchDog.waitStatus(Status.started,20000,10); 48 | Vertx vertx=clusterStarter.getVertx(); 49 | assertNotNull(vertx); 50 | assertEquals(watchDog.getVertx(),vertx); 51 | watchDog.send(Characters.FLASH,"type","heartbeat"); 52 | // car should power on by heartbeat 53 | int loops=0; 54 | while(!car.powerIsOn() && loops<=100) { 55 | Thread.sleep(10); 56 | loops++; 57 | } 58 | assertTrue(loops<100); 59 | LOG.info(String.format("car powered on after %3d msecs",loops*10)); 60 | Thread.sleep(heartBeatInterval*(maxMissedBeats+3)); 61 | assertTrue(!car.powerIsOn()); 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /rc-detect/src/main/java/org/rcdukes/detect/edgedectection/WatershedEdgeDetector.java: -------------------------------------------------------------------------------- 1 | package org.rcdukes.detect.edgedectection; 2 | 3 | import org.opencv.core.*; 4 | import org.opencv.imgproc.Imgproc; 5 | import org.rcdukes.detectors.EdgeDetector; 6 | 7 | import static org.opencv.core.CvType.CV_32S; 8 | 9 | public class WatershedEdgeDetector implements EdgeDetector { 10 | 11 | private double threshold = 100; 12 | private double max = 255; 13 | private int iterations = 1; 14 | private double dilatedThreshold = 1; 15 | private double dilatedMax = 1; 16 | 17 | public WatershedEdgeDetector() {} 18 | 19 | public WatershedEdgeDetector(double threshold, double max, int iterations, double dilatedThreshold, double dilatedMax) { 20 | this(); 21 | this.threshold = threshold; 22 | this.max = max; 23 | this.iterations = iterations; 24 | this.dilatedThreshold = dilatedThreshold; 25 | this.dilatedMax = dilatedMax; 26 | } 27 | 28 | @Override 29 | public Mat detect(Mat image) { 30 | Mat imgRgb = new Mat(); 31 | Imgproc.cvtColor(image, imgRgb, Imgproc.COLOR_RGBA2RGB); 32 | 33 | Mat imgGray = new Mat(); 34 | Imgproc.cvtColor(imgRgb, imgGray, Imgproc.COLOR_RGBA2GRAY); 35 | Imgproc.threshold(imgGray, imgGray, threshold, max, Imgproc.THRESH_BINARY); 36 | 37 | Mat imgEroded = new Mat(); 38 | Imgproc.erode(imgGray,imgEroded,new Mat(),new Point(-1,-1),iterations); 39 | 40 | Mat imgDilated = new Mat(); 41 | Imgproc.dilate(imgGray,imgDilated,new Mat(),new Point(-1,-1),iterations); 42 | 43 | Imgproc.threshold(imgDilated,imgDilated,dilatedThreshold, dilatedMax, Imgproc.THRESH_BINARY_INV); 44 | Mat markerImage = new Mat(imgGray.size(), CvType.CV_8U, new Scalar(0)); 45 | Core.add(imgEroded, imgDilated, markerImage); 46 | 47 | Mat markers = new Mat(); 48 | markerImage.convertTo(markers, CV_32S); 49 | 50 | Imgproc.watershed(imgRgb, markers); 51 | markerImage.convertTo(markerImage,CvType.CV_8U); 52 | 53 | imgRgb.release(); 54 | imgGray.release(); 55 | imgEroded.release(); 56 | imgDilated.release(); 57 | markers.release(); 58 | 59 | return markerImage; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /rc-car/src/test/java/org/rcdukes/car/TestHandlers.java: -------------------------------------------------------------------------------- 1 | package org.rcdukes.car; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | 5 | import org.junit.Test; 6 | import org.rcdukes.car.SteeringHandler; 7 | import org.rcdukes.common.Config; 8 | import org.rcdukes.common.ServoPosition; 9 | 10 | import io.vertx.core.json.JsonObject; 11 | import org.rcdukes.car.Steering; 12 | import org.rcdukes.drivecontrol.Car; 13 | import org.rcdukes.drivecontrol.TestCar; 14 | 15 | /** 16 | * test the speed and engine handlers 17 | * 18 | * @author wf 19 | * 20 | */ 21 | public class TestHandlers extends TestCar { 22 | 23 | public static boolean debug=true; 24 | 25 | 26 | @Test 27 | public void testSteeringHandler() throws Exception { 28 | Car car=getCar(); 29 | // make sure commands are accepted 30 | car.setPowerOn(); 31 | SteeringHandler sh=new SteeringHandler(car); 32 | Steering steering = car.getSteering(); 33 | JsonObject msg=new JsonObject(); 34 | msg.put("position",Config.POSITION_CENTER); 35 | sh.handleServo(msg); 36 | assertEquals(130,steering.getServo()); 37 | msg.put("position",Config.POSITION_LEFT); 38 | sh.handleServo(msg); 39 | assertEquals(125,steering.getServo()); 40 | msg.put("position",Config.POSITION_LEFT); 41 | sh.handleServo(msg); 42 | assertEquals(120,steering.getServo()); 43 | if (debug) 44 | servoCommand.showLog(); 45 | } 46 | 47 | 48 | @Test 49 | public void testSteeringAngles() throws Exception { 50 | Car car=getCar(); 51 | // make sure commands are accepted 52 | car.setPowerOn(); 53 | SteeringHandler sh=new SteeringHandler(car); 54 | double angles[]= {-45,-30,-20,-10,-5,0,5,10,20,30,45}; 55 | double expectedValues[] = {-20,-20,-20,-10,-5,0,5,10,20,25,25}; 56 | int index=0; 57 | for (double angle:angles) { 58 | JsonObject angleJo=new JsonObject(); 59 | angleJo.put("angle", new Double(angle)); 60 | ServoPosition anglePos = sh.handleServoAngle(angleJo); 61 | String msg=String.format("steering %5.1f° (%3d) for wanted angle %5.1f°", anglePos.getValue(),anglePos.getServoPos(),angle); 62 | if (debug) 63 | System.out.println(msg); 64 | assertEquals(expectedValues[index],anglePos.getValue(),0.001); 65 | index++; 66 | } 67 | } 68 | 69 | } 70 | -------------------------------------------------------------------------------- /rc-drivecontrol/src/test/java/org/rcdukes/drivecontrol/ServoCommandDummy.java: -------------------------------------------------------------------------------- 1 | package org.rcdukes.drivecontrol; 2 | 3 | import java.time.Instant; 4 | 5 | import org.apache.tinkerpop.gremlin.process.traversal.Order; 6 | import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; 7 | import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph; 8 | import org.rcdukes.car.ServoCommand; 9 | 10 | /** 11 | * ServoCommand Dummy 12 | * @author wf 13 | * 14 | */ 15 | public class ServoCommandDummy implements ServoCommand { 16 | // we'll remember the values in an in-memory graph database 17 | private TinkerGraph graph; 18 | private long start; 19 | 20 | /** 21 | * create the dummy 22 | */ 23 | public ServoCommandDummy() { 24 | graph = TinkerGraph.open(); 25 | // reset the log 26 | resetLog(); 27 | } 28 | 29 | /** 30 | * get the graph database going 31 | */ 32 | public void resetLog() { 33 | start=Instant.now().getNano()/1000000; 34 | } 35 | 36 | 37 | @Override 38 | public void setServo(int gpioPin, int value) { 39 | long now = Instant.now().getNano()/1000000; 40 | // remember the values set with the corresponding time stamps 41 | graph.addVertex("label", "servo", "gpioPin", gpioPin, "value", value, 42 | "timestamp", now,"relative",now-start); 43 | // wait a millisecond since we can't measure time 44 | // more precisely without effort 45 | try { 46 | Thread.sleep(1); 47 | } catch (InterruptedException e) { 48 | // ignore 49 | } 50 | } 51 | 52 | /** 53 | * get a graph traversal source 54 | * 55 | * @return - the graph traversal source 56 | */ 57 | public GraphTraversalSource g() { 58 | return graph.traversal(); 59 | } 60 | 61 | /** 62 | * show the log of events 63 | */ 64 | public void showLog() { 65 | int index[] = { 0 }; 66 | g().V().order().by("timestamp",Order.incr).forEachRemaining(eventV -> { 67 | System.out.print(String.format("%4d:", ++index[0])); 68 | for (String key : eventV.keys()) { 69 | System.out.println(String.format("\t%s=%s", key,eventV.property(key).value().toString())); 70 | } 71 | }); 72 | } 73 | } -------------------------------------------------------------------------------- /rc-server/src/test/java/org/rcsdukes/server/TestEventBusBridge.java: -------------------------------------------------------------------------------- 1 | package org.rcsdukes.server; 2 | 3 | import org.junit.Test; 4 | import org.rcdukes.common.Characters; 5 | import org.rcdukes.common.ClusterStarter; 6 | import org.rcdukes.common.DukesVerticle; 7 | import org.rcdukes.common.DukesVerticle.Status; 8 | import org.rcdukes.common.Environment; 9 | 10 | import io.vertx.core.json.JsonObject; 11 | import io.vertx.ext.bridge.BridgeOptions; 12 | import io.vertx.ext.bridge.PermittedOptions; 13 | import io.vertx.rxjava.core.eventbus.EventBus; 14 | import io.vertx.rxjava.core.eventbus.MessageConsumer; 15 | import io.vertx.rxjava.ext.eventbus.bridge.tcp.TcpEventBusBridge; 16 | 17 | public class TestEventBusBridge { 18 | 19 | /** 20 | * 21 | * @author jay 22 | */ 23 | public class EchoServer extends DukesVerticle { 24 | 25 | public EchoServer(Characters character) { 26 | super(character); 27 | } 28 | 29 | static final String ADDRESS = "echo"; 30 | 31 | @Override 32 | public void start() throws Exception { 33 | super.preStart(); 34 | 35 | TcpEventBusBridge bridge = TcpEventBusBridge.create(vertx, 36 | new BridgeOptions() 37 | .addInboundPermitted(new PermittedOptions().setAddress(ADDRESS)) 38 | .addOutboundPermitted( 39 | new PermittedOptions().setAddress(ADDRESS))); 40 | 41 | bridge.listen(7001, res -> { 42 | if (res.succeeded()) { 43 | 44 | } else { 45 | System.exit(0); 46 | } 47 | }); 48 | EventBus eb = vertx.eventBus(); 49 | 50 | MessageConsumer consumer = eb.consumer(ADDRESS, message -> { 51 | message.reply(message.body()); 52 | }); 53 | super.postStart(); 54 | } 55 | } 56 | 57 | @Test 58 | public void testEventBusBridge() throws Exception { 59 | Environment.mock(); 60 | ClusterStarter starter = new ClusterStarter(); 61 | starter.prepare(); 62 | EchoServer echoVerticle = new EchoServer(Characters.COY); 63 | DukesVerticle.debug = true; 64 | starter.deployVerticles(echoVerticle); 65 | echoVerticle.waitStatus(Status.started, 15000, 10); 66 | starter.undeployVerticle(echoVerticle); 67 | if (!TestSuite.isTravis()) 68 | echoVerticle.waitStatus(Status.stopped, 15000, 10); 69 | } 70 | 71 | } 72 | -------------------------------------------------------------------------------- /rc-app/src/main/resources/fx/lanedetection.fxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 45 | -------------------------------------------------------------------------------- /rc-roi/src/main/java/org/rcdukes/opencv/OsCheck.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2018 BITPlan GmbH 3 | * 4 | * http://www.bitplan.com 5 | * 6 | * This file is part of the Opensource project at: 7 | * https://github.com/BITPlan/com.bitplan.dragtop 8 | * 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | */ 21 | package org.rcdukes.opencv; 22 | 23 | import java.util.Locale; 24 | 25 | /** 26 | * helper class to check the operating system this Java VM runs in 27 | * 28 | * please keep the notes below as a pseudo-license 29 | * 30 | * http://stackoverflow.com/questions/228477/how-do-i-programmatically-determine-operating-system-in-java 31 | * compare to http://svn.terracotta.org/svn/tc/dso/tags/2.6.4/code/base/common/src/com/tc/util/runtime/Os.java 32 | * http://www.docjar.com/html/api/org/apache/commons/lang/SystemUtils.java.html 33 | */ 34 | public final class OsCheck { 35 | /** 36 | * types of Operating Systems 37 | */ 38 | public enum OSType { 39 | Windows, MacOS, Linux, Other 40 | }; 41 | 42 | // cached result of OS detection 43 | protected static OSType detectedOS; 44 | 45 | /** 46 | * detect the operating system from the os.name System property and cache the 47 | * result 48 | * 49 | * @return - the operating system detected 50 | */ 51 | public static OSType getOperatingSystemType() { 52 | if (detectedOS == null) { 53 | String OS = System.getProperty("os.name", "generic").toLowerCase(Locale.ENGLISH); 54 | if ((OS.indexOf("mac") >= 0) || (OS.indexOf("darwin") >= 0)) { 55 | detectedOS = OSType.MacOS; 56 | } else if (OS.indexOf("win") >= 0) { 57 | detectedOS = OSType.Windows; 58 | } else if (OS.indexOf("nux") >= 0) { 59 | detectedOS = OSType.Linux; 60 | } else { 61 | detectedOS = OSType.Other; 62 | } 63 | } 64 | return detectedOS; 65 | } 66 | } -------------------------------------------------------------------------------- /rc-drivecontrol/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | 8 | org.rcdukes 9 | dukes 10 | 0.0.3 11 | 12 | 13 | org.rcdukes.dukes 14 | rc-drivecontrol 15 | Car/Engine/Steering 16 | 17 | true 18 | 19 | org.rcdukes.dukes.car.AdaFruit 20 | 21 | 22 | 23 | io.vertx 24 | vertx-core 25 | 26 | 27 | io.vertx 28 | vertx-rx-java 29 | 30 | 31 | io.vertx 32 | vertx-hazelcast 33 | 34 | 35 | org.rcdukes.dukes 36 | rc-common 37 | 0.0.3 38 | 39 | 40 | org.apache.tinkerpop 41 | tinkergraph-gremlin 42 | 43 | 44 | ch.qos.logback 45 | logback-classic 46 | 47 | 48 | 49 | com.pi4j 50 | pi4j-core 51 | 1.2 52 | 53 | 54 | 55 | com.pi4j 56 | pi4j-gpio-extension 57 | 1.2 58 | 59 | 60 | args4j 61 | args4j 62 | 63 | 64 | 65 | 66 | 67 | 68 | maven-jar-plugin 69 | 70 | 71 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /rc-watchdog/src/test/java/org/rcdukes/watchdog/TestAsync.java: -------------------------------------------------------------------------------- 1 | package org.rcdukes.watchdog; 2 | 3 | import static org.junit.Assert.assertNotNull; 4 | 5 | import java.io.IOException; 6 | import java.util.concurrent.atomic.AtomicBoolean; 7 | 8 | import org.apache.tinkerpop.shaded.minlog.Log; 9 | import org.junit.Before; 10 | import org.junit.Test; 11 | import org.junit.runner.RunWith; 12 | import org.rcdukes.common.ClusterStarter; 13 | import org.slf4j.Logger; 14 | import org.slf4j.LoggerFactory; 15 | 16 | import io.vertx.core.AsyncResult; 17 | import io.vertx.core.DeploymentOptions; 18 | import io.vertx.core.Handler; 19 | import io.vertx.core.Vertx; 20 | import io.vertx.core.json.JsonObject; 21 | import io.vertx.ext.unit.Async; 22 | import io.vertx.ext.unit.TestContext; 23 | import io.vertx.ext.unit.junit.VertxUnitRunner; 24 | 25 | /** 26 | * test the WatchDog Verticle 27 | * 28 | * @author wf 29 | * 30 | */ 31 | @RunWith(VertxUnitRunner.class) 32 | public class TestAsync { 33 | private static final Logger LOG = LoggerFactory.getLogger(TestAsync.class); 34 | @Test 35 | public void testWatchDog() { 36 | 37 | } 38 | 39 | private Vertx vertx; 40 | 41 | final AtomicBoolean loaded = new AtomicBoolean(false); 42 | 43 | /** 44 | * @see Stackoverflow 45 | * Question for Vertx Unit Testing 46 | * @param context 47 | * @throws IOException 48 | */ 49 | @Before 50 | public void setUp(TestContext context) throws IOException { 51 | ClusterStarter starter=new ClusterStarter(); 52 | starter.clusteredVertx(new Handler>() { 53 | @Override 54 | public void handle(AsyncResult res) { 55 | if (res.succeeded()) { 56 | vertx = res.result(); 57 | 58 | DeploymentOptions options = new DeploymentOptions() 59 | .setConfig(new JsonObject().put("http.port", 8080)); 60 | // vertx.deployVerticle(MyWebService.class.getName(), options, 61 | // context.asyncAssertSuccess()); 62 | Log.info("async deployment SUCCESS"); 63 | loaded.set(true); 64 | } else { 65 | Log.info("async deployment FAILED"); 66 | } 67 | } 68 | }); 69 | } 70 | 71 | @Test 72 | public void testAsync(TestContext context) { 73 | Async async = context.async(); // wait for context 74 | assertNotNull(async); 75 | // System.out.println("Print from method printSomething()"); 76 | async.complete(); 77 | } 78 | 79 | } 80 | -------------------------------------------------------------------------------- /rc-detect/src/main/java/org/rcdukes/detect/CameraConfig.java: -------------------------------------------------------------------------------- 1 | package org.rcdukes.detect; 2 | 3 | import org.rcdukes.common.Config; 4 | 5 | /** 6 | * camera configuration to be exchanged with gui 7 | * @author wf 8 | * 9 | */ 10 | public class CameraConfig { 11 | private String source; 12 | // correction of viewing angle 13 | private double angleOffset=0.0; 14 | private double roih; 15 | private double roiy; 16 | private double fps; 17 | private boolean showStoppingZone=false; 18 | /** 19 | * construct me 20 | */ 21 | public CameraConfig() { 22 | fps=10.0; 23 | setRoiy(44); // 44% offset 24 | setRoih(100); // full rest height 25 | try { 26 | source = Config.getEnvironment().getString(Config.CAMERA_URL); 27 | } catch (Exception e) { 28 | org.rcdukes.error.ErrorHandler.getInstance().handle(e); 29 | } 30 | } 31 | 32 | public double getAngleOffset() { 33 | return angleOffset; 34 | } 35 | 36 | public void setAngleOffset(double angleOffset) { 37 | this.angleOffset = angleOffset; 38 | } 39 | 40 | public long getInterval() { 41 | return Math.round(1000/fps); 42 | } 43 | 44 | /** 45 | * @return the roiy 46 | */ 47 | public double getRoiy() { 48 | return roiy; 49 | } 50 | 51 | /** 52 | * @param roiy the roiy to set 53 | */ 54 | public void setRoiy(double roiy) { 55 | this.roiy = roiy; 56 | } 57 | 58 | /** 59 | * @return the roih 60 | */ 61 | public double getRoih() { 62 | return roih; 63 | } 64 | 65 | /** 66 | * @param roih the roih to set 67 | */ 68 | public void setRoih(double roih) { 69 | this.roih = roih; 70 | } 71 | 72 | public String getSource() { 73 | return source; 74 | } 75 | 76 | public void setSource(String source) { 77 | this.source = source; 78 | } 79 | 80 | public double getFps() { 81 | return fps; 82 | } 83 | 84 | public void setFps(double fps) { 85 | this.fps = fps; 86 | } 87 | 88 | /** 89 | * @return the showStoppingZone 90 | */ 91 | public boolean isShowStoppingZone() { 92 | return showStoppingZone; 93 | } 94 | 95 | /** 96 | * @param showStoppingZone the showStoppingZone to set 97 | */ 98 | public void setShowStoppingZone(boolean showStoppingZone) { 99 | this.showStoppingZone = showStoppingZone; 100 | } 101 | 102 | } 103 | -------------------------------------------------------------------------------- /rc-detect/src/main/java/org/rcdukes/detect/linedetection/LineFilter.java: -------------------------------------------------------------------------------- 1 | package org.rcdukes.detect.linedetection; 2 | 3 | import org.opencv.core.Mat; 4 | import org.opencv.core.Point; 5 | 6 | import org.rcdukes.geometry.Line; 7 | 8 | import java.util.*; 9 | 10 | import static java.lang.Math.atan2; 11 | import static java.lang.Math.toDegrees; 12 | import static java.lang.Math.toRadians; 13 | 14 | /** 15 | * filters lines 16 | */ 17 | public class LineFilter { 18 | 19 | private final double angle; 20 | private final double margin; 21 | private boolean directional; 22 | 23 | /** 24 | * create me 25 | * @param angle 26 | * @param margin 27 | * @param directional 28 | */ 29 | public LineFilter(double angle, double margin, boolean directional) { 30 | this.angle = angle; 31 | this.margin = margin; 32 | this.directional = directional; 33 | } 34 | 35 | public Collection filter(Collection lines) { 36 | double minDeg = angle - margin; 37 | double maxDeg = angle + margin; 38 | double minRad = toRadians(minDeg); 39 | double maxRad = toRadians(maxDeg); 40 | 41 | // System.out.println("min degrees: " + minDeg); 42 | // System.out.println("max degrees: " + maxDeg); 43 | // System.out.println("min radians: " + minRad); 44 | // System.out.println("max radians: " + maxRad); 45 | 46 | Set filtered = new HashSet<>(); 47 | 48 | for (Line line : lines) { 49 | double radian = line.angleRad(); 50 | 51 | if (radian >= minRad && radian <= maxRad) { 52 | filtered.add(line); 53 | } 54 | } 55 | 56 | return filtered; 57 | } 58 | 59 | public void debug(Mat lines) { 60 | System.out.println("debug lines"); 61 | for (int x = 0; x < lines.rows(); x++) { 62 | double[] data = lines.get(x, 0); 63 | double x1 = data[0]; 64 | double y1 = data[1]; 65 | double x2 = data[2]; 66 | double y2 = data[3]; 67 | Point start = new Point(x1, y1); 68 | Point end = new Point(x2, y2); 69 | 70 | double radian = atan2(end.y - start.y, end.x - start.x); 71 | 72 | double deg = toDegrees(radian); 73 | 74 | System.out.println("LINE P("+x1+","+y1+") - P("+x2+","+y2+"), radian: " + radian + ", deg: " +deg); 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /rc-drivecontrol/src/main/java/org/rcdukes/car/ServoRange.java: -------------------------------------------------------------------------------- 1 | package org.rcdukes.car; 2 | 3 | import java.util.Arrays; 4 | 5 | import org.rcdukes.common.ServoPosition; 6 | 7 | /** 8 | * a range for a Servo 9 | * @author wf 10 | * 11 | */ 12 | public class ServoRange { 13 | int stepSize; 14 | 15 | ServoPosition zeroPosition; 16 | ServoSide sideN; 17 | ServoSide sideP; 18 | private ServoPosition max; 19 | private ServoPosition min; 20 | 21 | public int getStepSize() { 22 | return stepSize; 23 | } 24 | public void setStepSize(int stepSize) { 25 | this.stepSize = stepSize; 26 | } 27 | 28 | public ServoPosition getZeroPosition() { 29 | return zeroPosition; 30 | } 31 | public void setZeroPosition(ServoPosition zeroPosition) { 32 | this.zeroPosition = zeroPosition; 33 | } 34 | public ServoSide getSideN() { 35 | return sideN; 36 | } 37 | public void setSideN(ServoSide sideN) { 38 | this.sideN = sideN; 39 | } 40 | public ServoSide getSideP() { 41 | return sideP; 42 | } 43 | public void setSideP(ServoSide sideP) { 44 | this.sideP = sideP; 45 | } 46 | 47 | public ServoPosition getMax() { 48 | return max; 49 | } 50 | public ServoPosition getMin() { 51 | return min; 52 | } 53 | /** 54 | * construct the servo range 55 | * @param stepSize 56 | * @param sideN 57 | * @param zeroPosition 58 | * @param sideP 59 | */ 60 | public ServoRange(int stepSize, ServoSide sideN, ServoPosition zeroPosition, 61 | ServoSide sideP) { 62 | super(); 63 | this.stepSize = stepSize; 64 | this.zeroPosition = zeroPosition; 65 | this.sideN = sideN; 66 | this.sideP = sideP; 67 | this.setMinMax(); 68 | } 69 | 70 | public void setMinMax() { 71 | ServoPosition pos[]= {getSideN().getMin(),getSideN().getMax(),getSideP().getMin(),getSideP().getMax()}; 72 | Arrays.sort(pos, (p1,p2) -> Integer.signum(p1.getServoPos()-p2.getServoPos())); 73 | this.min=pos[0]; 74 | this.max=pos[3]; 75 | } 76 | 77 | /** 78 | * make sure the servo position stays within the valid bounds 79 | * @param pos 80 | * @return the clamped servo position 81 | */ 82 | public int clampServoPos(long pos) { 83 | int servoPos=(int) pos; 84 | if (servoPos < min.getServoPos()) 85 | return min.getServoPos(); 86 | else if (servoPos > max.getServoPos()) 87 | return max.getServoPos(); 88 | else 89 | return servoPos; 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Created by .ignore support plugin (hsz.mobi) 2 | 3 | # eclipse files 4 | .project 5 | .classpath 6 | .settings 7 | 8 | */target/* 9 | *.iml 10 | .idea/* 11 | */.vertx/* 12 | 13 | ### macOS template 14 | *.DS_Store 15 | .AppleDouble 16 | .LSOverride 17 | 18 | # Icon must end with two \r 19 | Icon 20 | 21 | 22 | # Thumbnails 23 | ._* 24 | 25 | # Files that might appear in the root of a volume 26 | .DocumentRevisions-V100 27 | .fseventsd 28 | .Spotlight-V100 29 | .TemporaryItems 30 | .Trashes 31 | .VolumeIcon.icns 32 | .com.apple.timemachine.donotpresent 33 | 34 | # Directories potentially created on remote AFP share 35 | .AppleDB 36 | .AppleDesktop 37 | Network Trash Folder 38 | Temporary Items 39 | .apdisk 40 | ### Java template 41 | # Compiled class file 42 | *.class 43 | 44 | # Log file 45 | *.log 46 | 47 | # BlueJ files 48 | *.ctxt 49 | 50 | # Mobile Tools for Java (J2ME) 51 | .mtj.tmp/ 52 | 53 | # Package Files # 54 | # please note this also ignores the necessary opencv.jar 55 | *.jar 56 | *.war 57 | *.ear 58 | *.zip 59 | *.tar.gz 60 | *.rar 61 | 62 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 63 | hs_err_pid* 64 | ### JetBrains template 65 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm 66 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 67 | 68 | # User-specific stuff: 69 | .idea/**/workspace.xml 70 | .idea/**/tasks.xml 71 | .idea/dictionaries 72 | 73 | # Sensitive or high-churn files: 74 | .idea/**/dataSources/ 75 | .idea/**/dataSources.ids 76 | .idea/**/dataSources.xml 77 | .idea/**/dataSources.local.xml 78 | .idea/**/sqlDataSources.xml 79 | .idea/**/dynamic.xml 80 | .idea/**/uiDesigner.xml 81 | 82 | # Gradle: 83 | .idea/**/gradle.xml 84 | .idea/**/libraries 85 | 86 | # Mongo Explorer plugin: 87 | .idea/**/mongoSettings.xml 88 | 89 | ## File-based project format: 90 | *.iws 91 | 92 | ## Plugin-specific files: 93 | 94 | # IntelliJ 95 | /out/ 96 | 97 | # mpeltonen/sbt-idea plugin 98 | .idea_modules/ 99 | 100 | # JIRA plugin 101 | atlassian-ide-plugin.xml 102 | 103 | # Crashlytics plugin (for Android Studio and IntelliJ) 104 | com_crashlytics_export_strings.xml 105 | crashlytics.properties 106 | crashlytics-build.properties 107 | fabric.properties 108 | 109 | *.iml 110 | .idea 111 | /bin/ 112 | /target 113 | /lib 114 | -------------------------------------------------------------------------------- /rc-detect/src/main/java/org/rcdukes/video/ColorFilter.java: -------------------------------------------------------------------------------- 1 | package org.rcdukes.video; 2 | 3 | import org.opencv.core.Core; 4 | import org.opencv.core.Mat; 5 | import org.opencv.core.Scalar; 6 | 7 | /** 8 | * filter colors in a given range 9 | * 10 | * @author wf 11 | * 12 | */ 13 | public class ColorFilter { 14 | private Scalar minColor; 15 | private Scalar maxColor; 16 | 17 | /** 18 | * set minimum color with relative rgb values 19 | * 20 | * @param r 21 | * - red from 0.0 to 1.0 22 | * @param g 23 | * - green from 0.0 to 1.0 24 | * @param b 25 | * - blue from 0.0 to 1.0 26 | */ 27 | public void setMinColorRGB(double r, double g, double b) { 28 | this.minColor = new Scalar(b * 255, g * 255, r * 255); 29 | } 30 | 31 | /** 32 | * set the minimum rgb color 33 | * @param r red from 0 to 255 34 | * @param g green from 0 to 255 35 | * @param b blue from 0 to 255 36 | */ 37 | public void setMinColorRGB(int r, int g, int b) { 38 | this.minColor=new Scalar(b,g,r); 39 | } 40 | 41 | /** 42 | * set maximum color with rgb values 43 | * 44 | * @param r 45 | * @param g 46 | * @param b 47 | */ 48 | public void setMaxColorRGB(double r, double g, double b) { 49 | this.maxColor = new Scalar(b * 255, g * 255, r * 255); 50 | } 51 | 52 | /** 53 | * set the maximum rgb color 54 | * @param r red from 0 to 255 55 | * @param g green from 0 to 255 56 | * @param b blue from 0 to 255 57 | */ 58 | public void setMaxColorRGB(int r, int g, int b) { 59 | this.maxColor=new Scalar(b,g,r); 60 | } 61 | 62 | /** 63 | * filter by the min and max Colors (if set) 64 | * 65 | * @param image 66 | * - the image to filter 67 | * @return - an image with colors in the given range or the original if not 68 | * both minColor and maxColor have been set 69 | */ 70 | public Mat filter(Mat image) { 71 | Mat imgColorFiltered = image; 72 | if (minColor != null && maxColor != null) { 73 | // https://docs.opencv.org/3.4/da/d97/tutorial_threshold_inRange.html 74 | // https://stackoverflow.com/questions/36693348/java-opencv-core-inrange-input-parameters 75 | Mat imgColorMask = new Mat(); 76 | Core.inRange(image, minColor, maxColor, imgColorMask); 77 | imgColorFiltered = new Mat(); 78 | Core.bitwise_and(image, image, imgColorFiltered, imgColorMask); 79 | } 80 | return imgColorFiltered; 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /rc-detect/src/main/java/org/rcdukes/video/VideoRecorder.java: -------------------------------------------------------------------------------- 1 | package org.rcdukes.video; 2 | 3 | import org.opencv.core.Mat; 4 | import org.opencv.core.Size; 5 | import org.opencv.videoio.VideoWriter; 6 | 7 | /** 8 | * record videos 9 | * @author wf 10 | * 11 | */ 12 | public class VideoRecorder { 13 | 14 | String name; 15 | private VideoWriter save; 16 | private Size frameSize; 17 | private double fps; 18 | 19 | boolean started; 20 | boolean isColor; 21 | public static String exts[]= {".mov",".avi",".mpg"}; 22 | private String ext=".avi"; 23 | private String path; 24 | public static String FOURCCs[]= { "AVC1", "FMP4", "H264", "JPEG","MJPG", "MP4V","X264","XVID" }; 25 | public static String FOURCC="mp4v"; 26 | 27 | /** 28 | * construct me 29 | * @param name - the name of the video - a timestamp will be added 30 | * @param fps - frames per second 31 | */ 32 | public VideoRecorder(String name, double fps) { 33 | this.name=name; 34 | this.fps=fps; 35 | started=false; 36 | } 37 | 38 | // https://stackoverflow.com/questions/53158765/record-and-save-video-stream-use-opencv-in-java 39 | public void start(Size frameSize, boolean isColor) { 40 | this.frameSize=frameSize; 41 | this.isColor=isColor; 42 | int fourcc = VideoWriter.fourcc(FOURCC.charAt(0), FOURCC.charAt(1), FOURCC.charAt(2), FOURCC.charAt(3)); 43 | setPath(ImageUtils.filePath(name+"_"+FOURCC,getExt())); 44 | save = new VideoWriter(getPath(),fourcc, this.fps, this.frameSize, isColor); 45 | started=true; 46 | } 47 | 48 | 49 | /** 50 | * stop the recording 51 | */ 52 | public void stop() { 53 | if (save!=null) 54 | save.release(); 55 | started=false; 56 | } 57 | 58 | /** 59 | * record a single frame 60 | * @param mat - open cv frame to be recorded 61 | */ 62 | public void recordMat(Mat mat) { 63 | if (!started) { 64 | isColor=mat.channels()>1; 65 | this.start(mat.size(),isColor); 66 | } 67 | save.write(mat); 68 | } 69 | 70 | /** 71 | * @return the path 72 | */ 73 | public String getPath() { 74 | return path; 75 | } 76 | 77 | /** 78 | * @param path the path to set 79 | */ 80 | public void setPath(String path) { 81 | this.path = path; 82 | } 83 | 84 | /** 85 | * @return the ext 86 | */ 87 | public String getExt() { 88 | return ext; 89 | } 90 | 91 | /** 92 | * @param ext the ext to set 93 | */ 94 | public void setExt(String ext) { 95 | this.ext = ext; 96 | } 97 | 98 | } 99 | -------------------------------------------------------------------------------- /rc-drivecontrol/src/main/java/org/rcdukes/car/ServoBlaster.java: -------------------------------------------------------------------------------- 1 | package org.rcdukes.car; 2 | 3 | import java.io.File; 4 | import java.io.IOException; 5 | import java.util.HashMap; 6 | import java.util.Map; 7 | 8 | import org.apache.commons.io.FileUtils; 9 | //import nl.revolution.dukes.utils.Environment; 10 | //import nl.vaneijndhoven.dukes.generallee.EngineMap; 11 | //import nl.vaneijndhoven.dukes.generallee.SteeringMap; 12 | import org.slf4j.Logger; 13 | import org.slf4j.LoggerFactory; 14 | 15 | import org.rcdukes.error.ErrorHandler; 16 | 17 | /** 18 | * sends commands to the servos and LED via servoblaster 19 | * 20 | */ 21 | public class ServoBlaster implements ServoCommand { 22 | 23 | private Map mapGpio2Id = new HashMap(); 24 | private static final int SERVOBLASTER_ID_MOTOR = 1; // GPIO-17 25 | private static final int SERVOBLASTER_ID_WHEEL = 2; // GPIO-18 26 | private static final int SERVOBLASTER_ID_LED = 6; // GPIO-24 27 | 28 | public static final boolean WRITE_DIRECT = true; // write directly to device 29 | 30 | private static final Logger LOG = LoggerFactory.getLogger(ServoBlaster.class); 31 | 32 | /** 33 | * construct the servo blaster access 34 | */ 35 | public ServoBlaster() { 36 | this.mapGpio2Id.put(17, SERVOBLASTER_ID_MOTOR); 37 | this.mapGpio2Id.put(18, SERVOBLASTER_ID_WHEEL); 38 | this.mapGpio2Id.put(24, SERVOBLASTER_ID_LED); 39 | } 40 | 41 | @Override 42 | public void setServo(int gpioPin, int value) { 43 | Integer id=this.mapGpio2Id.get(gpioPin); 44 | if (id==null) { 45 | LOG.error(String.format("GPIO Pin %d has not ServoBlaster mapping",gpioPin)); 46 | return; 47 | } 48 | String servoBlasterCommand = id + "=" + value; 49 | String msg=String.format("Setting servo on GPIO %d with servoBlaster command: %s",gpioPin,servoBlasterCommand); 50 | LOG.trace(msg); 51 | // write the command to the device (if permissions are set correctly) 52 | File servoBlaster = new File("/dev/servoblaster"); 53 | if (!servoBlaster.canWrite()) { 54 | LOG.info("/dev/servoblaster can't be written - not a PI, not installed or permissions missing"); 55 | return; 56 | } 57 | try { 58 | FileUtils.writeStringToFile(servoBlaster, servoBlasterCommand + "\n", 59 | "UTF-8"); 60 | } catch (IOException e) { 61 | ErrorHandler.getInstance().handle(e, 62 | "You might want to check the permissions on " 63 | + servoBlaster.getAbsolutePath()); 64 | } 65 | } 66 | 67 | } 68 | -------------------------------------------------------------------------------- /rc-detect/src/main/java/org/rcdukes/detect/edgedectection/CannyEdgeDetector.java: -------------------------------------------------------------------------------- 1 | package org.rcdukes.detect.edgedectection; 2 | 3 | import org.opencv.core.Mat; 4 | import org.opencv.imgproc.Imgproc; 5 | import org.rcdukes.detectors.EdgeDetector; 6 | import org.rcdukes.video.ColorFilter; 7 | 8 | /** 9 | * Canny edge detector 10 | * @see OpenCV Canny Edge Detection 11 | */ 12 | public class CannyEdgeDetector implements EdgeDetector { 13 | 14 | double threshold1 = 60; 15 | double threshold2 = 150; 16 | int apertureSize = 3; 17 | boolean l2gradient = false; 18 | ColorFilter colorFilter; 19 | 20 | public double getThreshold1() { 21 | return threshold1; 22 | } 23 | 24 | public void setThreshold1(double threshold1) { 25 | this.threshold1 = threshold1; 26 | } 27 | 28 | public double getThreshold2() { 29 | return threshold2; 30 | } 31 | 32 | public void setThreshold2(double threshold2) { 33 | this.threshold2 = threshold2; 34 | } 35 | 36 | public int getApertureSize() { 37 | return apertureSize; 38 | } 39 | 40 | public void setApertureSize(int apertureSize) { 41 | this.apertureSize = apertureSize; 42 | } 43 | 44 | public boolean isL2gradient() { 45 | return l2gradient; 46 | } 47 | 48 | public void setL2gradient(boolean l2gradient) { 49 | this.l2gradient = l2gradient; 50 | } 51 | 52 | 53 | public ColorFilter getColorFilter() { 54 | return colorFilter; 55 | } 56 | 57 | public void setColorFilter(ColorFilter colorFilter) { 58 | this.colorFilter = colorFilter; 59 | } 60 | 61 | /** 62 | * default constructor 63 | */ 64 | public CannyEdgeDetector() { 65 | } 66 | 67 | /** 68 | * construct me with the given parameters 69 | * @param threshold1 70 | * @param threshold2 71 | * @param apertureSize 72 | * @param l2gradient 73 | */ 74 | public CannyEdgeDetector(double threshold1, double threshold2, 75 | int apertureSize, boolean l2gradient) { 76 | this(); 77 | this.threshold1 = threshold1; 78 | this.threshold2 = threshold2; 79 | this.apertureSize = apertureSize; 80 | this.l2gradient = l2gradient; 81 | } 82 | 83 | @Override 84 | public Mat detect(Mat image) { 85 | Mat imgEdges = new Mat(); 86 | if (this.colorFilter!=null) { 87 | image=this.colorFilter.filter(image); 88 | } 89 | Imgproc.Canny(image, imgEdges, threshold1, threshold2, apertureSize, 90 | l2gradient); 91 | return imgEdges; 92 | } 93 | 94 | } 95 | -------------------------------------------------------------------------------- /rc-detect/src/main/java/org/rcdukes/objects/stoppingzone/StoppingZoneOrientation.java: -------------------------------------------------------------------------------- 1 | package org.rcdukes.objects.stoppingzone; 2 | 3 | import org.rcdukes.geometry.Lane; 4 | import org.rcdukes.geometry.Line; 5 | import org.rcdukes.geometry.Point; 6 | import org.rcdukes.geometry.Point2D; 7 | import org.rcdukes.objects.StoppingZone; 8 | import org.rcdukes.objects.ViewPort; 9 | 10 | import java.util.Optional; 11 | 12 | public class StoppingZoneOrientation { 13 | 14 | private final StoppingZone stoppingZone; 15 | private final Lane lane; 16 | private final ViewPort viewPort; 17 | 18 | public StoppingZoneOrientation(StoppingZone stoppingZone, Lane lane, ViewPort viewPort) { 19 | this.stoppingZone = stoppingZone; 20 | this.lane = lane; 21 | this.viewPort = viewPort; 22 | } 23 | 24 | public double determineDistanceToStoppingZone() { 25 | if (!stoppingZone.getEntrance().isPresent()) { 26 | return Double.NaN; 27 | } 28 | 29 | Optional leftIntersect = lane.getLeftBoundary().flatMap(boundary -> stoppingZone.getEntrance().get().intersect(boundary)); 30 | Optional rightIntersect = lane.getRightBoundary().flatMap(boundary -> stoppingZone.getEntrance().get().intersect(boundary)); 31 | 32 | if (!leftIntersect.isPresent() || !rightIntersect.isPresent()) { 33 | return Double.NaN; 34 | } 35 | 36 | Line entrance = new Line(leftIntersect.get(), rightIntersect.get()); 37 | 38 | Point2D base = new Point(viewPort.getOrigin().getX() + (viewPort.getWidth() / 2), viewPort.getOrigin().getY() + viewPort.getHeight()); 39 | return entrance.distance(base); 40 | } 41 | 42 | public double determineDistanceToStoppingZoneEnd() { 43 | if (!stoppingZone.getExit().isPresent()) { 44 | return Double.NaN; 45 | } 46 | 47 | Optional leftIntersect = lane.getLeftBoundary().flatMap(boundary -> stoppingZone.getExit().get().intersect(boundary)); 48 | Optional rightIntersect = lane.getRightBoundary().flatMap(boundary -> stoppingZone.getExit().get().intersect(boundary)); 49 | 50 | if (!leftIntersect.isPresent() || !rightIntersect.isPresent()) { 51 | return Double.NaN; 52 | } 53 | 54 | Line exit = new Line(leftIntersect.get(), rightIntersect.get()); 55 | 56 | Point2D base = new Point(viewPort.getOrigin().getX() + (viewPort.getWidth() / 2), viewPort.getOrigin().getY() + viewPort.getHeight()); 57 | return exit.distance(base); 58 | } 59 | } -------------------------------------------------------------------------------- /rc-imageview/src/main/java/org/rcdukes/imageview/MJpegHandler.java: -------------------------------------------------------------------------------- 1 | package org.rcdukes.imageview; 2 | 3 | import static org.asynchttpclient.Dsl.asyncHttpClient; 4 | 5 | import java.io.IOException; 6 | import java.io.PipedInputStream; 7 | import java.io.PipedOutputStream; 8 | import java.util.concurrent.Future; 9 | 10 | import org.asynchttpclient.AsyncHttpClient; 11 | import org.asynchttpclient.Response; 12 | import org.asynchttpclient.handler.BodyDeferringAsyncHandler; 13 | import org.asynchttpclient.handler.BodyDeferringAsyncHandler.BodyDeferringInputStream; 14 | 15 | /** 16 | * handler for MJPeg Streams 17 | * @author wf 18 | * 19 | */ 20 | public class MJpegHandler { 21 | 22 | AsyncHttpClient asyncHttpClient; 23 | private PipedInputStream pipedInputStream; 24 | private PipedOutputStream pipedOutputStream; 25 | private BodyDeferringAsyncHandler outputHandler; 26 | BodyDeferringInputStream inputStream; 27 | 28 | public BodyDeferringInputStream getInputStream() { 29 | return inputStream; 30 | } 31 | 32 | /** 33 | * get an mjpeg stream from the given url 34 | * 35 | * @param url 36 | * @return - the MJPeg Stream 37 | * @throws Exception 38 | */ 39 | public MJpegHandler(String url) throws Exception { 40 | // https://stackoverflow.com/a/50402629/1497139 41 | asyncHttpClient = asyncHttpClient(); 42 | asyncHttpClient.prepareGet(url); 43 | pipedInputStream = new PipedInputStream(); 44 | pipedOutputStream = new PipedOutputStream( 45 | pipedInputStream); 46 | outputHandler = new BodyDeferringAsyncHandler( 47 | pipedOutputStream); 48 | Future futureResponse = asyncHttpClient.prepareGet(url) 49 | .execute(outputHandler); 50 | Response response = outputHandler.getResponse(); 51 | if (response.getStatusCode() == 200) { 52 | inputStream=new BodyDeferringAsyncHandler.BodyDeferringInputStream( 53 | futureResponse, outputHandler, pipedInputStream); 54 | } 55 | } 56 | 57 | public MJpegHandler() { 58 | } 59 | 60 | /** 61 | * open me with the given bufferSize 62 | * 63 | * @param url 64 | * @return 65 | * @throws Exception 66 | */ 67 | public MJpegDecoder open(int bufferSize) throws Exception { 68 | MJpegDecoder mjpegDecoder = new MJpegDecoder(this); 69 | mjpegDecoder.open(bufferSize); 70 | return mjpegDecoder; 71 | } 72 | 73 | /** 74 | * close this handler 75 | * @throws IOException 76 | */ 77 | public void close() throws IOException { 78 | this.asyncHttpClient.close(); 79 | } 80 | 81 | } 82 | -------------------------------------------------------------------------------- /rc-common/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | 8 | org.rcdukes 9 | dukes 10 | 0.0.3 11 | 12 | 13 | org.rcdukes.dukes 14 | rc-common 15 | Library containing common API classes 16 | 17 | 18 | 19 | io.vertx 20 | vertx-core 21 | 22 | 23 | io.vertx 24 | vertx-rx-java 25 | 26 | 27 | io.vertx 28 | vertx-web 29 | 30 | 31 | com.hazelcast 32 | hazelcast 33 | 34 | 35 | io.vertx 36 | vertx-hazelcast 37 | 38 | 39 | ch.qos.logback 40 | logback-classic 41 | 42 | 43 | junit 44 | junit 45 | 46 | 47 | commons-io 48 | commons-io 49 | 50 | 51 | 52 | org.apache.commons 53 | commons-lang3 54 | 55 | 56 | 57 | org.asynchttpclient 58 | async-http-client-extras-rxjava2 59 | 60 | 61 | 62 | org.apache.tinkerpop 63 | gremlin-core 64 | 65 | 66 | 67 | org.apache.tinkerpop 68 | tinkergraph-gremlin 69 | 70 | 71 | 72 | com.google.code.gson 73 | gson 74 | 75 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /rc-app/src/main/resources/fx/navigation.fxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 13 | 14 | 15 | 16 | 17 | 18 |