ROS学习之利用xacro/URDF模型搭建及rviz和gazebo仿真

2023-11-09

建议好好研究一下P3DX中的代码,非常有借鉴意义。

xacro非常重要的作用是利用类似宏的方式,利用参数化来快速搭建模型。

A ROS/Gazebo Pioneer 3DX model created by Rafael Berkvens modified by Mario Serna Hernández. 地址:https://github.com/mario-serna/pioneer_p3dx_model

文件1:pxdx.xacro

最开始引用了另外两个文件,后面会说。

link中主要有三个部分:简化后删除原有的mesh文件,mesh可以引用三维模型来美化效果。

三个部分:inertial, visual, collision

分别表示惯性元素,视觉元素和碰撞元素

joint表示link之间的连接关系,可以转动revolute或者固定fixed

<?xml version="1.0"?>
<!-- 
This is the xacro description of a Pioneer 3DX, to be used in rviz and gazebo.
Copyright (C) 2013 Rafael Berkvens rafael.berkvens@uantwerpen.be

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

This project is based on work by Tracy Davies, where it was in turn based on
work original in ucs-ros-pkg.-->

<robot name="pxdx" xmlns:xacro="http://www.ros.org/wiki/xacro">

  <!-- import all gazebo-customization elements, including gazebo colors -->
  <xacro:include filename="pxdx.gazebo" />
  <!-- import the pioneer 3dx's wheels -->
  <xacro:include filename="pxdx_wheel.xacro" />

  <!-- chassis -->
	<link name="base_link">
		<inertial>
			<mass value="3.5" />
			<!--<origin xyz="-0.025 0 -0.223"/> -->
			<origin xyz="-0.05 0 0" />
			<inertia ixx="1" ixy="0" ixz="0" iyy="1" iyz="0" izz="1" />
		</inertial>

		<visual name="base_visual">
			<origin xyz="-0.045 0 0.145" rpy="0 0 0" />
			<geometry name="pioneer_geom">
				<box size="0.35 0.25 0.14" />
			</geometry>
			<material name="ChassisRed">
				<color rgba="0.851 0.0 0.0 1.0" />
			</material>
		</visual>

		<collision>
			<origin xyz="-0.045 0 0.145" rpy="0 0 0" />
			<geometry>
				<box size="0.35 0.25 0.14" />
			</geometry>
		</collision>
	</link>

  <!-- top_plate -->
	<link name="top_plate">
		<inertial>
			<mass value="0.01" />
			<origin xyz="0 0 0" />
			<inertia ixx="0.001" ixy="0" ixz="0" iyy="0.001" iyz="0" izz="0.001" />
		</inertial>

		<visual name="base_visual">
			<origin xyz="0 0 0" rpy="0 0 0" />
			<geometry name="top_geom">
				<box size="0.45 0.38 0.01" />
			</geometry>

			<material name="TopBlack">
				<color rgba="0.038 0.038 0.038 1.0" />
			</material>
		</visual>

		<collision>
			<origin xyz="0.0 0 0" rpy="0 0 0" />
			<geometry name="pioneer_geom">
				<box size="0.45 0.38 0.01" />
			</geometry>
		</collision>
	</link>

	<joint name="base_top_joint" type="fixed">
		<origin xyz="-0.045 0 0.234" rpy="0 0 0" />
		<parent link="base_link" />
		<child link="top_plate" />
	</joint>

  <!-- swivel -->
	<link name="swivel">
		<inertial>
			<mass value="0.1" />
			<origin xyz="0 0 0" />
			<inertia ixx="0.01" ixy="0" ixz="0" iyy="0.01" iyz="0" izz="0.01" />
		</inertial>

		<visual name="base_visual">
			<origin xyz="0 0 0" rpy="0 0 0" />
			<geometry name="pioneer_geom">
				<box size="0.01 0.01 0.01" />
			</geometry>
			<material name="swivel">
				<color rgba="0.5 0.5 0.5 1" />
			</material>
		</visual>

		<collision>
			<origin xyz="0 0 0" rpy="0 0 0" />
			<geometry>
				<box size="0.01 0.01 0.01" />
			</geometry>
		</collision>
	</link>

	<joint name="base_swivel_joint" type="continuous">
		<origin xyz="-0.185 0 0.055" rpy="0 0 0" />
		<axis xyz="0 0 1" />
		<anchor xyz="0 0 0" />
		<limit effort="100" velocity="100" k_velocity="0" />
		<joint_properties damping="0.0" friction="0.0" />
		<parent link="base_link" />
		<child link="swivel" />
	</joint>

  <!-- center_hubcap -->
	<link name="center_hubcap">
		<inertial>
			<mass value="0.01" />
			<origin xyz="0 0 0" />
			<inertia ixx="0.012411765597" ixy="-0.000711733678" ixz="0.00050272983"
				iyy="0.015218160428" iyz="-0.000004273467" izz="0.011763977943" />
		</inertial>

		<visual name="base_visual">
			<origin xyz="0 0 0" rpy="0 0 0" />
			<geometry name="pioneer_geom">
				<box size="0.01 0.01 0.01" />
			</geometry>
			<material name="swivel">
				<color rgba="0.5 0.5 0.5 1" />
			</material>
		</visual>

		<collision>
			<origin xyz="0 0 0" rpy="0 0 0" />
			<geometry>
				<box size="0.01 0.01 0.01" />
			</geometry>
		</collision>
	</link>

	<joint name="swivel_hubcap_joint" type="continuous">
		<origin xyz="-0.026 0 -0.016" rpy="0 0 0" />
		<axis xyz="0 1 0" />
		<anchor xyz="0 0 0" />
		<limit effort="100" velocity="100" k_velocity="0" />
		<joint_properties damping="0.0" friction="0.0" />
		<parent link="swivel" />
		<child link="center_wheel" />
	</joint>

  <!-- center_wheel -->
	<link name="center_wheel">
		<inertial>
			<mass value="0.1" />
			<origin xyz="0 0 0" />
			<inertia ixx="0.012411765597" ixy="-0.000711733678" ixz="0.00050272983"
				iyy="0.015218160428" iyz="-0.000004273467" izz="0.011763977943" />
		</inertial>

		<visual name="base_visual">
			<origin xyz="0 0 0" rpy="${-3.1415927/2.0} 0 0" />
			<geometry name="pioneer_geom">
				<cylinder radius="0.0375" length="0.01" />
			</geometry>
			<material name="WheelBlack">
				<color rgba="0.117 0.117 0.117 1" />
			</material>
		</visual>

		<collision>
			<origin xyz="0 0 0" rpy="${-3.1415927/2.0} 0 0" />
			<geometry>
				<cylinder radius="0.0375" length="0.01" />
			</geometry>
		</collision>
	</link>

	<joint name="center_wheel_joint" type="fixed">
		<origin xyz="-0.0035 0 -0.001" rpy="0 0 0"/>
		<parent link="center_wheel"/>
		<child link="center_hubcap"/>
	</joint>

	<xacro:p3dx_wheel suffix="left" parent="base_link" reflect="1"/>
	<xacro:p3dx_wheel suffix="right" parent="base_link" reflect="-1"/>
	
	<!-- lms100 laser -->
	<link name="lms100">
		<inertial>
			<mass value="1e-5" />
			<origin xyz="0 0 0" rpy="0 0 0" />
			<inertia ixx="1e-6" ixy="0" ixz="0" iyy="1e-6" iyz="0" izz="1e-6" />
		</inertial>

		<visual>
			<origin xyz="0 0 0" rpy="0 0 0" />
			<geometry>
				<box size="0.1 0.1 0.1" />   
			</geometry>
		</visual>

		<collision>
			<origin xyz="0 0 0" rpy="0 0 0" />
			<geometry>
				<box size="0.1 0.1 0.1" />
			</geometry>
		</collision>
	</link>

	<joint name="lms100_joint" type="fixed">
		<axis xyz="0 1 0" />
		<origin xyz="0.3 0 0.15" rpy="0 0 0" />
		<parent link="base_link" />
		<child link="lms100" />
	</joint>

