Skip to content

Latest commit

 

History

History
134 lines (85 loc) · 3.62 KB

File metadata and controls

134 lines (85 loc) · 3.62 KB

Project README

Architecture

Software Architecture

For a detailed view of the architecture diagram, see architecture.md.

Redis Functions Used

RedisVectorClient (redis_vector_client.py)

Manages the Redis connection and implements advanced features for vector search with RedisSearch and RedisJSON. Key functions are:

  • createvectorestore: creates a Redis index for vector search.
  • addtocosincollection: adds normalized vectors and associated commands to the Redis database via hash.
  • selectcommandcosinsimilarity: performs a cosine similarity search on Redis to select the most relevant command given a query vector.
  • Supports the use of Redis commands such as FT.CREATE, HSET, and FT.SEARCH to index and query vectors.

Rediscontroller (redis_controller.py)

Subscribes to the Redis channel sensorsdata, receives sensor data, compares it with vectors in the database using RedisVectorClient, and publishes control commands on channel cmd. Uses in particular:

  • pubsub.subscribe and pubsub.listen for real-time communication.
  • redis.publish to send movement or stop commands based on calculated similarity.

VirtualBody (virtual_redis_body.py)

Simulates communication with a virtual robot, reads sensor data, and sends data to Redis via publish on channel sensorsdata. Listens on channel cmd for movement commands.

redis_start_train.py

Script that prepares and loads vector data into the Redis database for search, creating the index and populating the database with normalized vectors and commands.

start_navigation.py

Main script that starts the simulation, the sensor data sending thread, and the controller that receives commands from Redis to guide the robot.

Commands to Run the Project

1. Ensure that Redis is started and accessible on port 6379 (default).

2. Start Redis with Docker Compose:

docker-compose up -d

3. Run the script to create the index and load data into the vector Redis this if exist a csv file:

./train.sh

4. Start the simulation and control with:

python src/start_navigation.py

5. To terminate, interrupt with Ctrl+C.

Training and dataset creation

1.If you have executed previously a train.sh file execute these commands else go to point 2

docker stop redis-server

docker compose rm redis

2.If you want create a csv file for training:

docker compose up -d redis

python src/start_human_navigation.py 

later the execution of src/start_human_navigation.py you can execute file for training:

python src/redis_start_train.py

Environment Setup with uv

To set up the runtime environment using uv, follow these steps:

1. Install uv (if not already installed):

curl -LsSf https://astral.sh/uv/install.sh | sh

Or using Homebrew on macOS:

brew install uv

2. Create and activate a virtual environment:

uv venv
source .venv/bin/activate  # On macOS/Linux
# or
.venv\Scripts\activate  # On Windows

3. Install project dependencies:

uv pip install -r requirements.txt

4. Run the project scripts using uv:

# Run training script
uv run src/redis_start_train.py

# Run navigation script
uv run src/start_navigation.py

Note: Make sure you have Python 3.12 or higher installed, as required by the project configuration.

Run Python inside CoppeliaSim

To run the Python interpreter defined in your virtual environment from within the CoppeliaSim simulators scripts:

echo "defaultPython = /absolute/path/venv/bin/python" > $USER/.CoppeliaSim/usrset.txt