Welcome to RDK X5 Board repository
2.Robot information release
2.Robot information release
After the program runs, the ROS expansion board will return real-time data, including voltage, IMU data, and connect to the car encoder to obtain the speed of the car.
1、Start up
Taking Rosmaster-X3 of our company as an example, enter the following command on the terminal to start it.
ros2 run yahboomcar_bringup Mcnamu_driver_X3

2、View topic nodes
Enter the command at the terminal
xxxxxxxxxxros2 topic list


3、Reading Topic Data
If you want to read the voltage value, you need to enter the following command at the terminal
xxxxxxxxxxros2 topic echo /voltage

4、Publish topic data
To publish/cmd_ Taking speed data as an example, terminal input
xxxxxxxxxxros2 topic pub /cmd_vel geometry_msgs/msg/Twist "{linear: {x: 0.5, y: 0.0, z: 0.0}, angular: {x: 0.0, y: 0.0, z: 0.2}}"

5、Source code parsing
x
from Rosmaster_Lib import Rosmaster #Import Driver Libraryself.car = Rosmaster() #Instantiating Rosmaster objects#create subcriber 创建订阅者self.sub_cmd_vel =self.create_subscription(Twist,"cmd_vel",self.cmd_vel_callback,1)self.sub_RGBLight =self.create_subscription(Int32,"RGBLight",self.RGBLightcallback,100)self.sub_BUzzer =self.create_subscription(Bool,"Buzzer",self.Buzzercallback,100)#create publisher 创建发布者self.EdiPublisher = self.create_publisher(Float32,"edition",100)self.volPublisher = self.create_publisher(Float32,"voltage",100)self.staPublisher = self.create_publisher(JointState,"joint_states",100)self.velPublisher = self.create_publisher(Twist,"vel_raw",50)self.imuPublisher = self.create_publisher(Imu,"/imu/data_raw",100)self.magPublisher = self.create_publisher(MagneticField,"/imu/mag",100)#调用库,读取ros拓展板的信息edition.data = self.car.get_version()*1.0battery.data = self.car.get_battery_voltage()*1.0ax, ay, az = self.car.get_accelerometer_data()gx, gy, gz = self.car.get_gyroscope_data()mx, my, mz = self.car.get_magnetometer_data()vx, vy, angular = self.car.get_motion_data()#发布话题数据self.imuPublisher.publish(imu)self.magPublisher.publish(mag)self.volPublisher.publish(battery)self.EdiPublisher.publish(edition)self.velPublisher.publish(twist)#订阅者回调函数def cmd_vel_callback(self,msg)def RGBLightcallback(self,msg)def Buzzercallback(self,msg):Please refer to the following path code for detailed ~/yahboomcar_ws/src/yahboomcar_bringup/yahboomcar_bringup/Mcnamu_driver_X3.py