</robot>

第二个文件:pxdx.gazebo
主要用于与gazebo相关的元素定义包括插件

<?xml version="1.0"?>

<!-- 
This is the gazebo urdf description of a Pioneer 3DX.
Copyright (C) 2013 Rafael Berkvens rafael.berkvens@uantwerpen.be

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
 -->
<robot xmlns:xacro="http://www.ros.org/wiki/xacro">
  <!-- properties (constants) -->
  <xacro:property name="ns" value="pxdx" />

  <!-- ros_control plugin -->
  <gazebo>
    <plugin name="gazebo_ros_control" filename="libgazebo_ros_control.so">
      <robotNamespace>/${ns}</robotNamespace>
    </plugin>
  </gazebo>

  <!-- base_link -->
	<gazebo reference="base_link">
		<material>Gazebo/Red</material>
	</gazebo>

  <!-- top_plate -->
  <gazebo reference="top_plate">
    <material>Gazebo/Black</material>
  </gazebo>
  
  <!-- swivel -->
  <gazebo reference="swivel">
    <material>Gazebo/Grey</material>
  </gazebo>
  
  <!-- center_hubcap -->
	<gazebo reference="center_hubcap">
		<material>Gazebo/Grey</material>
	</gazebo>
  
  <!-- center_wheel -->
	<gazebo reference="center_wheel">
		<material>Gazebo/Black</material>
		<mu1>10.0</mu1>
		<mu2>10.0</mu2>
		<kp>1000000.0</kp>
		<kd>1.0</kd>
	</gazebo>

  <!-- differential drive -->
	<gazebo>
		<plugin name="differential_drive_controller" filename="libgazebo_ros_diff_drive.so">
			<alwaysOn>true</alwaysOn>
            <legacyMode>0</legacyMode>
            <robotNamespace>/${ns}</robotNamespace>
			<updateRate>100</updateRate>
			<leftJoint>base_right_wheel_joint</leftJoint>
			<rightJoint>base_left_wheel_joint</rightJoint>
			<wheelSeparation>0.39</wheelSeparation>
			<wheelDiameter>0.15</wheelDiameter>
            <wheelAcceleration>1.0</wheelAcceleration>
			<wheelTorque>5</wheelTorque>
			<commandTopic>cmd_vel</commandTopic>
			<odometryTopic>odom</odometryTopic>
			<odometryFrame>base_footprint</odometryFrame>
			<robotBaseFrame>base_link</robotBaseFrame>
            <publishWheelTF>0</publishWheelTF>
            <publishOdom>1</publishOdom>
            <publishWheelJointState>0</publishWheelJointState>
		</plugin>
	</gazebo>

  <!-- ground truth -->
	<gazebo>
		<plugin name="p3d_base_controller" filename="libgazebo_ros_p3d.so">
			<alwaysOn>true</alwaysOn>
			<updateRate>50.0</updateRate>
			<bodyName>base_link</bodyName>
			<topicName>base_pose_ground_truth</topicName>
            <robotNamespace>/${ns}</robotNamespace>
			<gaussianNoise>0.01</gaussianNoise>
			<frameName>map</frameName>
			<!-- initialize odometry for fake localization -->
			<xyzOffsets>0 0 0</xyzOffsets>
			<rpyOffsets>0 0 0</rpyOffsets>
		</plugin>
	</gazebo>
	
	<!-- lms100 -->
	<gazebo reference="lms100">
		<sensor type="ray" name="head_hokuyo_sensor">
			<pose>0 0 0 0 0 0</pose>
			<visualize>false</visualize>
			<update_rate>50</update_rate>
			<ray>
				<scan>
					<horizontal>
						<samples>360</samples>
						<resolution>1</resolution>
						<min_angle>-1.57</min_angle>
						<max_angle>1.57</max_angle>
					</horizontal>
				</scan>
				<range>
					<min>0.10</min>
					<max>30.0</max>
					<resolution>0.01</resolution>
				</range>
				<noise>
					<type>gaussian</type>
					<!-- Noise parameters based on published spec for Hokuyo laser achieving 
						"+-30mm" accuracy at range < 10m. A mean of 0.0m and stddev of 0.01m will 
						put 99.7% of samples within 0.03m of the true reading. -->
					<mean>0.0</mean>
					<stddev>0.01</stddev>
				</noise>
			</ray>
			<plugin name="gazebo_ros_head_hokuyo_controller" filename="libgazebo_ros_laser.so">
				<topicName>laser_scan</topicName>
                <robotNamespace>/${ns}</robotNamespace>
				<frameName>lms100</frameName>
			</plugin>
		</sensor>
	</gazebo>
  <gazebo>
        <plugin name="joint_state_publisher" filename="libgazebo_ros_joint_state_publisher.so">
            <jointName>base_right_wheel_joint,base_left_wheel_joint,swivel_hubcap_joint,base_swivel_joint</jointName>
            <robotNamespace>/${ns}</robotNamespace>
        </plugin>
    </gazebo>
