首页 > 系统相关 >系统ubuntu20.04-ROS2源码安装humble

系统ubuntu20.04-ROS2源码安装humble

时间:2023-06-03 11:31:42浏览次数:49  
标签:ubuntu20.04 cartographer -- humble apt 源码 ros ros2


系统要求

Humble Hawksbill目前基于Debian的目标平台是

  • Tier 1: Ubuntu Linux - Jammy (22.04) 64-bit
  • Tier 3: Ubuntu Linux - Focal (20.04) 64-bit
  • Debian Linux - Bullseye (11) 64-bit

其他具有不同支持级别的Linux平台包括:

Arch Linux, see alternate instructions
Fedora Linux, see alternate instructions
OpenEmbedded / webOS OSE, see alternate instructions

As defined in REP 2000.

一. 系统设置

1.1区域设置

请确保您的区域设置支持UTF-8,如果您处于一个最小的环境(例如docker容器)中,那么区域设置可能是像POSIX这样的最小环境。我们使用以下设置进行测试。但是,如果您使用的是不同的UTF-8支持的区域设置,则应该可以。

locale  # check for UTF-8

sudo apt update && sudo apt install locales
sudo locale-gen en_US en_US.UTF-8
sudo update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
export LANG=en_US.UTF-8

locale  # verify settings

添加ROS 2 apt仓库

您需要将ROS2 apt存储库添加到您的系统中

首先确保Ubuntu Universe存储库已启用。

系统ubuntu20.04-ROS2源码安装humble_bash

sudo apt install software-properties-common
sudo add-apt-repository universe

现在添加带有apt的ROS 2 GPG密钥

sudo apt update && sudo apt install curl -y
sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg

然后将存储库添加到源列表中。

echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(. /etc/os-release && echo $UBUNTU_CODENAME) main" | sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null

安装开发工具和ROS工具

sudo apt update && sudo apt install -y \
  python3-flake8-docstrings \
  python3-pip \
  python3-pytest-cov \
  ros-dev-tools

根据你的Ubuntu版本安装软件包。

ubuntu20.04 LTS

python3 -m pip install -U \
   flake8-blind-except \
   flake8-builtins \
   flake8-class-newline \
   flake8-comprehensions \
   flake8-deprecated \
   flake8-import-order \
   flake8-quotes \
   "pytest>=5.3" \
   pytest-repeat \
   pytest-rerunfailures

ubuntu22.04 LTS and later

sudo apt install -y \
   python3-flake8-blind-except \
   python3-flake8-builtins \
   python3-flake8-class-newline \
   python3-flake8-comprehensions \
   python3-flake8-deprecated \
   python3-flake8-import-order \
   python3-flake8-quotes \
   python3-pytest-repeat \
   python3-pytest-rerunfailures

获取ROS2的源码

创建一个工作区并克隆所有源码:

mkdir -p ~/ros2_humble/src
cd ~/ros2_humble
vcs import --input https://raw.githubusercontent.com/ros2/ros2/humble/ros2.repos src

 使用rosdep安装依赖

ROS2软件包建立在频繁更新的Ubuntu系统上。始终建议您在安装新软件包之前确保系统是最新的。

sudo apt upgrade
sudo rosdep init
rosdep update
rosdep install --from-paths src --ignore-src -y --skip-keys "fastcdr rti-connext-dds-6.0.1 urdfdom_headers"

如果你使用的发行版是基于Ubuntu的(比如Linux Mint),但没有将自己标识为Ubuntu,你会收到一条错误消息,比如Unsupported OS[Mint]。在这种情况下,将--os=ubuntu:jammy附加到上面的命令中。

安装其他DDS实现(可选)

如果您想使用默认之外的其他DDS或RTPS供应商,您可以在此处找到说明。here.

在工作区中编译代码

如果您已经以另一种方式(通过Debians或二进制发行版)安装了ROS 2,请确保您在没有其他安装来源的新环境中运行以下命令。还要确保你的.bashrc中没有source/opt/ros/${ros_DISTRO}/setup.bash。你可以确保ros 2不是用命令printenv|grep-i ros来源的。输出应该为空.

关于使用ROS工作区的更多信息可以在本教程中找到。this tutorial.

cd ~/ros2_humble/
colcon build --symlink-install

注意:如果您在编译所有示例时遇到问题,并且这使您无法成功完成构建,则可以使用COLCON_IGNORE,方法与CATKIN_IGNORE相同,以忽略子树或从工作区中删除文件夹。举个例子:您希望避免安装大型OpenCV库。那么,只需在cam2image演示目录中运行touch COLCON_IGNORE,就可以将其排除在构建过程之外。

环境设置

