拓展3:FishBot 树莓派配置建图导航
-
@2216200358 在 拓展3:FishBot 树莓派配置建图导航 中说:
robot_state_publisher_node = Node(
package='robot_state_publisher',
executable='robot_state_publisher',
arguments=[urdf_model_path]
)这个写的感觉不太对,应该加个参数好像,你看看书前面的代码,或者最近B站的课程,也可以把TF贴出来看看
-
@小鱼 ```
#include <rclcpp/rclcpp.hpp>
#include <rclcpp/rclcpp.hpp>
#include <nav_msgs/msg/odometry.hpp>
#include <tf2/utils.h>
#include <tf2_ros/transform_broadcaster.h>class TopicSubscribe01 : public rclcpp::Node
{
public:
TopicSubscribe01(std::string name) : Node(name)
{
RCLCPP_INFO(this->get_logger(), "大家好,我是%s.", name.c_str());
odom_subscribe_ = this->create_subscription<nav_msgs::msg::Odometry>("odom", rclcpp::SensorDataQoS(), std::bind(&TopicSubscribe01::odom_callback, this, std::placeholders::1));
tf_broadcaster = std::make_unique<tf2_ros::TransformBroadcaster>(this);
}private:
// 声明一个订阅者
rclcpp::Subscription<nav_msgs::msg::Odometry>::SharedPtr odom_subscribe_;
std::unique_ptr<tf2_ros::TransformBroadcaster> tf_broadcaster_;
nav_msgs::msg::Odometry odom_msg_;void odom_callback(const nav_msgs::msg::Odometry::SharedPtr msg)
{
(void)msg;
RCLCPP_INFO(this->get_logger(), "recv odom->base_footprint tf :(%f,%f)", msg->pose.pose.position.x, msg->pose.pose.position.y);
odom_msg_.pose.pose.position.x = msg->pose.pose.position.x;
odom_msg_.pose.pose.position.y = msg->pose.pose.position.y;
odom_msg_.pose.pose.position.z = msg->pose.pose.position.z;odom_msg_.pose.pose.orientation.x = msg->pose.pose.orientation.x; odom_msg_.pose.pose.orientation.y = msg->pose.pose.orientation.y; odom_msg_.pose.pose.orientation.z = msg->pose.pose.orientation.z; odom_msg_.pose.pose.orientation.w = msg->pose.pose.orientation.w;
};
public:
void publish_tf()
{
geometry_msgs::msg::TransformStamped transform;
double seconds = this->now().seconds();
transform.header.stamp = rclcpp::Time(static_cast<uint64_t>(seconds * 1e9));
transform.header.frame_id = "odom";
transform.child_frame_id = "base_footprint";transform.transform.translation.x = odom_msg_.pose.pose.position.x; transform.transform.translation.y = odom_msg_.pose.pose.position.y; transform.transform.translation.z = odom_msg_.pose.pose.position.z; transform.transform.rotation.x = odom_msg_.pose.pose.orientation.x; transform.transform.rotation.y = odom_msg_.pose.pose.orientation.y; transform.transform.rotation.z = odom_msg_.pose.pose.orientation.z; transform.transform.rotation.w = odom_msg_.pose.pose.orientation.w; tf_broadcaster_->sendTransform(transform);
}
};int main(int argc, char argv)
{
rclcpp::init(argc, argv);
/产生一个的节点/
auto node = std::make_shared<TopicSubscribe01>("fishbot_bringup");
/ 运行节点,并检测退出信号/
rclcpp::WallRate loop_rate(1000.0);
while (rclcpp::ok())
{
rclcpp::spin_some(node);
node->publish_tf();
loop_rate.sleep();
}rclcpp::shutdown();
return 0;
} -
@小鱼 tf指的是 rqt-tf-tree 图,可以看看前面基础课程
-
小 小鱼 在 中 引用了 这个主题
-
@小鱼 在 拓展3:FishBot 树莓派配置建图导航 中说:
ros2 launch fishbot_bringup fishbot_bringup.launch.py
ken@ken-desktop:~/fishbot$ ros2 launch fishbot_bringup fishbot_bringup.launch.py
[INFO] [launch]: All log files can be found below /home/ken/.ros/log/2025-02-11-10-49-43-274026-ken-desktop-11936
[INFO] [launch]: Default logging verbosity is set to INFO
[INFO] [joint_state_publisher-1]: process started with pid [11939]
[INFO] [robot_state_publisher-2]: process started with pid [11940]
[INFO] [fishbot_bringup-3]: process started with pid [11941]
[robot_state_publisher-2] [WARN] [1739242183.457418801] [robot_state_publisher]: No robot_description parameter, but command-line argument available. Assuming argument is name of URDF file. This backwards compatibility fallback will be removed in the future.
[robot_state_publisher-2] [INFO] [1739242183.470537019] [robot_state_publisher]: Robot initialized
[fishbot_bringup-3] [INFO] [1739242183.476659215] [fishbot_bringup]: 大家好,我是fishbot_bringup.
鱼哥,出现这种情况是怎么回事呢? -
@Dutton_Ranch 可以忽略,确保 rqt-tf-tree 正常就行
-
鱼哥,我在运行slam之后出现以下情况,rvzi2显示的图像也仅仅是小红点,请问这是正常的吗?
ken@ken-desktop:~$ ros2 launch slam_toolbox online_async_launch.py
[INFO] [launch]: All log files can be found below /home/ken/.ros/log/2025-02-11-16-08-46-957579-ken-desktop-5364
[INFO] [launch]: Default logging verbosity is set to INFO
[INFO] [async_slam_toolbox_node-1]: process started with pid [5380]
[async_slam_toolbox_node-1] [INFO] [1739261328.623784436] [slam_toolbox]: Node using stack size 40000000
[async_slam_toolbox_node-1] [INFO] [1739261328.759676062] [slam_toolbox]: Configuring
[async_slam_toolbox_node-1] [INFO] [1739261328.827550390] [slam_toolbox]: Using solver plugin solver_plugins::CeresSolver
[async_slam_toolbox_node-1] [INFO] [1739261328.828714298] [slam_toolbox]: CeresSolver: Using SCHUR_JACOBI preconditioner.
[INFO] [launch.user]: [LifecycleLaunch] Slamtoolbox node is activating.
[async_slam_toolbox_node-1] [INFO] [1739261328.985683981] [slam_toolbox]: Activating
[async_slam_toolbox_node-1] Info: clipped range threshold to be within minimum and maximum range!
[async_slam_toolbox_node-1] [WARN] [1739261329.115561229] [slam_toolbox]: maximum laser range setting (20.0 m) exceeds the capabilities of the used Lidar (8.0 m)
[async_slam_toolbox_node-1] Registering sensor: [Custom Described Lidar]
如果这个时候我保存地图成功,但是与rvzi2的显示不同,请问如何设置才能让rvzi2和保存的图片一致呢? -
@小鱼 好的谢谢
-
@小鱼 你好,我想问一下为什么我在将建立好的地图导入后并且修改了launch文件,开始导航后出现的图片为
,我修改后的launch文件为
-
@Dutton_Ranch 修改后重新编译了吗,看一下ROS2基础教程
-
@小鱼 谢谢提醒,我在基础教程里找到问题了,我的.yaml文件中image名称没有修改过来。