Overview
Teleoperation (teleop) allows manual control of the robot using keyboard or joystick. This is essential for:- Testing motor control
- Initial robot setup
- Emergency manual override
- Data collection for mapping
Testing milestone: If teleop works, your full control stack (ros2_control → hardware interface → ESP32 → motors) is functional!
Teleoperation Methods
Keyboard
teleop_twist_keyboard
- Built-in ROS2 package
- WASD or arrow keys
- Simple, no hardware needed
Joystick
joy / teleop_twist_joy
- Xbox/PS controller
- Analog control
- Requires USB joystick
Custom GUI
rqt_robot_steering
- Graphical sliders
- Precise velocity input
- Good for debugging
Method 1: Keyboard Teleop
Installation
Usage
Terminal 1: Launch robot controlControls
- Linear: 0.5 m/s
- Angular: 1.0 rad/s
Custom Speed Limits
speed: Linear velocity (m/s)turn: Angular velocity (rad/s)
Method 2: Joystick Teleop
Installation
Setup Joystick
Connect USB controller, then:Configuration
File:config/teleop_joy.yaml
Launch Joystick Teleop
- Hold enable button (A/X)
- Move left stick → robot moves
- Move right stick → robot rotates
- Release enable button → robot stops
Method 3: GUI Teleop (rqt)
Installation
Usage
- Plugins → Robot Tools → Robot Steering
- Set topic:
/cmd_vel - Use sliders to control:
- Linear X (forward/backward)
- Linear Y (strafe left/right)
- Angular Z (rotate)
Advantages:
- Visual feedback
- Precise velocity values
- Good for debugging
Testing Procedure
Pre-Flight Checklist
- Robot on level surface
- Battery charged (12V full)
- Motors connected correctly
- E-stop accessible (unplug battery)
- Clear space around robot (2m radius)
- ESP32 powered and connected via USB
- All ros2_control nodes running
Test Sequence
1
Test 1: Basic Motion
Objective: Verify straight-line motion
- Launch robot control + teleop
- Press
i(forward) briefly (~1 second) - Observe robot moves forward ~0.5m
- Robot moves forward in straight line
- Stops when key released
- No unexpected rotation
2
Test 2: Directional Control
Test all directions:
Pass criteria:
| Key | Expected Motion |
|---|---|
i | Forward |
, | Backward |
j | Strafe left |
l | Strafe right |
- Each direction works
- Robot moves perpendicular (strafing)
- Motion is smooth, not jerky
3
Test 3: Rotation
Objective: Test in-place rotation
- Press
q(rotate left) - Robot should rotate counterclockwise
- Press
e(rotate right) - Robot should rotate clockwise
- Robot rotates in place (no translation)
- Smooth rotation, no wheel slipping
- Stops precisely when key released
4
Test 4: Diagonal Motion
Objective: Combined translation + rotation
- Press
u(forward + left strafe) - Press
o(forward + right strafe) - Press
m(backward + left strafe) - Press
.(backward + right strafe)
- Diagonal motion works
- Mecanum kinematics correct
5
Test 5: Speed Adjustment
Objective: Test velocity limits
- Press
wmultiple times (increase speed) - Drive forward (
i) - Observe faster motion
- Press
x(decrease speed) - Drive forward again
- Observe slower motion
- Speed changes as expected
- Robot doesn’t exceed limits (safety)
6
Test 6: Emergency Stop
Objective: Verify e-stop works
- Drive robot forward (
i) - While moving, press
k(stop) ORs(force stop) - Robot should stop immediately
- Robot stops within 0.5 seconds
- No coasting or drift
Data Validation
While teleop running, monitor topics:/cmd_vel: Shows Twist messages when keys pressed/joint_states: Wheel velocities change/odom: Robot pose updates
Troubleshooting
Robot doesn't move
Robot doesn't move
Symptoms: Keys pressed but robot stationaryDebug steps:
-
Check /cmd_vel published:
-
Check controller active:
-
Check hardware interface receiving commands:
- Add debug prints in hardware interface
write() - Verify serial data sent to ESP32
- Add debug prints in hardware interface
-
Check ESP32 receiving:
- Use Serial Monitor to see commands
- Verify motor PWM values change
-
Check motor power:
- 12V battery connected?
- IBT-2 enable pins HIGH?
Robot moves wrong direction
Robot moves wrong direction
Symptoms: Press forward, robot goes left/backwardCauses & Solutions:
-
Wheel connected to wrong joint:
- Verify wheel physical position matches URDF joint name
- Example: Front-left wheel connected to wheel_FL_joint
-
Motor direction inverted:
- In ESP32: Swap RPWM and LPWM for that motor
- Or multiply command by -1 in hardware interface
-
Encoder direction wrong:
- Swap encoder A/B pins
- Or invert encoder count in ESP32 code
Robot drifts or curves
Robot drifts or curves
Symptoms: Press forward, robot curves instead of straightCauses:
- Wheel diameter mismatch (physical vs URDF)
- Motor PID gains different between wheels
- Wheel slippage (floor too slippery)
- Battery low (motors underpowered)
- Calibrate wheel diameter in URDF
- Tune all motor PIDs to same response
- Test on non-slip surface (carpet, rubber mat)
- Charge battery (check voltage)
Jerky or oscillating motion
Jerky or oscillating motion
Symptoms: Robot stutters, oscillatesCauses:
- PID control loop unstable
- Control frequency too low
- Velocity commands changing too fast
-
Tune PID:
- Reduce Kp (proportional gain)
- Increase damping (Kd)
-
Increase control rate:
- ESP32: 50Hz minimum
- ros2_control:
update_rate: 50in config
-
Filter velocity commands:
Teleop keys not working
Teleop keys not working
Symptoms: Pressing keys has no effectSolutions:
-
Terminal not focused:
- Click on teleop terminal window
- Ensure it’s the active window
-
Wrong topic:
- Check teleop publishes to
/cmd_vel - Verify controller subscribes to
/cmd_vel
- Check teleop publishes to
-
Node crashed:
-
NumLock on (arrow keys):
- Turn NumLock off
- Use letter keys (i,j,k,l) instead
Advanced: Custom Teleop Node
Create custom teleop for specific behaviors:Launch File Integration
Complete launch file with teleop:Next Steps
Odometry
Publish robot pose from wheel encoders
IMU Fusion
Fuse IMU data with odometry for better accuracy
LiDAR Setup
Configure RPLIDAR for mapping and navigation
SLAM Mapping
Create maps with simultaneous localization and mapping