Project files
- 3D-model2 files
- firmware1535 files
- images3 files
- ros2_packages35 files
- .gitignore1 KB
- LICENSE1 KB
- README.md9 KB
README.md
Machine-translated by Robotheca from the original in Chinese (opens in a new tab). License: MIT (opens in a new tab).
T-Robot
Bilibili link: T-Robot v0.1 release! Open-source omnidirectional mobile robot (Based on Micro-ROS) (opens in a new tab)
Image: T-Robot1 (opens in a new tab)
-
T-Robot is a DIY mobile robot
-
Fully embraces the ROS2 ecosystem, enabling 2D LiDAR map reconstruction and autonomous navigation
-
Designed purely for interest, can be used as a ROS2 beginner reference
-
Uses micro-ROS at the lower level, fully embracing the ROS2 ecosystem
-
Upper-level applications use ROS2 for rapid development of various functional modules
-
This project draws on and learns from the following repositories: linorobot2 (opens in a new tab) fishbot (opens in a new tab) turtlebot3 (opens in a new tab)
-
Note: Only tested under ros2-foxy
0 Repository Documentation Description
- images: some photos
- firmware: underlying firmware
- ros2_packages: ROS2 packages
- 3D-models: 3D models
1 Robot Hardware Components
All purchased from Taobao; no links provided to avoid suspicion of advertising.
- Robot Chassis Layout
Image: image-20221207200401126 (opens in a new tab)
-
Main Controller: ESP32 (ESP-WROOM-32) + Sophon X3 Board (2GB)
-
Lidar: LD14
-
IMU: MPU9250
-
Motor: WGA12-N20 DC geared motor (12V, 1:50 reduction ratio)
-
Motor Driver Chip: 4 ร RZ7889
-
Encoder: AB quadrature magnetic Hall encoder
-
Power Supply: 12V lithium battery
- 12V to drive motors; external 12V-to-5V module provides DC-5V output (max current 4A)
-
Wheels: 4 Mecanum wheels, 48 mm diameter
-
Structural Components: Laser-cut acrylic plates, 3D-printed parts
4 Bottom Firmware Section
2.0 Firmware Description
-
This firmware is based on the Arduino framework and is suitable for the ESP32 series. It is not recommended to compile using Arduino IDE (may result in errors).
-
It is recommended to use VS Code + PlatformIO. Firmware dependencies can be automatically installed via
platformio.ini. -
Based on micro_ros_arduino#v2.0.5-foxy (opens in a new tab). You can change to other versions such as
galacticorhumble(may require minor modifications). -
Since
micro_ros_arduinodoes not natively supportPlatformIO, thelibmicroros.afor the corresponding hardware platform must be manually specified inplatformio.ini. Use the following command (example for ESP32):build_flags = -L $PROJECT_DIR/lib/micro_ros_arduino/src/esp32/ -l libmicrorosThe official micro_ros_arduino library has been rebuilt, so it cannot be used directly.
-
If you want to use the official micro_ros_arduino, you need to change the QoS of the odometry message to default:
- Changing to default will reduce the publishing frequency.
//!!! Change rclc_publisher_init_best_effort to rclc_publisher_init_default !!! RCCHECK(rclc_publisher_init_best_effort( &odom_publisher, &node, ROSIDL_GET_MSG_TYPE_SUPPORT(nav_msgs, msg, Odometry), "odom")); -
Use Wi-Fi to communicate with the host computer.
-
If using a serial port, ensure the baud rate is above 480600 bps and modify
src/main.cpp:set_microros_transports(); //set_microros_wifi_transports("WiFi Name", "Password", "Host IP", 8888);
2.1 Module Descriptions
2.1.1 lib/config
Contains most macro definitions, pin definitions, etc.
2.1.2 lib/encoder
Encoder library for ESP32 written in C++, original author's repository: ESP32encoder (opens in a new tab)
-
This project has made necessary modifications, adding the
getRPM()function to directly obtain speed information.float ESP32Encoder::getRPM(int counts_per_rev) //counts_per_rev: encoder counts per revolution { counts_per_rev_ = counts_per_rev; int64_t encoder_ticks = getCount(); // this function calculates the motor's RPM based on encoder ticks and delta time unsigned long current_time = micros(); unsigned long dt = current_time - prev_update_time_; // convert the time from milliseconds to minutes double dtm = (double)dt / 60000000; double delta_ticks = encoder_ticks - prev_encoder_ticks_; // calculate wheel's speed (RPM) prev_update_time_ = current_time; prev_encoder_ticks_ = encoder_ticks; return ((delta_ticks / counts_per_rev_) / dtm); } -
Different encoder counting modes can be configured:
//file: ESP32encoder.h
void attachSingleEdge(int aPintNumber, int bPinNumber); //1x
void attachHalfQuad(int aPintNumber, int bPinNumber); //2x
void attachFullQuad(int aPintNumber, int bPinNumber); //4x
2.1.3 lib/imu
-
imu_interface.h-
Defines the
ros2 imu messageformat for the IMU, which can be directly sent to ROS/ROS2 for use; -
The
IMUInterface()constructor initializes theimu_msg.headerrelated information; the implementation may vary slightly depending on the version; -
Abstracts 4 virtual functions to facilitate adaptation to different types of IMUs;
//file: imu_interface.h virtual geometry_msgs__msg__Vector3 readAccelerometer() = 0; virtual geometry_msgs__msg__Vector3 readGyroscope() = 0; virtual bool startSensor() = 0; virtual void calibrateGyro()=0;
-
-
default_imu.h- Depends on the MPU9250 library (opens in a new tab), which can be automatically installed via the
platformio.inifile or manually downloaded and added; - Implements the 4 virtual functions from
imu_interface.h;
- Depends on the MPU9250 library (opens in a new tab), which can be automatically installed via the
2.1.4 lib/kinematics
A C++ library for solving forward and inverse kinematics of a robot chassis. It supports differential drive, Ackermann, Mecanum, and other configurations. Original repository: kinematics (opens in a new tab)
Wheelbase, wheel diameter, speed, and other parameters are defined in lib/config.
- Core function 1: Calculate wheel speeds from linear and angular velocities
rpm getRPM(float linear_x, float linear_y, float angular_z);
- Core function 2: Calculate linear and angular velocities from wheel speeds
velocities getVelocities(int rpm1, int rpm2, int rpm3, int rpm4);
2.1.5 lib/motor
motor_interface.h abstracts various functions of the motor, such as forward rotation, reverse rotation, and stopping;
motor.h inherits from motor_interface and implements its functions, adding pwm_offset;
pwm_offset is used to address the issue of some motors not rotating under low-duty-cycle PWM drive;
2.1.6 lib/odemetry
Defines the odometer nav_msgs/msg/odometry for publishing odometry message.
-
Core function 1: Get the current
odometry messagedatanav_msgs__msg__Odometry Odometry::getData() { return odom_msg_; } -
Core function 2: Update
odometry messagedata by passing velocity information
void update(float vel_dt, float linear_vel_x, float linear_vel_y, float angular_vel_z);
2.1.7 lib/pid
As the name suggests, it is the PID control for motors. No further explanation is needed; just check the code.
2.1.8 lib/micro_ros_arduino
Based on the official micro_ros_arduino#v2.0.5foxy (opens in a new tab), necessary modifications were made and it was rebuilt:
- Modified
UCLIENT_CUSTOM_TRANSPORT_MTU=1024to allow transmission of data larger than 512 bytes (mainly odometry messages) when using the best_effort transmission strategy; - Modified
RMW_UXRCE_MAX_HISTORY=2to reduce RAM usage and avoid memory overflow; - Specific rebuild steps can be found at: https://github.com/micro-ROS/micro_ros_arduino/issues/1221#issuecomment-1329923473 (opens in a new tab)
2.1.9 src/main.cpp
- Initialize encoders, PID control, motors, etc.
- Create 2 publishers:
odomandimu - Create 1 subscriber:
cmd_vel - Create 3 software timers: 2 for publisher publishing; 1 for controlling robot movement
3 ROS Functional Package Section
3.1 ld14
- Laser radar function package, usually provided by the radar manufacturer
3.2 robot_bringup
- Place the program for starting the robot on boot (currently only one
default.launch.py)
3.2.1 default.launch.py
- Start the laser radar, robot_description, micro_agent, and so on in sequence
3.3 robot_description
- Mainly contains the robot description file, i.e., the URDF.
- If an error occurs when loading the STL file, refer to fix malformed stl (opens in a new tab).
3.4 robot_cartographer
- Use cartographer for mapping; refer to cartographer documentation for details.
4 Known Issues
- The IMU coordinate system is not aligned with the default ROS coordinate system and needs to be realigned. Updates will be provided as progress is made.
- Due to the IMU coordinate system issue, using EKF to fuse IMU and Odometry data will result in errors. Therefore, the encoder data is directly used for Odometry output.
- The current update frequency of Odometry is maintained at 40Hz. Higher frequencies cannot be achieved, as the serial baud rate seems to have reached its limit. WiFi communication can be attempted as an alternative.
- The camera driver has not been added yet, as there are plans to use the camera for further development in the future. Updates will be provided later.
Files by @tianci8, at commit 51e79ac, read from GitHub in your browser. Hardware license: MIT; software license: MIT. Robotheca doesn't review code: read it before running it.