Msitu is a React Native tree planting app designed to simplify the pegging and rope-tying process during tree planting operations. The app integrates with RTK (Real-Time Kinematic) Rover and Base Station equipment to provide centimeter-level accuracy for precise tree placement.
- RTK Integration: Centimeter-level GPS accuracy (1cm error margin)
- Grid Generation: Automatic planting line generation with customizable mesh patterns
- Distance Calculations: Precise distance measurements between coordinates
- Bluetooth/USB Connectivity: Connect to RTK equipment via Bluetooth or USB
- Project Management: Create and manage multiple planting projects
- Real-time Positioning: Live rover position tracking with visual feedback
- Offline Capability: Work without internet connectivity
This project uses React Native Turbo Modules (the new architecture) to interface with native code for high-performance geometric calculations. The main native module is RTNMsitu, which provides:
// Core functions available through RTNMsitu
RTNMsitu.toPoint(coord) // Convert lat/lng to UTM coordinates
RTNMsitu.lineToCoords(points, center) // Convert UTM points to lat/lng coordinates
RTNMsitu.linesToCoords(lines, center) // Convert multiple UTM lines to lat/lng
RTNMsitu.generateMesh(first, second, direction, type, gapSize, lineLength) // Generate planting grid
RTNMsitu.closetPointRelativeToRoverPosition(roverLocation, points) // Find closest point
RTNMsitu.distanceBtnCoords(pt1, pt2) // Calculate distance between coordinatesThe RTNMsitu module is implemented in:
- Android: Kotlin with S2 Geometry library for spatial calculations
- iOS: Swift (planned)
- TypeScript: Type-safe interface definitions
Key native libraries used:
- S2 Geometry: For spatial indexing and nearest point calculations
- UTM Coordinate System: For precise distance and area calculations
- Kotlin Coroutines: For asynchronous mesh generation
- Node.js: >= 18.0.0
- React Native CLI: Latest version
- Android Studio: Dolphin or later
- Java Development Kit (JDK): 17 or later
- Android SDK: API level 24+ (minimum), 35 (target)
- Git: For version control
-
Clone the repository
git clone https://github.com/dsmagicug/msitu.git cd kibira -
Install dependencies
npm install # or yarn install -
Start Metro bundler
# From project root npm start # or yarn start
-
Run the app
# For Android npm run android # or yarn android # For iOS (requires macOS) npm run ios # or yarn ios
- Open Android Studio
- Open the
androidfolder from the project root - Wait for Gradle sync to complete
- Ensure the following are configured:
- Minimum SDK: 24
- Target SDK: 35
- View Binding: Enabled
- Kotlin Support: Enabled
# Generate release APK
cd android
./gradlew assembleRelease
# The APK will be located at:
# android/app/build/outputs/apk/release/app-release.apk# Generate Android bundle
npm run bundle-android- Base Station: Ensure clear sky view for accurate satellite readings
- Rover: Connect to base station and establish RTK communication
- App Connection: Connect app to rover via Bluetooth or USB
- RTK Fix: Wait for RTK fix indication (takes a few minutes)
- Establish RTK Fix: Ensure you have centimeter-level accuracy
- Place Base Points:
- Place two pegs on the plot outskirts (~50m apart)
- Mimic desired tree planting orientation
- Tie rope between pegs for straightness
- Capture Coordinates:
- Copy two coordinate values from the rope
- Keep them as far apart as possible
- Create Project:
- Fill in project details
- Paste coordinates into "Base Points" field
- The app will generate planting lines automatically
If no internet connection is available:
- Move around the plot with the rover to establish bearing
- Use offline maps or visual references
- The app will work without visual map representation
- That being said, for reference, please at least load the map.
When using different equipment sets:
- Create Project A using Equipment Set One
- Draw all possible lines for Project A
- Stand on last line of Project A
- Copy coordinates using Equipment Set Two
- Create Project B with new base points
- Project B will be an extension of Project A with minimal offset (1-2 ft)
RTNMsitu/
βββ android/ # Android native implementation
β βββ src/main/java/
β β βββ com/rtnmsitu/
β β βββ MsituModule.kt # Main Turbo module implementation
β β βββ geometry/ # Geometric calculations
β β βββ s2/ # S2 geometry utilities
β β βββ utils/ # Helper utilities
βββ spec/ # TypeScript interface definitions
β βββ NativeRTNMsitu.ts # Turbo module spec
β βββ types/ # Type definitions
βββ index.ts # Module exports
- React Native: 0.76.1
- React: 18.3.1
- React Native Maps: For map visualization
- React Native Reanimated: For smooth animations
- Redux Toolkit: State management
- NativeWind: Tailwind CSS for React Native
- RTNMsitu: Custom Turbo module for geometric calculations
- Font Optimization: Only includes used vector icon fonts (5/20 fonts)
- ProGuard Rules: Optimized for release builds
- Coordinate Validation: Robust validation to prevent crashes
- Async Operations: Heavy calculations run off main thread
-
Gradle Sync Fails
- Clean project:
./gradlew clean - Invalidate caches in Android Studio
- Check Java/JDK version compatibility
- Clean project:
-
Metro Bundler Issues
- Clear Metro cache:
npx react-native start --reset-cache - Check Node.js version (>= 18)
- Clear Metro cache:
-
RTNMsitu Module Issues
- Ensure Turbo modules are properly configured
- Check native code compilation
- Verify TypeScript interface definitions
# Enable debug logging
adb logcat | grep -E "(RTNMsitu|Msitu)"
# View React Native logs
npx react-native log-androidThis project is licensed under the GPL License. See the LICENSE file for details.
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
For issues and questions:
- Create an issue on GitHub
- Contact: support@ds.co.ug
- Repository: https://github.com/dsmagicug/msitu