source setup script

通过获取以下文件来设置您的环境。

# Replace ".bash" with your shell if you're not using bash
# Possible values are: setup.bash, setup.sh, setup.zsh
. ~/ros2_humble/install/local_setup.bash

尝试一些例子

在一个终端中,获取设置文件,然后运行C++讲话器:

. ~/ros2_humble/install/local_setup.bash
ros2 run demo_nodes_cpp talker

在另一个终端源中,安装文件,然后运行Python侦听器:

. ~/ros2_humble/install/local_setup.bash
ros2 run demo_nodes_py listener

你应该看到talker说这是发布消息,而listener说我听到了这些消息。这将验证C++和Python API是否正常工作.

安装之后

教程Continue with the tutorials and demos to configure your environment, create your own workspace and packages, and learn ROS 2 core concepts.

使用ROS1桥

ROS 1桥可以连接从ROS 1到ROS 2的话题,反之亦然。

See the dedicated documentation on how to build and use the ROS 1 bridge.

其他RMW实现(可选)

ROS2使用的默认中间件是Fast DDS,但中间件(RMW)可以在运行时替换。请参阅有关如何使用多个RMW的指南。 guide 

可替换的编译器

除了gcc之外,使用不同的编译器来编译ROS2是很容易的。如果将环境变量CC和CXX分别设置为工作的C和C++编译器的可执行文件,并重新触发CMake配置(通过使用-force-CMake-config或删除要受影响的包),CMake将重新配置并使用不同的编译器。

Clang

配置CMake来检测和使用Clang:

sudo apt install clang
export CC=clang
export CXX=clang++
colcon build --cmake-force-configure

卸载

1、如果您按照上面的说明使用colcon安装了工作区,那么“卸载”可能只是打开一个新的终端,而不是获取工作区的设置文件。这样,您的环境将表现得好像您的系统上没有Humble安装一样。

2、如果您还试图释放空间,可以使用以下命令删除整个工作区目录:

rm -rf ~/ros2_humble

 

 

 

1.安装cartographer

下载源码

git clone https://ghproxy.com/https://github.com/ros2/cartographer.git -b ros2
git clone https://ghproxy.com/https://github.com/ros2/cartographer_ros.git -b ros2

source一下humble的目录source ~/ros2_humble/humble/local_setup.zsh

会出现如下问题

pcl_conversions", but CMake did not find one.
以及下面
Could not find a package configuration file provided by "pcl_msgs" with any
  of the following names:

    pcl_msgsConfig.cmake
    pcl_msgs-config.cmake

然后需要源码下载

git clone https://github.com/ros-perception/perception_pcl  选择ros2版本的
git clone https://github.com/ros-perception/pcl_msgs -b ros2

编译的时候需要source ~/ros2_humble/humble/local_setup.zsh

然后按照cmake的方式编译即可。之后再编译cartographer即可colcon build

使用单线激光雷达运行cartographer在 ros2下的humble版本

 配置好urdf

<!--
  Copyright 2016 The Cartographer Authors

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->

<robot name="cartographer_backpack_2d">
  <material name="orange">
    <color rgba="1.0 0.5 0.2 1" />
  </material>
  <material name="gray">
    <color rgba="0.2 0.2 0.2 1" />
  </material>

  <link name="imu_link">
    <visual>
      <origin xyz="0 0 0" />
      <geometry>
        <box size="0.06 0.04 0.02" />
      </geometry>
      <material name="orange" />
    </visual>
  </link>

  <link name="base_scan">
    <visual>
      <origin xyz="0 0 0" />
      <geometry>
        <cylinder length="0.05" radius="0.03" />
      </geometry>
      <material name="gray" />
    </visual>
  </link>

  <link name="vertical_laser_link">
    <visual>
      <origin xyz="0 0 0" />
      <geometry>
        <cylinder length="0.05" radius="0.03" />
      </geometry>
      <material name="gray" />
    </visual>
  </link>

  <link name="base_footprint" />

  <joint name="imu_link_joint" type="fixed">
    <parent link="base_footprint" />
    <child link="imu_link" />
    <origin xyz="0 0 0" />
  </joint>

  <joint name="base_scan_joint" type="fixed">
    <parent link="base_footprint" />
    <child link="base_scan" />
    <origin rpy="0 0.0 0.0" xyz="0.0 0 0.0" />
  </joint>

  <joint name="vertical_laser_link_joint" type="fixed">
    <parent link="base_footprint" />
    <child link="vertical_laser_link" />
    <origin rpy="0 -1.570796 3.141593" xyz="0.1007 0 0.1814" />
  </joint>
</robot>

新建配置文件

 

