当前位置: 首页 > news >正文

旅游网站开发的背景及意义wordpress增加连接池

旅游网站开发的背景及意义,wordpress增加连接池,网站品牌栏目建设情况,网站建设专业性评价内容ROS2系列文章目录 ROS2中nav_msgs/msg/Path 数据含义及使用 ROS2中std_msgs/msg/Header 数据含义及使用 ROS中TF变换详解 文章目录 ROS2系列文章目录ROS2中launch编写及参数含义(xml、python)一、ROS官方介绍二、实现案例1.编写主函数、CMakeLists.tx…

ROS2系列文章目录

ROS2中nav_msgs/msg/Path 数据含义及使用

ROS2中std_msgs/msg/Header 数据含义及使用

ROS中TF变换详解


文章目录

  • ROS2系列文章目录
  • ROS2中launch编写及参数含义(xml、python)
  • 一、ROS官方介绍
  • 二、实现案例
    • 1.编写主函数、CMakeLists.txt及package.xml
    • 2.编写启动节点的launch文件
    • 3.编译并运行


ROS2中launch编写及参数含义(xml、python)


一、ROS官方介绍

ROS 2中的启动系统负责帮助用户描述其系统的配置,然后按描述执行。系统的配置包括运行什么程序,在哪里运行,传递什么参数,以及ROS特定的约定,这些约定通过为每个组件提供不同的配置,使其易于在整个系统中重用组件。它还负责监测启动过程的状态,并报告和/或对这些过程的状态变化作出反应。
ROS2官方说明:http://docs.ros.org/en/humble/Tutorials/Intermediate/Launch/Creating-Launch-Files.html#write-the-launch-file

二、实现案例

1.编写主函数、CMakeLists.txt及package.xml

此处创建learn_ros2功能包,在learn_ros2/src目录下建立main.cpp,该函数具体实现功能参照博文:ROS2中nav_msgs/msg/Path 数据含义及使用

#include <nav_msgs/msg/path.hpp>
#include <rclcpp/rclcpp.hpp>
#include <string>
#include <unistd.h>
using namespace std;
class My_node:public rclcpp::Node{
public:My_node(std::string node_name):Node(node_name){}
};
int main(int argc, char**argv){rclcpp::init(argc,argv);//节点初始化std::shared_ptr<My_node> node_ptr = std::make_shared<My_node>("test_node");rclcpp::Publisher<nav_msgs::msg::Path>::SharedPtr nav_pub = node_ptr->create_publisher<nav_msgs::msg::Path>("/global_path",1);nav_msgs::msg::Path path;geometry_msgs::msg::PoseStamped pose;path.header.frame_id = "world";while (rclcpp::ok()){path.header.stamp = node_ptr->now();path.poses.clear();for (int i = 0; i < 10; i++){pose.header.frame_id = "world";pose.header.stamp = node_ptr->now();pose.pose.position.set__x(i);pose.pose.position.set__y(0.2*i*i+2);pose.pose.position.set__z(0);pose.pose.orientation.set__x(0);pose.pose.orientation.set__y(0);pose.pose.orientation.z = 0;pose.pose.orientation.w = 1;path.poses.push_back(pose);}nav_pub->publish(path);sleep(1);std::cout<<"已发送path"<<std::endl;}    std::cout<<"退出程序"<<std::endl;
}

指定功能包learn_ros2的CMakeLists.txt如下:

