修复了雷达扫描范围的bug,修复了里程计数据的发布者冲突的问题。目前存在问题:odom坐标系在运动过程中还是会飘
This commit is contained in:
@@ -1134,7 +1134,7 @@ namespace lslidar_driver
|
||||
{
|
||||
auto scan = sensor_msgs::msg::LaserScan::UniquePtr(new sensor_msgs::msg::LaserScan());
|
||||
//int scan_num = ceil((angle_able_max - angle_able_min) / 360 * count_num) + 1;
|
||||
int scan_num = fixed_array_length;//cyy_addcyy_add
|
||||
int scan_num = ceil((angle_able_max - angle_able_min) / 360 * count_num) + 1;
|
||||
|
||||
std::vector<ScanPoint> points;
|
||||
rclcpp::Time start_time;
|
||||
@@ -1160,7 +1160,7 @@ namespace lslidar_driver
|
||||
scan->angle_min = 2 * M_PI * angle_able_min / 360;
|
||||
scan->angle_max = 2 * M_PI * angle_able_max / 360;
|
||||
}
|
||||
scan->angle_increment = 2 * M_PI / (double)(fixed_array_length - 1);
|
||||
scan->angle_increment = 2 * M_PI / (double)(scan_num - 1);
|
||||
|
||||
scan->range_min = min_range;
|
||||
scan->range_max = max_range;
|
||||
@@ -1169,7 +1169,7 @@ namespace lslidar_driver
|
||||
scan->intensities.reserve(scan_num);
|
||||
scan->intensities.assign(scan_num, std::numeric_limits<float>::infinity());
|
||||
scan->scan_time = 0.1;
|
||||
scan->time_increment = 0.1 / (double)(fixed_array_length - 1);
|
||||
scan->time_increment = 0.1 / (double)(scan_num - 1);
|
||||
|
||||
int start_num = floor(angle_able_min * count_num / 360);
|
||||
int end_num = floor(angle_able_max * count_num / 360);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,7 @@
|
||||
# ============================================================================
|
||||
# gc_nav2_with_slam_online_real.launch.py
|
||||
# 功能:真机实时建图 — slam_toolbox 从零建图 + Nav2 导航
|
||||
# 依赖:需先启动 origincar_bringup(底盘驱动 + EKF)
|
||||
# ============================================================================
|
||||
|
||||
import os
|
||||
@@ -29,7 +30,7 @@ def generate_launch_description():
|
||||
pkg_dir, 'params', 'gc_navigation_slam.yaml'))
|
||||
slam_params_file = os.path.join(pkg_dir, 'config', 'slam_toolbox_mapping.yaml')
|
||||
|
||||
# === 3. slam_toolbox:实时建图 → 直接发布到 /map ===
|
||||
# === 3. slam_toolbox:实时建图 → 发布 map→odom ===
|
||||
slam_toolbox_node = Node(
|
||||
package='slam_toolbox',
|
||||
executable='async_slam_toolbox_node',
|
||||
@@ -49,7 +50,7 @@ def generate_launch_description():
|
||||
}.items(),
|
||||
)
|
||||
|
||||
# === 5. 机器人模型 + TF ===
|
||||
# === 5. 机器人模型(URDF 已定义 base_footprint→base_link,无需 static TF)===
|
||||
model = DeclareLaunchArgument(
|
||||
name='model',
|
||||
default_value=os.path.join(origincar_urdf_dir, 'urdf', 'origincar.urdf'))
|
||||
@@ -63,17 +64,9 @@ def generate_launch_description():
|
||||
'use_sim_time': use_sim_time, 'publish_frequency': 30.0}],
|
||||
)
|
||||
|
||||
base_footprint_tf = Node(
|
||||
package='tf2_ros',
|
||||
executable='static_transform_publisher',
|
||||
name='base_footprint_to_base_link',
|
||||
arguments=['0', '0', '0', '0', '0', '0', 'base_footprint', 'base_link'],
|
||||
)
|
||||
|
||||
# === 6. 组装 ===
|
||||
ld.add_action(model)
|
||||
ld.add_action(robot_state_publisher)
|
||||
ld.add_action(base_footprint_tf)
|
||||
ld.add_action(slam_toolbox_node)
|
||||
ld.add_action(navigation_launch)
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ ekf_filter_node:
|
||||
|
||||
map_frame: map
|
||||
odom_frame: odom
|
||||
base_link_frame: base_link
|
||||
base_link_frame: base_footprint
|
||||
world_frame: odom
|
||||
|
||||
odom0: odom
|
||||
|
||||
@@ -212,6 +212,7 @@ private:
|
||||
rclcpp::Subscription<std_msgs::msg::Int32>::SharedPtr Sign_Switch_Sub;
|
||||
|
||||
string usart_port_name, robot_frame_id, gyro_frame_id, odom_frame_id, akm_cmd_vel, test;
|
||||
bool publish_tf_;
|
||||
std::string cmd_vel;
|
||||
int serial_baud_rate;
|
||||
RECEIVE_DATA Receive_Data;
|
||||
|
||||
@@ -37,12 +37,6 @@ def generate_launch_description():
|
||||
)
|
||||
|
||||
|
||||
base_to_link = launch_ros.actions.Node(
|
||||
package='tf2_ros',
|
||||
executable='static_transform_publisher',
|
||||
name='base_to_link',
|
||||
arguments=['0', '0', '0','0', '0','0','base_footprint','base_link'],#arguments=['0.41', '0.12', '0','0', '0','0','base_footprint','base_link'],
|
||||
)
|
||||
|
||||
|
||||
base_to_gyro = launch_ros.actions.Node(
|
||||
@@ -73,10 +67,21 @@ def generate_launch_description():
|
||||
remappings=[("odometry/filtered", "odom_combined")]
|
||||
)
|
||||
|
||||
# 从 URDF 生成 robot_description,供 joint_state_publisher 和 robot_state_publisher 共用
|
||||
from launch_ros.parameter_descriptions import ParameterValue
|
||||
from launch.substitutions import Command
|
||||
|
||||
robot_description = ParameterValue(
|
||||
Command(['xacro ', os.path.join(
|
||||
get_package_share_directory('origincar_description'),
|
||||
'urdf', 'origincar.urdf')]),
|
||||
value_type=str)
|
||||
|
||||
joint_state_publisher_node = launch_ros.actions.Node(
|
||||
package='joint_state_publisher',
|
||||
executable='joint_state_publisher',
|
||||
name='joint_state_publisher',
|
||||
parameters=[{'robot_description': robot_description}],
|
||||
)
|
||||
|
||||
ld = LaunchDescription()
|
||||
@@ -84,7 +89,6 @@ def generate_launch_description():
|
||||
ld.add_action(carto_slam_dec)
|
||||
ld.add_action(akmcar_dec)
|
||||
ld.add_action(origincar_base)
|
||||
ld.add_action(base_to_link)
|
||||
ld.add_action(base_to_gyro)
|
||||
ld.add_action(joint_state_publisher_node)
|
||||
ld.add_action(choose_car)
|
||||
|
||||
@@ -1,24 +1,27 @@
|
||||
import os
|
||||
from pathlib import Path
|
||||
import launch_ros.actions
|
||||
import launch
|
||||
from ament_index_python.packages import get_package_share_directory
|
||||
from launch import LaunchDescription
|
||||
from launch.actions import (DeclareLaunchArgument, GroupAction,LogInfo,
|
||||
IncludeLaunchDescription, SetEnvironmentVariable)
|
||||
from launch.substitutions import LaunchConfiguration
|
||||
from launch_ros.actions import Node
|
||||
from launch_ros.parameter_descriptions import ParameterValue
|
||||
from launch.substitutions import Command
|
||||
|
||||
|
||||
def generate_launch_description():
|
||||
origincar_description = GroupAction([
|
||||
launch_ros.actions.Node(
|
||||
package='robot_state_publisher',
|
||||
executable='robot_state_publisher',
|
||||
name='robot_state_publisher',
|
||||
arguments=[os.path.join(get_package_share_directory('origincar_description'),'urdf','origincar.urdf')]
|
||||
)
|
||||
])
|
||||
|
||||
ld = LaunchDescription()
|
||||
urdf_path = os.path.join(
|
||||
get_package_share_directory('origincar_description'),
|
||||
'urdf', 'origincar.urdf')
|
||||
|
||||
robot_description = ParameterValue(
|
||||
Command(['xacro ', urdf_path]), value_type=str)
|
||||
|
||||
ld.add_action(origincar_description)
|
||||
return ld
|
||||
robot_state_publisher = Node(
|
||||
package='robot_state_publisher',
|
||||
executable='robot_state_publisher',
|
||||
name='robot_state_publisher',
|
||||
parameters=[{'robot_description': robot_description,
|
||||
'publish_frequency': 30.0}],
|
||||
)
|
||||
|
||||
ld = LaunchDescription()
|
||||
ld.add_action(robot_state_publisher)
|
||||
return ld
|
||||
|
||||
0
src/origincar_base/scripts/cmd_vel_to_ackermann_drive.py
Normal file → Executable file
0
src/origincar_base/scripts/cmd_vel_to_ackermann_drive.py
Normal file → Executable file
@@ -225,7 +225,9 @@ void origincar_base::Publish_Odom()
|
||||
t.transform.translation.z = 0.0;
|
||||
|
||||
t.transform.rotation = odom_quat;
|
||||
tf_broadcaster_->sendTransform(t);
|
||||
if (publish_tf_) {
|
||||
tf_broadcaster_->sendTransform(t);
|
||||
}
|
||||
odom_publisher->publish(odom);
|
||||
robotpose_publisher->publish(robotpose);
|
||||
robotvel_publisher->publish(robotvel);
|
||||
@@ -264,7 +266,11 @@ bool origincar_base::Get_Sensor_Data()
|
||||
{
|
||||
short transition_16 = 0, j = 0, Header_Pos = 0, Tail_Pos = 0;
|
||||
uint8_t Receive_Data_Pr[RECEIVE_DATA_SIZE] = {0};
|
||||
Stm32_Serial.read(Receive_Data_Pr,sizeof (Receive_Data_Pr));
|
||||
try {
|
||||
Stm32_Serial.read(Receive_Data_Pr,sizeof (Receive_Data_Pr));
|
||||
} catch (const serial::SerialException& e) {
|
||||
return false;
|
||||
}
|
||||
for (j = 0; j < 24; j++) {
|
||||
if (Receive_Data_Pr[j] == FRAME_HEADER)
|
||||
Header_Pos=j;
|
||||
@@ -375,6 +381,7 @@ origincar_base::origincar_base()
|
||||
this->declare_parameter<std::string>("odom_frame_id", "odom");
|
||||
this->declare_parameter<std::string>("robot_frame_id", "base_link");
|
||||
this->declare_parameter<std::string>("gyro_frame_id", "gyro_link");
|
||||
this->declare_parameter<bool>("publish_tf", false);
|
||||
|
||||
this->get_parameter("serial_baud_rate", serial_baud_rate);
|
||||
this->get_parameter("usart_port_name", usart_port_name);
|
||||
@@ -383,6 +390,7 @@ origincar_base::origincar_base()
|
||||
this->get_parameter("odom_frame_id", odom_frame_id);
|
||||
this->get_parameter("robot_frame_id", robot_frame_id);
|
||||
this->get_parameter("gyro_frame_id", gyro_frame_id);
|
||||
this->get_parameter("publish_tf", publish_tf_);
|
||||
|
||||
odom_publisher = create_publisher<nav_msgs::msg::Odometry>("odom", 10);
|
||||
|
||||
|
||||
@@ -4,12 +4,6 @@
|
||||
<link name="base_footprint">
|
||||
<origin xyz="0 0 0" rpy="0 0 0" />
|
||||
</link>
|
||||
<<<<<<< HEAD
|
||||
<!-- 基础底盘 -->
|
||||
|
||||
|
||||
=======
|
||||
>>>>>>> mo_new
|
||||
<link name="base_link">
|
||||
</link>
|
||||
<joint name="base_joint" type="fixed">
|
||||
@@ -89,11 +83,7 @@
|
||||
</inertial>
|
||||
</link>
|
||||
<joint name="fr_left_steer_joint" type="revolute">
|
||||
<<<<<<< HEAD
|
||||
<origin xyz="0.0841 0.0945 -0.03" rpy="0 0 0" />
|
||||
=======
|
||||
<origin xyz="0.0715 0.0945 -0.03" rpy="0 0 0" />
|
||||
>>>>>>> mo_new
|
||||
<parent link="chassis_link" />
|
||||
<child link="fr_left_steer_link" />
|
||||
<axis xyz="0 0 1" />
|
||||
@@ -146,11 +136,7 @@
|
||||
</inertial>
|
||||
</link>
|
||||
<joint name="fr_right_steer_joint" type="revolute">
|
||||
<<<<<<< HEAD
|
||||
<origin xyz="0.0841 -0.0945 -0.03" rpy="0 0 0" />
|
||||
=======
|
||||
<origin xyz="0.0715 -0.0945 -0.03" rpy="0 0 0" />
|
||||
>>>>>>> mo_new
|
||||
<parent link="chassis_link" />
|
||||
<child link="fr_right_steer_link" />
|
||||
<axis xyz="0 0 1" />
|
||||
@@ -219,11 +205,7 @@
|
||||
</collision>
|
||||
</link>
|
||||
<joint name="re_left_wheel_joint" type="continuous">
|
||||
<<<<<<< HEAD
|
||||
<origin xyz="-0.0841 0.0945 -0.03" rpy="1.5708 0 0" />
|
||||
=======
|
||||
<origin xyz="-0.0715 0.0945 -0.03" rpy="1.5708 0 0" />
|
||||
>>>>>>> mo_new
|
||||
<parent link="chassis_link" />
|
||||
<child link="re_left_wheel_link" />
|
||||
<axis xyz="0 0 -1" />
|
||||
@@ -257,11 +239,7 @@
|
||||
</collision>
|
||||
</link>
|
||||
<joint name="re_right_wheel_joint" type="continuous">
|
||||
<<<<<<< HEAD
|
||||
<origin xyz="-0.0841 -0.0945 -0.03" rpy="-1.5708 0 0" />
|
||||
=======
|
||||
<origin xyz="-0.0715 -0.0945 -0.03" rpy="-1.5708 0 0" />
|
||||
>>>>>>> mo_new
|
||||
<parent link="chassis_link" />
|
||||
<child link="re_right_wheel_link" />
|
||||
<axis xyz="0 0 1" />
|
||||
@@ -287,11 +265,7 @@
|
||||
</inertial>
|
||||
</link>
|
||||
<joint name="virtual_steering_wheel_joint" type="revolute">
|
||||
<<<<<<< HEAD
|
||||
<origin xyz="0.0841 0.0 0.0" rpy="0.0 0.0 0.0" />
|
||||
=======
|
||||
<origin xyz="0.0715 0.0 0.0" rpy="0.0 0.0 0.0" />
|
||||
>>>>>>> mo_new
|
||||
<parent link="chassis_link" />
|
||||
<child link="virtual_steer_link" />
|
||||
<axis xyz="-1 0 0" />
|
||||
@@ -336,10 +310,6 @@
|
||||
<origin rpy="0 0 0" xyz="0 0 0.045" />
|
||||
</joint>
|
||||
|
||||
<<<<<<< HEAD
|
||||
|
||||
=======
|
||||
>>>>>>> mo_new
|
||||
<!-- ackerman -->
|
||||
|
||||
<gazebo>
|
||||
|
||||
Reference in New Issue
Block a user