你可以在不启动rviz的情况下在地图上导航我的TurtleBot3吗?(Foxy-ROS2)

huangapple go评论77阅读模式
英文:

Can I navigate my turtlebot3 on a map without lauching rviz? (Foxy-ROS2)

问题

I am trying to navigate turtlebot on a map I created. I use these commands:

ros2 topic pub --once /initialpose geometry_msgs/msg/PoseWithCovarianceStamped "{header: {stamp: {sec: 0, nanosec: 0}, frame_id: 'map'}, pose:{pose: {position: {x: 0.0,y: 0.0, z: 0.0}, orientation: {x: 0.0, y: 0.0, z: 0.0, w: 1.0}}}}"

ros2 topic pub /goal_pose geometry_msgs/PoseStamped "{header: {stamp: {sec: 0, nanosec: 0}, frame_id: 'map2'}, pose: {position: {x: 2.53,y: 1.03, z: 0.0}, orientation: {x: 0.0, y: 0.0, z: 5.0, w: 1.0}}}"

They work but only if I first run:

ros2 launch turtlebot3_navigation2 navigation2.launch.py map:=/home/---/Desktop/Folder/map2.yaml

I want to skip opening rviz in order to control the bot with a less powerful computer as rviz (I believe) will consume resource. Is there a way to skip rviz?

I tried these but nothing happened:

ros2 launch nav2_bringup navigation_launch.py map:=/home/---/Desktop/Folder/map2.yaml

ros2 run nav2_map_server map_server /home/---/Desktop/Folder/map2.yaml (then) ros2 launch nav2_bringup navigation_launch.py

Neither worked. I get this error:

[planner_server-2] [INFO] [1680782755.903735844] [global_costmap.global_costmap]: Timed out waiting for transform from base_link to map to become available, tf error: Invalid frame ID "map" passed to canTransform argument target_frame - frame does not exist

英文:

I am trying to navigate turtlebot on a map I created. I use these commands:

ros2 topic pub --once /initialpose geometry_msgs/msg/PoseWithCovarianceStamped "{header: {stamp: {sec: 0, nanosec: 0}, frame_id: 'map'}, pose:{pose: {position: {x: 0.0,y: 0.0, z: 0.0}, orientation: {x: 0.0, y: 0.0, z: 0.0, w: 1.0}}}}"

ros2 topic pub /goal_pose geometry_msgs/PoseStamped "{header: {stamp: {sec: 0, nanosec: 0}, frame_id: 'map2'}, pose: {position: {x: 2.53,y: 1.03, z: 0.0}, orientation: {x: 0.0, y: 0.0, z: 5.0, w: 1.0}}}"

They work but only if I first run :

ros2 launch turtlebot3_navigation2 navigation2.launch.py map:=/home/---/Desktop/Folder/map2.yaml

I want to skip opening rviz in order to control the bot with a less powerful computer as rviz (I believe) will consume resource. Is there a way to skip rviz?

I tried these but nothing happeened:
ros2 launch nav2_bringup navigation_launch.py map:=/home/---/Desktop/Folder/map2.yaml

ros2 run nav2_map_server map_server /home/---/Desktop/Folder/map2.yaml (then) ros2 launch nav2_bringup navigation_launch.py

Neither worked. I get this error:

[planner_server-2] [INFO] [1680782755.903735844] [global_costmap.global_costmap]: Timed out waiting for transform from base_link to map to become available, tf error: Invalid frame ID "map" passed to canTransform argument target_frame - frame does not exist

答案1

得分: 1

你正在使用一个名为(.launch)的文件,其中包含了启动rviz2的信息!

.launch文件用于在单个脚本中运行多个节点或命令。通常,包中包含的.launch文件用于参考,而不是用于部署。

我建议你基于navigation2.launch.py创建一个新的(.launch)文件。如果要在不使用rviz2的情况下运行,只需从脚本中将其移除。

以下这些行用于获取rviz配置文件3

rviz_config_dir = os.path.join(
    ('nav2_bringup'),
    rviz',
    nav2_default_view.rviz)

以下这些行告诉脚本使用'rviz_config_dir'来运行rviz21

Node(
    package='rviz2',
    executable='rviz2',
    name='rviz2',
    arguments=['-d', rviz_config_dir],
    parameters=[{'use_sim_time': use_sim_time}],
    output='screen'),

如果只移除最后一个部分,就可以实现你的目标!

英文:

You're using a (.launch) file that launches rviz2 in it!

Launch files are used to run multiple nodes or commands in a single script. Usually, the launch files included in packages are used for reference and not meant for deployment.

I recommend you create a new (.launch) file based on navigation2.launch.py. To run without rviz2 you just have to remove it from the script.

The following lines get the rviz config file:

rviz_config_dir = os.path.join(
 ('nav2_bringup'),
 rviz',
 nav2_default_view.rviz)

The following lines tell the script to run rviz2 with 'rviz_config_dir':

Node(
 package='rviz2',
 executable='rviz2',
 name='rviz2',
 arguments=['-d', rviz_config_dir],
 parameters=[{'use_sim_time': use_sim_time}],
 output='screen'),

If you just remove this last one, that will do the trick!

huangapple
  • 本文由 发表于 2023年4月6日 20:10:39
  • 转载请务必保留本文链接:https://go.coder-hub.com/75949376.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定