</robot>

重要插件:

joint_state_publisher发布关节状态

ros_laser生成点云

ros_diff控制运动

ros_p3d发布真实轨迹

ros_control连接控制器

第三个文件:pxdx_wheel.xacro

<?xml version="1.0"?>

<!-- 
This is the xacro description of a wheel of the Pioneer 3DX.
Copyright (C) 2013 Rafael Berkvens rafael.berkvens@uantwerpen.be

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

This project is based on work by Tracy Davies, where it was in turn based on
work original in ucs-ros-pkg.
 -->

<robot xmlns:xacro="http://www.ros.org/wiki/xacro">

	<!-- properties (constants) -->
	<xacro:property name="M_PI" value="3.14159" />

	<!-- right/left hubcap + wheel -->
	<xacro:macro name="p3dx_wheel" params="suffix parent reflect">
	
		<!-- wheel -->
		<link name="p3dx_${suffix}_wheel">
			<inertial>
				<mass value="0.5" />
				<origin xyz="0 0 0" />
				<inertia ixx="0.012411765597" ixy="0" ixz="0" iyy="0.015218160428"
					iyz="0" izz="0.011763977943" />
			</inertial>

			<visual name="base_visual">
				<origin xyz="0 0 0" rpy="${-3.1415927/2} 0 0" />
				<geometry name="pioneer_geom">
					<cylinder radius="0.09" length="0.01" />
				</geometry>
				<material name="WheelBlack">
					<color rgba="0.117 0.117 0.117 1" />
				</material>
			</visual>

			<collision>
				<origin xyz="0 0 0" rpy="${-3.1415927/2} 0 0" />
				<geometry>
					<!--<mesh filename="package://p3dx_description/meshes/${suffix}_wheel.stl"/> -->
					<cylinder radius="0.09" length="0.01" />
				</geometry>
			</collision>
		</link>

		<joint name="base_${suffix}_hubcap_joint" type="fixed">
			<origin xyz="0 0 0" rpy="0 0 0" />
			<parent link="p3dx_${suffix}_wheel" />
			<child link="p3dx_${suffix}_hubcap" />
		</joint>

		<!-- hubcap -->
		<link name="p3dx_${suffix}_hubcap">
			<inertial>
				<mass value="0.01" />
				<origin xyz="0 0 0" />
				<inertia ixx="0.012411765597" ixy="0" ixz="0" iyy="0.015218160428"
					iyz="0" izz="0.011763977943" />
			</inertial>

			<visual name="base_visual">
				<origin xyz="0 0 0" rpy="0 0 0" />
				<geometry name="pioneer_geom">
					<box size="0.01 0.01 0.01" />
				</geometry>

				<material name="HubcapYellow">
					<color rgba="1.0 0.811 0.151 1.0" />
				</material>
			</visual>

			<collision>
				<origin xyz="0 0 0" rpy="0 0 0" />
				<geometry>
					<box size="0.01 0.01 0.01" />
				</geometry>
			</collision>
		</link>

		<joint name="base_${suffix}_wheel_joint" type="continuous">
			<axis xyz="0 1 0" />
			<anchor xyz="0 0 0" />
			<limit effort="100" velocity="100" />
			<joint_properties damping="0.0" friction="0.0" />
			<origin xyz="0 ${reflect*0.158} 0.091" rpy="0 0 0" />
			<parent link="base_link" />
			<child link="p3dx_${suffix}_wheel" />
		</joint>
		
		<!-- gazebo elements -->

    <transmission name="${parent}_${suffix}_wheel_trans">
      <type>transmission_interface/SimpleTransmission</type>
      <joint name="base_${suffix}_wheel_joint">
        <hardwareInterface>EffortJointInterface</hardwareInterface>
      </joint>
      <actuator name="base_${suffix}_wheel_motor">
        <hardwareInterface>EffortJointInterface</hardwareInterface>
        <mechanicalReduction>${reflect * 624/35 * 80/19}</mechanicalReduction>
      </actuator>
    </transmission>

		<gazebo reference="p3dx_${suffix}_hubcap">
			<material>Gazebo/Yellow</material>
		</gazebo>

		<gazebo reference="p3dx_${suffix}_wheel">
			<material>Gazebo/Black</material>
			<mu1>0.5</mu1>
			<mu2>50.0</mu2>
			<kp>100000000.0</kp>
			<kd>1.0</kd>
		</gazebo>

	</xacro:macro>

