Robot Hardware Components and Programming

Aus HSHL Mechatronik
Zur Navigation springen Zur Suche springen

The AplphBot is modified with a RPLidar is used for this project. Raspberry pi 4 is used as a computer with Odometer sensor and motor driver L298P is used.

IMG AlphaBot

Raspberry Pi 4 is installed with Linux server and established a SSH connection with the robot and PC.

Please go through the documentation here for the steps: How to install Ubuntu Server on your Raspberry Pi

Then ROS2 is installed in raspberry pi through SSH

RPLidar Integration

Now that we have the driver software, we can post a LaserScan topic and communicate with the laser. Actually, there are a few distinct versions of the driver available. We are utilizing the package repository version in this instance. To install the package,

> sudo apt install ros-foxy-rplidar-ros <

Therefore, we must run the driver next. Currently, for the version that is installed on the apt repo, the package name is rplidar ros, and the node name is rplidar_composition. Several further optional settings must also be set.

  • -p serial_port:=/dev/ttyUSB0 - The serial port the lidar
  • -p frame_id:=lidar_link - The transform frame of the lidar
  • -p angle_compensate:=true - Simply turn this setting on, please. If you don't turn it on, even though it appears to be on, it won't function properly.
  • -p scan_mode:=Standard - What scan mode the lidar is in, how many points there are, and other things are controlled

Then the final commond is

> ros2 run rplidar_ros rplidar_composition --ros-args -p serial_port:=/dev/ttyUSB0 -p frame_id:=lidar_link -p angle_compensate:=true -p scan_mode:=Standard
<

Now, LaserScan messages ought to be being published by the driver node. We can once again utilize RViz to verify this. We'll need to manually define the fixed frame by typing in laser_frame if robot_state_publisher isn't functioning.

Setting up Motor Driver and Programming

One of the crucial components of the intelligent robot is the motor driver module. The motor driver chip used by AlphaBot is the ST L298P driver chip, which has a high voltage and large current.


Interface definition of driver module:
The left motor is connected to IN1 and IN2, and the right motor is connected to IN3 and IN4. The output enable pins ENA and ENB are active high enabled. The PWM pulse will be outputted from IN1, IN2, IN3, and IN4 to regulate the speed of the motor robot when they are driven to High level. Control theory:

 IN1  IN2  IN3  IN4    Descriptions  
1 0 0 1 The robot moves straight when the motors revolve forward. 0 1 1 0 The robot retracts when the motors rotate rearward. 1 0 0 0 The robot moves to the left when the left motor stops and the right motor rotates. 0 0 0 0 The robot halts when the motors sops.