Skip to content

Commit

Permalink
refactor stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
codekansas committed Jan 17, 2025
1 parent 6640cab commit 2e35eff
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
4 changes: 0 additions & 4 deletions kos_sim/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@

import logging

import colorlogging

colorlogging.configure()

logger = logging.getLogger("kos_sim")

__version__ = "0.0.1"
9 changes: 8 additions & 1 deletion kos_sim/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import time
from concurrent import futures

import colorlogging
import grpc
from kos_protos import actuator_pb2_grpc, imu_pb2_grpc, sim_pb2_grpc

Expand Down Expand Up @@ -93,11 +94,17 @@ def serve(model_path: str, config_path: str | None = None, port: int = 50051) ->
server.start()


if __name__ == "__main__":
def run_server() -> None:
parser = argparse.ArgumentParser(description="Start the simulation gRPC server.")
parser.add_argument("--model-path", type=str, required=True, help="Path to MuJoCo XML model file")
parser.add_argument("--port", type=int, default=50051, help="Port to listen on")
parser.add_argument("--config-path", type=str, default=None, help="Path to config file")

colorlogging.configure()

args = parser.parse_args()
serve(args.model_path, args.config_path, args.port)


if __name__ == "__main__":
run_server()
3 changes: 3 additions & 0 deletions kos_sim/simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import threading
from pathlib import Path

import colorlogging
import mujoco
import mujoco_viewer
import numpy as np
Expand Down Expand Up @@ -237,6 +238,8 @@ async def main() -> None:
parser.add_argument("--speed", type=float, default=1.0, help="Simulation speed multiplier")
parser.add_argument("--no-render", action="store_true", help="Disable rendering")

colorlogging.configure()

args = parser.parse_args()
await test_simulation_adhoc(
args.model_name,
Expand Down
6 changes: 5 additions & 1 deletion kos_sim/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def test_sim_service(host: str = "localhost", port: int = 50051) -> None:
logger.error("Test failed: %s", e)


if __name__ == "__main__":
def main() -> None:
parser = argparse.ArgumentParser(description="Test the simulation server with actuator commands.")
parser.add_argument("--host", type=str, default="localhost", help="Server host")
parser.add_argument("--port", type=int, default=50051, help="Server port")
Expand All @@ -105,3 +105,7 @@ def test_sim_service(host: str = "localhost", port: int = 50051) -> None:
test_actuator_commands(args.host, args.port)
else:
test_sim_service(args.host, args.port)


if __name__ == "__main__":
main()

0 comments on commit 2e35eff

Please sign in to comment.