</robot>

注意transmission中主要定义了虚拟接口,用于连接控制

然后可以使用launch文件启动

<launch>
  <arg name="paused" default="false"/>
  <arg name="use_sim_time" default="true"/>
  <arg name="gui" default="true"/>
  <arg name="headless" default="false"/>
  <arg name="debug" default="false"/>
<!-- We resume the logic in empty_world.launch, changing only the name of the world to be launched -->
  <include file="$(find gazebo_ros)/launch/empty_world.launch">
    <arg name="debug" value="$(arg debug)" />
    <arg name="gui" value="$(arg gui)" />
    <arg name="paused" value="$(arg paused)"/>
    <arg name="use_sim_time" value="$(arg use_sim_time)"/>
    <arg name="headless" value="$(arg headless)"/>
  </include>
  <!-- Load joint controller configurations from YAML file to parameter server -->
  <rosparam file="pxdx.yaml" command="load"/>
  <param name="robot_description" command="$(find xacro)/xacro 'pxdx.xacro'"/>
  <!-- load the controllers -->
  <node name="controller_spawner" pkg="controller_manager" type="spawner" respawn="false"
   ns="pxdx/" output="screen" args="--stopped 
    joint1_position_controller 
    joint2_position_controller 
    joint_state_controller"/>
<!-- push robot_description to factory and spawn robot in gazebo -->
  <node name="urdf_spawner" pkg="gazebo_ros" type="spawn_model"
        args="-z 1.0 -unpause -urdf -model pxdx -param robot_description" respawn="false" output="screen" >
    </node>
  <!-- convert joint states to TF transforms for rviz, etc -->
  <node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher"
    respawn="false" output="screen">
    <remap from="/joint_states" to="/pxdx/joint_states" />
    <param name="tf_prefix" value="pxdx"/>
  </node>