-- Copyright 2016 The Cartographer Authors
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
--      http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.

include "map_builder.lua"
include "trajectory_builder.lua"

options = {
  map_builder = MAP_BUILDER,
  trajectory_builder = TRAJECTORY_BUILDER,
  map_frame = "map",
  tracking_frame = "base_footprint",
  published_frame = "base_footprint",
  odom_frame = "odom",
  provide_odom_frame = true,
  publish_frame_projected_to_2d = false,
  use_pose_extrapolator = true,
  use_odometry = false,
  use_nav_sat = false,
  use_landmarks = false,
  num_laser_scans = 1,
  num_multi_echo_laser_scans = 0,
  num_subdivisions_per_laser_scan = 1,
  num_point_clouds = 0,
  lookup_transform_timeout_sec = 0.2,
  submap_publish_period_sec = 0.3,
  pose_publish_period_sec = 5e-3,
  trajectory_publish_period_sec = 30e-3,
  rangefinder_sampling_ratio = 1.,
  odometry_sampling_ratio = 1.,
  fixed_frame_pose_sampling_ratio = 1.,
  imu_sampling_ratio = 1.,
  landmarks_sampling_ratio = 1.,
}

MAP_BUILDER.use_trajectory_builder_2d = true

TRAJECTORY_BUILDER_2D.submaps.num_range_data = 35
TRAJECTORY_BUILDER_2D.min_range = 0.3
TRAJECTORY_BUILDER_2D.max_range = 8.
TRAJECTORY_BUILDER_2D.missing_data_ray_length = 1.
TRAJECTORY_BUILDER_2D.use_imu_data = false
TRAJECTORY_BUILDER_2D.use_online_correlative_scan_matching = true
TRAJECTORY_BUILDER_2D.real_time_correlative_scan_matcher.linear_search_window = 0.1
TRAJECTORY_BUILDER_2D.real_time_correlative_scan_matcher.translation_delta_cost_weight = 10.
TRAJECTORY_BUILDER_2D.real_time_correlative_scan_matcher.rotation_delta_cost_weight = 1e-1

POSE_GRAPH.optimization_problem.huber_scale = 1e2
POSE_GRAPH.optimize_every_n_nodes = 35
POSE_GRAPH.constraint_builder.min_score = 0.65

return options

新建launch文件

"""
  Copyright 2018 The Cartographer Authors
  Copyright 2022 Wyca Robotics (for the ros2 conversion)

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
"""

from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument, IncludeLaunchDescription, ExecuteProcess
from launch.conditions import IfCondition, UnlessCondition
from launch.substitutions import LaunchConfiguration
from launch_ros.actions import Node, SetRemap
from launch_ros.substitutions import FindPackageShare
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch.actions import Shutdown
import os

def generate_launch_description():
    ## ***** Launch arguments *****
    bag_filename_arg = DeclareLaunchArgument('bag_filename')

  ## ***** File paths ******
    pkg_share = FindPackageShare('cartographer_ros').find('cartographer_ros')
    urdf_dir = os.path.join(pkg_share, 'urdf')
    urdf_file = os.path.join(urdf_dir, 'backpack_2d.urdf')
    with open(urdf_file, 'r') as infp:
        robot_desc = infp.read()

    ## ***** Nodes *****
    robot_state_publisher_node = Node(
        package = 'robot_state_publisher',
        executable = 'robot_state_publisher',
        parameters=[
            {'robot_description': robot_desc},
            {'use_sim_time': False}],
        output = 'screen'
        )

    cartographer_node = Node(
        package = 'cartographer_ros',
        executable = 'cartographer_node',
        parameters = [{'use_sim_time': False}],
        arguments = [
            '-configuration_directory', FindPackageShare('cartographer_ros').find('cartographer_ros') + '/configuration_files',
            '-configuration_basename', 'my_revo_lds.lua'],
        remappings = [
            ('scan', 'scan')],#节点映射,修改为scan
        output = 'screen'
        )

    cartographer_occupancy_grid_node = Node(
        package = 'cartographer_ros',
        executable = 'cartographer_occupancy_grid_node',
        parameters = [
            {'use_sim_time': False},
            {'resolution': 0.05}],
        )

    rviz_node = Node(
        package = 'rviz2',
        executable = 'rviz2',
        on_exit = Shutdown(),
        arguments = ['-d', FindPackageShare('cartographer_ros').find('cartographer_ros') + '/configuration_files/demo_2d.rviz'],
        parameters = [{'use_sim_time': False}],
    )

    ros2_bag_play_cmd = ExecuteProcess(
        cmd = ['ros2', 'bag', 'play', LaunchConfiguration('bag_filename'), '--clock'],
        name = 'rosbag_play',
    )

    return LaunchDescription([
        # Launch arguments
        #bag_filename_arg, 注释
        # Nodes
        robot_state_publisher_node,
        cartographer_node,
        cartographer_occupancy_grid_node,
        rviz_node,
        #ros2_bag_play_cmd 注释
    ])