cmake_minimum_required(VERSION 3.8)
project(learn_ros2)if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")add_compile_options(-Wall -Wextra -Wpedantic)
endif()
# find dependencies
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(rclpy REQUIRED)
find_package(std_msgs REQUIRED)
find_package(nav_msgs REQUIRED)
if(BUILD_TESTING)find_package(ament_lint_auto REQUIRED)# the following line skips the linter which checks for copyrights# comment the line when a copyright and license is added to all source filesset(ament_cmake_copyright_FOUND TRUE)# the following line skips cpplint (only works in a git repo)# comment the line when this package is in a git repo and when# a copyright and license is added to all source filesset(ament_cmake_cpplint_FOUND TRUE)ament_lint_auto_find_test_dependencies()
endif()
#添加可执行文件名
add_executable(test_node src/main.cpp)
#给可执行文件链接ros2的标准库及其他依赖
ament_target_dependencies(test_node rclcpp std_msgs nav_msgs)
#将可执行文件安装在指定目录下
install(TARGETS test_node
DESTINATION lib/${PROJECT_NAME})
#将launch目录下的文件安装在指定目录下
install(DIRECTORY launchDESTINATION share/${PROJECT_NAME})
ament_package()

2.编写启动节点的launch文件

在learn_ros2目录下建立launch文件夹,并在文件目录中新建python及xml文件如下:
test_launch.launch.py,test_xml_launch.xml

首先使用python实现test_launch.launch.py文件,具体含义参考注释

from launch import LaunchDescription
from launch_ros.actions import Nodedef generate_launch_description():parameters_basic1 = Node(package="learn_ros2",executable="test_node",)# 创建LaunchDescription对象launch_description,用于描述launch文件launch_description = LaunchDescription([parameters_basic1])# 返回让ROS2根据launch描述执行节点return launch_description

该处使用的url网络请求的数据。

使用XML实现test_xml_launch.xml文件,具体含义参考注释

<launch><!-- 启动节点,命名为/name1/test_node --><node pkg="learn_ros2" exec="test_node" name="test_node" namespace="name_1"/><!-- 启动节点,命名为/name2/test_node --><node pkg="learn_ros2" exec="test_node" name="test_node" namespace="name_2"/><!-- 启动节点,命名为/name3/test_node,同时将话题/global_path,映射为/test_node3/global_path--><node pkg="learn_ros2" exec="test_node" name="test_node" namespace="name_3"><remap from="/global_path" to="/test_node3/global_path"/></node> </launch>

3.编译并运行

注意:编写完成launch文件后,要使用ros2编译命令对功能包的可执行文件进行生成

使用test_xml_launch.xml启动各个程序

source install/setup.bash
ros2 launch learn_ros2 test_xml_launch.xml

请添加图片描述

使用test_launch.launch.py启动各个程序如下:

请添加图片描述

http://www.yayakq.cn/news/933472/

相关文章:

  • 个人网站做企业备案吗室内设计师经常用的网站
  • 昆明优化网站排名凡克
  • 网站备案教育审批号网站地图html怎么做
  • 网站推广计划方案专业返利网站开发
  • 做个网站哪里可以做vi手册模板免费
  • 安达网站制作怎么做淘客的网站
  • 惠州做网站的公司网络营销的8个基本职能
  • 用vs2008做网站视频教程wordpress归档页面
  • 境外网站开发百度百科词条创建入口
  • 企业自有网站水墨 网站模板
  • 沧州网站建设方案咨询门户网站代码
  • php网站建设网站js网站模板免费下载
  • 建站之星和凡科建站哪个系统好企业建站都有什么网站
  • 电脑网站模板wordpress 移动 插件
  • 新闻发布网站模板智能网站建设服务
  • 望城区建设局网站网站开发文档有哪些
  • 福州网站开发培训南昌定制网站开发
  • 怎样做微信网站云南网站建设效果好吗
  • 网页传奇176金融网站排名优化
  • 网站开发运行环境有哪些打开网站不要出现 index.html
  • python做网站的好处眼镜网站源码
  • 设计软件ai网站建设备案优化之看
  • 龙岗外贸网站建设公司价格乾县交通建设网站
  • 成都做小程序的开发公司轻松seo优化排名 快排
  • 男的做直播哪个网站上海加盟网站建设
  • 如何建立公司的销售网站怎么做自己地网站
  • 厚街网站仿做定制开发app的注意事项
  • 做搜狗pc网站seo优化方案书
  • 东莞网站推广及优化可以做公众号封面图的网站
  • 十大免费剪辑软件下载网站是怎么做优化