</launch>

rviz启动后

设置fixed frame = pxdx/base_footprint

添加机器人模型和odom及laser_scan

保存config文件后可通过

rosrun rviz rviz -d pxdx.rviz
roslaunch pxdx.launch
#通过twist键盘控制运动
rosrun teleop_twist_keyboard teleop_twist_keyboard.py /cmd_vel:=/pxdx/cmd_vel

不完美的地方将就看吧。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

ROS学习之利用xacro/URDF模型搭建及rviz和gazebo仿真 的相关文章

  • 就分页分段内存而言的程序寿命

    我对 x86 Linux 机器中的分段和分页过程有一个令人困惑的概念 如果有人能澄清从开始到结束所涉及的所有步骤 我们将很高兴 x86 使用分页分段内存技术进行内存管理 任何人都可以解释一下从可执行的 elf 格式文件从硬盘加载到主内存到它
  • 无需超级用户即可在 Linux 中打开 RAW 套接字

    我必须编写一个在 Linux 上运行的 ping 函数 语言是 C 所以 C 也可以 在网上搜索并查看源代码ping命令 事实证明我应该创建一个原始套接字 icmp sock socket AF INET SOCK RAW IPPROTO
  • 尽管 if 语句,Visual Studio 仍尝试包含 Linux 标头

    我正在尝试创建一个强大的头文件 无需更改即可在 Windows 和 Linux 上进行编译 为此 我的包含内容中有一个 if 语句 如下所示 if defined WINDOWS include
  • 如何根据标签将单个 XML 文件拆分为多个

    我有一个带有标签的 XML 文件 我想像这样分割文件
  • 并行运行 shell 脚本

    我有一个 shell 脚本 打乱大型文本文件 600 万行和 6 列 根据第一列对文件进行排序 输出 1000 个文件 所以伪代码看起来像这样 file1 sh bin bash for i in seq 1 1000 do Generat
  • 如何让R使用所有处理器?

    我有一台运行 Windows XP 的四核笔记本电脑 但查看任务管理器 R 似乎一次只使用一个处理器 如何让 R 使用全部四个处理器并加速我的 R 程序 我有一个基本系统 我使用它在 for 循环上并行化我的程序 一旦您了解需要做什么 此方
  • 在 Mono 上运行 .Net MVC5 应用程序

    我正在 Windows 上的 Visual Studio 2013 中开发 Net 4 5 1 MVC5 应用程序 现在我想知道 是否可以在Linux Ubuntu 12 04 上运行这个应用程序 可以使用OWIN吗 Owin 可以自托管运
  • 使用包管理器时如何管理 Perl 模块?

    A 最近的问题 https stackoverflow com questions 397817 unable to find perl modules in intrepid ibex ubuntu这让我开始思考 在我尝试过的大多数 Li
  • C修改printf()输出到文件

    有没有办法修改printf为了将字符串输出到文件而不是控制台 我尝试在互联网上查找一些内容 发现了类似的电话dup dup2 and fflush这可能与此有关 EDIT 也许我不清楚 问题是这是C考试问题 问题如下 解释一个通常将字符串输
  • 使用 python 脚本更改 shell 中的工作目录

    我想实现一个用户态命令 它将采用其参数之一 路径 并将目录更改为该目录 程序完成后 我希望 shell 位于该目录中 所以我想实施cd命令 但需要外部程序 可以在 python 脚本中完成还是我必须编写 bash 包装器 Example t
  • 错误:“rjags”的包或命名空间加载失败

    在终端的 conda 环境之一中 我能够成功安装包 rjags 但是 当我在该环境中运行 R 并运行库 rjags 时 出现以下错误 加载所需的包 coda 错误 rjags 的包或命名空间加载失败 rjags 的 loadNamespac
  • 如何在 *nix 中登录时运行脚本?

    我知道我曾经知道如何做到这一点 但是 如何在 unix 中登录时运行脚本 bash 可以 From 维基百科 Bash http en wikipedia org wiki Bash 28Unix shell 29 当 Bash 启动时 它
  • 为什么同一个curl命令在windows和linux下输出不同的东西?

    为什么同样的curl o file https www link com 命令输出不同的东西 例如 如果我运行命令curl o source txt https www youtube com playlist list PLIx6Fwnp
  • 使用自定义堆的类似 malloc 的函数

    如果我希望使用自定义预分配堆构造类似 malloc 的功能 那么 C 中最好的方法是什么 我的具体问题是 我有一个可映射 类似内存 的设备 已将其放入我的地址空间中 但我需要获得一种更灵活的方式来使用该内存来存储将随着时间的推移分配和释放的
  • 在运行时检查 GCC 版本

    我需要找出 C 程序执行过程中 运行时 可用的 系统中安装的 GCC 版本 主要版本和次要版本 意思是 以编程方式提取可用 gcc 的版本 就像我在 shell 中输入 gcc version 一样 但在 c 程序中 The GNUC an
  • 跨 CPU 内核的 rdtsc 精度

    我从一个线程发送网络数据包 并在运行于不同 CPU 核心上的第二个线程上接收回复 我的流程测量每个数据包发送和接收之间的时间 类似于 ping 我使用 rdtsc 来获得高分辨率 低开销的计时 这是我的实现所需要的 所有测量结果看起来都很可
  • Ubuntu 的打包 - Web 应用程序

    Web 应用程序没有与 C 或类似文件不同的 make 文件 但是 它需要放置在特定的目录中 例如 var www 我是 Linux 打包新手 所以我的问题是 如何将我的应用程序打包到 deb 中 以便在安装时将其放入 etc myprog
  • 如何在Linux中自动启动需要X的应用程序

    我试图在系统进入运行级别 5 时自动启动 X 应用程序 这样做的正确方法是什么 我写了一个脚本并将其放在 etc init d 中 我已运行适当的 chkconfig 命令来设置 etc rcX d 目录中的符号链接 一切工作正常 除了当我
  • 从另一个 python 脚本获取返回信息

    我在 Linux 上 我有一个 python 脚本 我想从另一个 python 脚本调用它 我不想将其作为模块导入 为了一层安全性 现在为了学术练习 因为我想弄清楚这一点 我实际上想让一个脚本使用 os system 或另一个类似的函数 并
  • 在 C 中运行 setuid 程序的正确方法

    我有一个权限为4750的进程 我的Linux系统中存在两个用户 root 用户和 appz 用户 该进程继承以 appz 用户身份运行的进程管理器的权限 我有两个基本惯例 void do root void int status statu