系统ubuntu20.04-ROS2源码安装humble_Ubuntu_02

 https://docs.ros.org/en/humble/Tutorials.html#

 

标签:ubuntu20.04,cartographer,--,humble,apt,源码,ros,ros2
From: https://blog.51cto.com/u_15754466/6407644

相关文章

  • 基于JAVA的springboot篮球论坛系统,附源码+数据库+论文+PPT
    1、项目介绍考虑到实际生活中在篮球论坛方面的需要以及对该系统认真的分析,将系统权限按管理员和用户这两类涉及用户划分。(a)管理员;管理员使用本系统涉到的功能主要有:首页、个人中心、用户管理、篮球论坛、系统管理等功能。管理员用例图如图3-1所示。(b)用户;用户使用本系统......
  • do_page_fault源码阅读
    前言参考《Linux内核源码情景分析》对缺页异常的处理过程,但是书中的kernelversion版本较老,因此本文基于kernelversion4.19.20源码,参考oldversion的内核源码剖析,再次进行了阅读。缺页异常的产生原因缺页异常就在通过虚拟地址去访问物理内存的过程中出现失败时抛出的异常,访问......
  • 还在用BeanUtils拷贝对象?MapStruct才是王者!【附源码】
    前几天,远在北京的小伙伴在群里抛出了“MapStruct”的概念。对于只闻其名,未见其人的我来说,决定对其研究一番。本文我们就从MapStruct的概念出发,通过具体的代码示例来研究它的使用情况,最后与“市面上”的其它工具来做个对比!官方介绍首先我们打开MapStruct的官网地址,映入眼帘的就......
  • 独立商户商城全套方案带源码
    前两天分享了一个基于微信生态的多租户商城[分享一个基于微信生态的多租户商城]这个部署起来比较麻烦,首先需要一个认证的微信开发平台账号和一个认证的微信公众号账号。今天分享另外一个商城,这个商城跟微信生态没有绑定这么紧密,但是功能相对还是满满的。0x01:后台端服务仓库地址......
  • 视频直播网站源码,Java过滤相同name的字符
    视频直播网站源码,Java过滤相同name的字符第一种 privatestaticStringss(Stringname)  {    String[]str=name.split(",");    if(str.length==0)    {      returnnull;    }    List<String>list=ne......
  • SeaTunnel V2.3.1源码分析--zeta引擎启动过程分析
    今天主要看SeaTunnel自研的数据同步引擎,叫Zeta。首先,如果使用的是zeta引擎,那么第一步一定是运行bin/seatunnel-cluster.sh脚本,这个脚本就是启动zeta的服务端的。打开seatunnel-cluster.sh看看,可以看到其实是去启动seatunnel-core/seatunnel-starter/src/main/java/org/apache/se......
  • 基于JAVA的springboot+vue财务管理系统,附源码+数据库+论文+PPT
    1、项目介绍随着信息技术和网络技术的飞速发展,人类已进入全新信息化时代,传统管理技术已无法高效,便捷地管理信息。为了迎合时代需求,优化管理效率,各种各样的管理系统应运而生,各行各业相继进入信息管理时代,财务管理系统就是信息时代变革中的产物之一。任何系统都要遵循系统设计的基......
  • drf之频率类源码
    1频率类写一个类,继承SimpleRateThrottle,重写get_cache_key,返回[ip,用户id]什么,就以什么做限制,编写类属性scope=字符串,在配置文件中配置'DEFAULT_THROTTLE_RATES':{'字符串':'3/m',}配置在视图类,全局使用(配置在配置文件中)2自定义频率类......
  • springboot整合shiro实现认证授权源码
    shiro-admin介绍springboot整合shiro实现前后端分离架构(swagger文档协调前端开发)源码地址:https://gitee.com/liujinxin_ark/shiro-admin软件架构架构说明springboot+shiro+mysql+swagger使用说明运行项目后访问http://localhost:8080/doc.html即可进入swagger接口文档界......
  • 源码、二进制可执行文件、jar包
    源码(Sourcecode):源码是开发人员编写的人类可读的程序代码,它以文本文件的形式存在,并使用特定的编程语言编写。源码包含了程序的逻辑、算法和操作步骤,以及相关的注释和文档说明。源码通常存储在版本控制系统中,并且用于开发、调试和维护软件。二进制文件(Binaryfile):二进制文件是......