- mars_rover.proto: Contains protobuf message definitions and gRPC service specifications for rover operations.
Ensure the following tools are installed on your system:
- Protocol Buffers Compiler (protoc): Installation Guide
- gRPC Plugins for Code Generation:
- For Python: grpcio-tools
- For other languages, refer to the respective gRPC documentation.
To generate code from the .proto files:
- Navigate to the directory containing mars_rover.proto:
cd path/to/rover_protos
- Generate Python code using grpcio-tools:
python -m grpc_tools.protoc -I. --python_out=. --grpc_python_out=. mars_rover.proto
This command generates mars_rover_pb2.py and mars_rover_pb2_grpc.py in the current directory.
For other programming languages, use the appropriate plugins and follow their specific instructions.
The generated code serves as the communication interface between various modules:
- rover-coral: Interacts with the mapping module using the generated stubs.
- rover-pi: Utilizes the protobuf definitions to handle hardware control messages.
Ensure that all modules use the same version of the generated code to maintain compatibility.
When modifying mars_rover.proto:
- Edit mars_rover.proto with the necessary changes.
- Regenerate the code for all target languages as outlined above.
- Update the submodules for all dependent modules (rover-pi, rover-coral, smart_rover, ...) using:
git submodule update --remote --recursive
NB! When updating the protos, you may have to change the import statement inside mars_rover_pb2_grpc.py, going from a
import mars_rover_pb2_grpc as mars__rover__pb2__grpc
# To instead be
from . import mars_rover_pb2_grpc as mars__rover__pb2__grpc
This process ensures that all components remain synchronized with the latest communication protocols.
Additional Resources • Protocol Buffers Documentation: https://developers.google.com/protocol-buffers • gRPC Documentation: https://grpc.io/docs/