# Manual Control Guide - Game-Style Interface

## Overview

The Manual Control page provides a game-style interface for controlling your agriculture robot in real-time. It features:

- **Live Camera Feed**: View what your robot sees
- **Joystick Control**: Intuitive directional movement
- **Action Buttons**: Quick access to common commands
- **Real-time Status**: Monitor robot state, battery, and position
- **Speed Control**: Adjust movement speed dynamically

## Accessing Manual Control

1. **Login** to your account
2. **Navigate** to "Manual Control" in the sidebar
3. **Connect** your robot via WiFi or Bluetooth (see Robot Connection Guide)
4. **Start** controlling!

## Interface Layout

### Top Status Bar
- **Left**: Connection status and battery level
- **Center**: Robot name and active status
- **Right**: Current speed indicator

### Main Viewport
- **Live Camera Feed**: Shows robot's camera view (when connected)
- **Placeholder**: Displays robot stats when camera unavailable

### Control Overlays

#### Top Right - Quick Actions
- **Play/Pause Button**: Start or pause robot operations
- **Emergency Stop**: Immediately stop all robot movement

#### Bottom Left - Joystick
- **Drag to Move**: Click and drag the joystick handle
- **Directional Control**: 
  - Up = Forward
  - Down = Backward
  - Left = Turn Left
  - Right = Turn Right
- **Release to Stop**: Let go to stop movement

#### Bottom Right - Action Buttons
- **FORWARD**: Move robot forward
- **BACKWARD**: Move robot backward
- **TURN LEFT**: Rotate robot left
- **TURN RIGHT**: Rotate robot right

#### Center Bottom - Speed Control
- **Slider**: Adjust movement speed (0-100%)
- **Real-time**: Changes apply immediately

### Bottom Info Bar
- **MODE**: Current operation mode
- **STATUS**: Robot status (RUNNING/STOPPED/ERROR)
- **POSITION**: X, Y coordinates
- **HEADING**: Current direction in degrees

## Controls

### Joystick Control
1. **Click and Hold** the joystick handle
2. **Drag** in desired direction
3. **Release** to stop

**Mobile/Touch:**
- Touch and drag the joystick
- Works the same as mouse control

### Button Controls
- **Press and Hold**: Continuous movement
- **Release**: Stop movement
- Works on both desktop and mobile

### Speed Adjustment
- **Drag** the speed slider
- **Value** updates in real-time
- **Robot** responds immediately

## Robot Commands

### Movement Commands
- **Forward/Backward**: Linear movement at set speed
- **Turn Left/Right**: Rotational movement (15° per command)

### Control Commands
- **Start**: Begin manual control mode
- **Pause**: Pause current operations
- **Emergency Stop**: Immediately halt all movement

## Camera Feed

### Connecting Camera
1. Connect robot via WiFi or Bluetooth
2. Camera feed appears automatically
3. If unavailable, placeholder shows robot stats

### Camera Requirements
- Robot must support video streaming
- WiFi connection recommended for best quality
- Ensure robot's camera server is running

## Mobile Optimization

The interface is optimized for mobile devices:
- **Touch Controls**: Full touch support
- **Responsive Layout**: Adapts to screen size
- **Large Buttons**: Easy to tap
- **Joystick**: Touch-friendly size

## Troubleshooting

### Camera Not Showing
- Verify robot is connected (check Robot Connect page)
- Ensure robot camera is enabled
- Check robot's IP address and port
- Try reconnecting the robot

### Controls Not Responding
- Check connection status (top left)
- Verify robot is in manual mode
- Ensure emergency stop is not active
- Try refreshing the page

### Joystick Not Working
- Click directly on the joystick handle
- Ensure you're dragging, not just clicking
- Check browser console for errors
- Try using button controls instead

### Speed Not Changing
- Verify slider is moving
- Check robot connection status
- Ensure robot supports speed control
- Try disconnecting and reconnecting

## Best Practices

1. **Start Slow**: Begin with low speed (20-30%)
2. **Test Controls**: Verify all directions work
3. **Monitor Status**: Watch battery and connection
4. **Use Emergency Stop**: Keep it accessible
5. **Clear Area**: Ensure safe operating space

## Keyboard Shortcuts (Future)

- `W` - Forward
- `S` - Backward
- `A` - Turn Left
- `D` - Turn Right
- `Space` - Emergency Stop
- `+` - Increase Speed
- `-` - Decrease Speed

## API Integration

The manual control page uses these endpoints:
- `POST /api/robot/move` - Move robot
- `POST /api/robot/turn` - Turn robot
- `POST /api/robot/stop` - Stop movement
- `POST /api/robot/mode` - Set mode
- `POST /api/robot/emergency-stop` - Emergency stop

## Next Steps

After mastering manual control:
1. Try **Auto Control** for autonomous operations
2. Set up **Field Mapping** for navigation
3. Configure **Operation Modes** for specific tasks
4. Monitor **Sensors** for real-time data



