Browse Source

更新小车robot_demo程序中走正方形的代码

corvin rasp melodic 2 years ago
parent
commit
a326cd4284

+ 7 - 7
src/robot_demo/cfg/view_demo.rviz

@@ -5,7 +5,7 @@ Panels:
     Property Tree Widget:
       Expanded: ~
       Splitter Ratio: 0.5
-    Tree Height: 521
+    Tree Height: 605
   - Class: rviz/Selection
     Name: Selection
   - Class: rviz/Tool Properties
@@ -134,7 +134,7 @@ Visualization Manager:
           Value: true
         Value: false
       Enabled: true
-      Keep: 52
+      Keep: 80
       Name: Odometry
       Position Tolerance: 0.10000000149011612
       Shape:
@@ -193,10 +193,10 @@ Visualization Manager:
       Invert Z Axis: false
       Name: Current View
       Near Clip Distance: 0.009999999776482582
-      Pitch: 0.7997961640357971
+      Pitch: 1.2747960090637207
       Target Frame: <Fixed Frame>
       Value: Orbit (rviz)
-      Yaw: 0.09999997168779373
+      Yaw: 0.08499996364116669
     Saved: ~
 Window Geometry:
   Displays:
@@ -204,7 +204,7 @@ Window Geometry:
   Height: 930
   Hide Left Dock: true
   Hide Right Dock: true
-  QMainWindow State: 000000ff00000000fd00000004000000000000016a0000029ffc0200000008fb0000001200530065006c0065006300740069006f006e00000001e10000009b0000006500fffffffb0000001e0054006f006f006c002000500072006f007000650072007400690065007302000001ed000001df00000185000000a3fb000000120056006900650077007300200054006f006f02000001df000002110000018500000122fb000000200054006f006f006c002000500072006f0070006500720074006900650073003203000002880000011d000002210000017afb000000100044006900730070006c00610079007300000000440000029f000000de00fffffffb0000002000730065006c0065006300740069006f006e00200062007500660066006500720200000138000000aa0000023a00000294fb00000014005700690064006500530074006500720065006f02000000e6000000d2000003ee0000030bfb0000000c004b0069006e0065006300740200000186000001060000030c00000261000000010000010f0000029ffc0200000003fb0000001e0054006f006f006c002000500072006f00700065007200740069006500730100000041000000780000000000000000fb0000000a0056006900650077007300000000440000029f000000b900fffffffb0000001200530065006c0065006300740069006f006e010000025a000000b200000000000000000000000200000490000000a9fc0100000001fb0000000a00560069006500770073030000004e00000080000002e10000019700000003000004b000000044fc0100000002fb0000000800540069006d00650100000000000004b00000028000fffffffb0000000800540069006d00650100000000000004500000000000000000000004b0000002f300000004000000040000000800000008fc0000000100000002000000010000000a0054006f006f006c00730100000000ffffffff0000000000000000
+  QMainWindow State: 000000ff00000000fd00000004000000000000016a000002f3fc0200000008fb0000001200530065006c0065006300740069006f006e00000001e10000009b0000006500fffffffb0000001e0054006f006f006c002000500072006f007000650072007400690065007302000001ed000001df00000185000000a3fb000000120056006900650077007300200054006f006f02000001df000002110000018500000122fb000000200054006f006f006c002000500072006f0070006500720074006900650073003203000002880000011d000002210000017afb000000100044006900730070006c0061007900730000000044000002f3000000de00fffffffb0000002000730065006c0065006300740069006f006e00200062007500660066006500720200000138000000aa0000023a00000294fb00000014005700690064006500530074006500720065006f02000000e6000000d2000003ee0000030bfb0000000c004b0069006e0065006300740200000186000001060000030c00000261000000010000010f0000029ffc0200000003fb0000001e0054006f006f006c002000500072006f00700065007200740069006500730100000041000000780000000000000000fb0000000a0056006900650077007300000000440000029f000000b900fffffffb0000001200530065006c0065006300740069006f006e010000025a000000b200000000000000000000000200000490000000a9fc0100000001fb0000000a00560069006500770073030000004e00000080000002e10000019700000003000004b000000044fc0100000002fb0000000800540069006d00650100000000000004b00000028000fffffffb0000000800540069006d00650100000000000004500000000000000000000004b0000002f300000004000000040000000800000008fc0000000100000002000000010000000a0054006f006f006c00730100000000ffffffff0000000000000000
   Selection:
     collapsed: false
   Time:
@@ -214,5 +214,5 @@ Window Geometry:
   Views:
     collapsed: true
   Width: 1200
-  X: 39
-  Y: 33
+  X: 37
+  Y: 3

+ 8 - 5
src/robot_demo/src/drive_square_node.cpp

@@ -53,7 +53,7 @@ void Drive_Square::go_forward(const float square_side_length)
     {
         ROS_INFO("Go forward, dist:%f", dist);
         publish_twist_cmd(linear_speed, 0);
-        ros::Duration(0.10).sleep(); //100 ms
+        ros::Duration(0.05).sleep(); //50 ms
 
         tf_Listener.lookupTransform(odom_frame, base_frame, ros::Time(0), tf_Transform);
         float x = tf_Transform.getOrigin().x();
@@ -107,15 +107,18 @@ void Drive_Square::go_circle()
     }
     publish_twist_cmd(0, 0); //原地转弯完成后,需要立刻停止小车的旋转
     ROS_INFO("Turning finish !!!");
-    ros::Duration(0.1).sleep(); //100 ms
+    ros::Duration(1).sleep();
 }
 
 void Drive_Square::go()
 {
-    for (size_t i = 0; i < 4; i++)
+    while(ros::ok())
     {
-        Drive_Square::go_forward(square_side_length);
-        Drive_Square::go_circle();
+        for (size_t i = 0; i < 4; i++)
+        {
+            Drive_Square::go_forward(square_side_length);
+            Drive_Square::go_circle();
+        }
     }
 }
 

+ 2 - 2
src/ros_arduino_bridge/ros_arduino_python/cfg/my_arduino_params.yaml

@@ -1,4 +1,4 @@
-#  
+#
 # Description:arduino节点运行时加载的参数,下面对参数进行解释:
 #   is_use_serial:与arduino通信是否使用串口,false的话就是IIC通信
 #   serial_port:串口通信时arduino的端口号
@@ -29,7 +29,7 @@ odom_name: odom
 
 # Robot drivetrain parameters
 wheel_diameter: 0.067   #车轮的直径
-wheel_track: 0.17     #两个车轮之间距离
+wheel_track: 0.19       #两个车轮之间距离
 encoder_resolution: 11  #12V DC motors
 gear_reduction: 30      #空载转速330rpm电机的减速比
 linear_scale_correction: 1.00