Welcome to ROS Robot Expansion 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 and IMU data. Connecting the car encoder can also obtain the speed of the car.
1、start mode
Taking our company's Rosmaster-X3 as an example, the terminal enters the following command to start,
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
xxxxxxxxxxfrom 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)#Call the library to read the information of the ROS expansion boardedition.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()#Publish topic dataself.imuPublisher.publish(imu)self.magPublisher.publish(mag)self.volPublisher.publish(battery)self.EdiPublisher.publish(edition)self.velPublisher.publish(twist)#Subscriber callback functiondef cmd_vel_callback(self,msg)def RGBLightcallback(self,msg)def Buzzercallback(self,msg):Please refer to the following path code for detailed code:~/driver_ws/src/yahboomcar_bringup/yahboomcar_bringup/Mcnamu_driver_X3.py