This repository provides the control interface for integrating a Google Coral Dev Board with mapping and sensor modules for the rover system. It supports testing the mapping module over gRPC and demonstrates multi-channel communication for rover controls and sensor integration.
control.py
: Acts as the main control interface over gRPC, working with the dummy ultrasound measurement script (dummy_ultrasound.py
) to test mapping module functionalities.coral_control.py
: Defines the Coral class, slightly modified fromcoral.py
andcoral_v2.py
, to include map-specific functionalities for extended control.coral.py
: Contains amain()
function and can be run independently for simple control testing.coral_v2.py
: Designed to work alongsidemanualcontrol.py
for advanced manual testing scenarios.
This repository will eventually be updated to interface with the physical hardware, sensors, and the mapping module running on the Coral Dev Board.
To get started, ensure your system is prepared with the necessary dependencies and configurations.
git clone https://github.com/bastiankrohg/rover-coral.git
cd rover-coral
Ensure Python is installed (version 3.8 or later recommended). Install the required Python packages by running:
pip install grpcio grpcio-tools pynput
To start the control.py
script, which acts as the gRPC control interface, run:
python control.py
This script demonstrates key control functions for testing the mapping module. It works with the dummy ultrasound script (dummy_ultrasound.py) and can be extended for integration with physical sensors and devices.
From the rover-pi repository, start the dummy ultrasound sensor script to simulate distance measurements:
python dummy_ultrasound.py
This script simulates sensor data, allowing you to test the mapping functionality without needing actual hardware.
To test the mapping module alongside control.py
and the dummy ultrasound script, start the mapping module:
python game_map_grpc.py
This script launches the mapping interface with gRPC integration. Ensure that both control.py and the dummy ultrasound sensor are running for a complete test environment.
To test the Coral Dev Board’s gRPC functionalities, run coral.py or manualcontrol.py:
python coral.py
or
python manualcontrol.py
These scripts initiates the basic gRPC client, which connects to the mapping module or other gRPC servers as configured. Not integrated with the mapping module.
The manualcontrol.py script also has some basic functionality to steer the rover using the keyboard
- W: Drive forward.
- S: Reverse.
- A: Turn on the spot (left).
- D: Turn on the spot (right).
- Q: Rotate mast left.
- E: Rotate mast right.
- O: Place a resource using the ultrasound measurement.
- P: Place an obstacle using the ultrasound measurement.
- T: Toggle scanning.
- TAB: Toggle the resource list display.
- SPACE: Toggle the obstacle list display.
- M: Save the current map to latest.json.
- ESC: Exit the control script.
Make sure to test the controls alongside the mapping module to observe how inputs affect the simulated environment.
If you need to modify or extend the gRPC communication capabilities, follow these steps:
-
Navigate to the
rover_protos
directory:cd rover_protos
-
Modify the mars_rover.proto file to include your new message types or RPC methods.
After updating the .proto file, compile it into Python files using grpcio-tools:
bash python -m grpc_tools.protoc -I=. --python_out=. --grpc_python_out=. mars_rover.proto
This generates the mars_rover_pb2.py and mars_rover_pb2_grpc.py files.
Once the files are compiled, adjust the imports in mars_rover_pb2_grpc.py:
- Replace the import statement that causes issues (at least when testing locally on my mac):
import mars_rover_pb2 as mars__rover__pb2
- Add a relative path to the mars_rover_pb2 import:
from . import mars_rover_pb2 as mars__rover__pb2
This ensures compatibility when using the rover_protos directory as a module.
If the rover_protos directory is a git submodule, recursively update it after making changes:
bash git submodule update --remote --recursive
The rover-coral module has the potential to evolve into a highly capable system for autonomous or semi-autonomous rover operations. Most of these are optimistic, and only documented as potential improvements should the project be picked up again at a later time. Here are the key areas of focus for future improvements:
- Dynamic Pathfinding:
- Implement algorithms like A* or Dijkstra to dynamically compute the most efficient routes while avoiding obstacles in real time.
- Factor in terrain data from the mapping module to adjust for potential hazards or impassable zones.
- Reactive Adjustments:
- Enable the rover to adjust its planned path based on unexpected changes in the environment detected by sensors.
6.2. Range Constraints in Path Planning
- Optimized Coverage:
- Develop logic to ensure the rover operates within a predefined range, conserving battery and resources.
- Return-to-Base:
- Introduce mechanisms to calculate the shortest route back to the starting position or charging station when the range limit is reached.
- Prioritized Navigation:
- Allow configuration of priority zones or resources, enabling path planning to focus on high-value targets within constraints.
- Search Patterns:
- Implement predefined search patterns such as lawnmower (SAR), spiral, or grid-based coverage for systematic area exploration.
- Autopilot:
- Create a module to generate and execute sequences of commands for autonomous pattern-based movement.
- Combine with real-time adjustments to adapt patterns based on obstacles or environment feedback.
- Command Sequencing:
- Automate the generation of complex sequences for tasks like resource collection, area scanning, and obstacle avoidance.
- Multi-Objective Optimization:
- Enable autonomous decision-making to balance objectives such as coverage, resource efficiency, and return-to-base safety.
- Self-Correction
- Real-Time Data Visualization:
- Develop a telemetry dashboard showing rover position, heading, detected obstacles/resources, and operational status (e.g., battery, connection).
- Control Feedback:
- Allow operators to monitor the progress of autonomous tasks and intervene manually if necessary.
- Mapping Synchronization:
- Ensure tight integration with the mapping module for real-time updates of the rover’s environment and traced path.
- Hardware Calibration:
- Align the software control logic with the physical hardware’s movement characteristics (e.g., turn radius, speed).
- Odometry Feedback:
- Incorporate data from motor encoders or sensors to improve accuracy in mapping and navigation.