随机推荐

  • 科技,让二次元老婆动起来

    想让你的二次元老婆动起来吗 前不久 Meta 也就是Facebook 发布了一款有趣的AI工具Animated Drawings 它可以让静态的儿童画动起来 有些懂行的朋友一看就说 哎呀这不就是关键点检测再加动态化嘛 道理是这个道理 但是儿
  • MYSQl:关于AUTO_INCREMENT

    auto increment是用于主键自动增长的 从1开始增长 当你把第一条记录删除时 再插入第二条数据时 主键值是2 不是1 问题来源 拷贝了公司项目的regions表 发现建表的sql语句如下 CREATE TABLE es regio
  • 两数求最大值 和 交换两个数字

    两数求最大值 include
  • 将图片进行base64 编码后的数据进行读取,以io流的方式传给前台并显示出来并且不断刷新图片

    前提摘要 最近做一个项目 是关于slam的 给slam发送构建地图的命令 slam不断返回json串 而地图的图片在json串中已经经过base64编码了 我这边需要将base64编码解析并以流的方式传给前台显示出来 但是消息是不断要接收的
  • 支付结算周期:D0 D1 T0 T1的区别

    D0 自然日当天 D1 自然日第二天 T0 工作日当天 T1 工作日第二天 D0和T0的区别 比如说 星期六做的交易 D0因为是自然日当天 所以周六即可到账 T0因为是工作日当天 所以下周一可到账
  • 在Windows10下配置深度学习环境(tensorflow-gpu + CUDA & CUDNN),十分详细,推荐小白食用

    在Windows10下配置深度学习环境 tensorflow gpu CUDA CUDNN 本文的基础建立在DUT汽院515教研室的师兄的教程之上 由本人总结更新 希望能帮到更多人 十分感谢师兄们的付出 CUDA的配置 请参考本人的另一篇文
  • 基于LSTM的情感识别在鹅漫评论分析中的实践与应用

    深度学习 深度神经网络 作为机器学习的一个重要分支 持续推动了很多领域的研究和应用取得新的进展 其中包括文本处理领域的情感分类问题 由于可以对文本进行更有效的编码及表达 基于深度学习的情感分类对比传统的浅层机器学习和统计学方法 可以取得更高
  • C++ public、protected 、 private使用详解

    1 类私有成员变量的访问 必须调用类成员函数来进行访问 对于protected成员 继承他的类可以直接在成员函数中调用 而对于私有成员 继承他的类要使用他们的值必须使用基类的成员函数 2 protected成员 基类对象不能调用自身prot
  • ajax中data参数json对象与json字符串的使用区别

    在jquery的ajax里面有个data参数 是客户的传给服务端的数据 我们先看第一种常见写法 前端代码 var username phone email num val var pwd password val ajax url logi
  • GDB 调试工具的使用和交叉编译安装

    作用 1 可以让我们的代码单步运行 并且可以打印出运行时各种变量的值 2 还可以调试各种 core 核心 文件 在启动 gdb 调试程序的时候 我们需要使用到 gcc g 命令指定 g 参数生成可执行调试程序 例如 g g main cpp
  • Proxy代理isExtensible方法

    介绍 isExtensible方法拦截Onject isExtensible操作 demo1 var p new Proxy isExtensible function target console log called return tr
  • redis 事务实现原理

    一 简介 Redis事务通常会使用MULTI EXEC WATCH等命令来完成 redis实现事务实现的机制与常见的关系型数据库有很大的却别 比如redis的事务不支持回滚 事务执行时会阻塞其它客户端的请求执行 二 事务实现细节 redis
  • 【电动车】基于多目标优化遗传算法NSGAII的峰谷分时电价引导下的电动汽车充电负荷优化研究(Matlab代码实现)

    欢迎来到本博客 博主优势 博客内容尽量做到思维缜密 逻辑清晰 为了方便读者 座右铭 行百里者 半于九十 本文目录如下 目录 1 概述 2 运行结果 3 文献来源 4 Matlab代码实现 1 概述 文献来源 摘要 在研究电动汽车用户充电需求
  • Ajax的介绍及应用,XMLHttpRequest对象

    AJAX介绍 AJAX全称 Asynchronous JavaScript and XML 异步的 JavaScript 和 XML JS是同步执行的 从上往下依次执行 如果遇到请求将会等待服务器的响应 AJAX是用来 异步 和服务器交互的
  • 转骰子

    转骰子 题目描述 骰子是一个立方体 每个面一个数字 初始为左 1 右 2 前 3 观察者方向 后 4 上 5 下 6 用 123456 表示这个状态 放置到平面上 可以向左翻转 用 L表示向左翻转 1 次 可以向右翻转 用 R 表示 向右翻
  • 利用Python采集某站上的所有陪玩妹子信息!听说现在做陪玩的都非常漂亮?

    前言 我想应该很多男生都是会打游戏的吧 女生就手机游戏 王者 刺激战场这些应该多些 男生应该就是英雄联盟 穿越火线 绝地求生等等一系列的游戏吧 那么你知道陪玩是什么时候就冒出来的新职业吗 知道的话可以告诉我一下哦 今天咱们的主要目的还是玩爬
  • Docker容器网络更改

    1 添加自定义网络 默认是桥接模式 docker network create 网络名称 2 解除容器绑定的网络 docker network disconnect 网络名称 容器名称 3 为容器重新指定网络 docker network
  • 《数据结构、算法与应用C++语言描述》使用C++语言实现二维数组稀疏矩阵

    数据结构 算法与应用C 语言描述 使用C 语言实现二维数组稀疏矩阵 稀疏矩阵定义 一个mxn 的矩阵 如果大多数元素都是0 则称为稀疏矩阵 spare matrix 一个矩阵如果不是稀疏的 就称为稠密矩阵 dense matrix 在稀疏矩
  • 如何设计一个分布式系统去分析3亿条数据?

    V xin ruyuanhadeng获得600 页原创精品文章汇总PDF 目录 从一个新闻门户网站案例引入 推算一下你需要分析多少条数据 黄金搭档 分布式存储 分布式计算 这篇文章聊一个话题 什么是分布式计算系统 一 从一个新闻门户网站案例
  • ROS学习之利用xacro/URDF模型搭建及rviz和gazebo仿真

    建议好好研究一下P3DX中的代码 非常有借鉴意义 xacro非常重要的作用是利用类似宏的方式 利用参数化来快速搭建模型 A ROS Gazebo Pioneer 3DX model created by Rafael Berkvens mo