MTC完成右臂抓取放置任务\\放置姿态设置

MT

#include "mtc_tutorial/mtc_glass_bottle.hpp"
static const rclcpp::Logger LOGGER = rclcpp::get_logger("mtc_glass_right"); // 获取节点基础接口的实现
rclcpp::node_interfaces::NodeBaseInterface::SharedPtr MTCTaskNode_Right::getNodeBaseInterface()
{return node_->get_node_base_interface();
}// 构造函数的实现,创建节点对象
MTCTaskNode_Right::MTCTaskNode_Right(const rclcpp::NodeOptions& options): node_{ std::make_shared<rclcpp::Node>("mtc_right_node", options) }  // 初始化节点名称为 "mtc_node"
{
}// 设置规划场景的实现
void MTCTaskNode_Right::setupPlanningScene()
{const double table_height = 1.02;std::string frame_id = "world";geometry_msgs::msg::PoseStamped bottlePose;bottlePose.header.frame_id = frame_id;bottlePose.pose.position.x = 0.3;bottlePose.pose.position.y = -0.5;bottlePose.pose.position.z = table_height;bottlePose.pose.orientation.w = 1.0;geometry_msgs::msg::PoseStamped glassPose;glassPose.header.frame_id = frame_id;glassPose.pose.position.x = -0.6;glassPose.pose.position.y = -0.5;glassPose.pose.position.z = table_height;glassPose.pose.orientation.w = 1.0;// center of table surface geometry_msgs::msg::PoseStamped tabletopPose;tabletopPose.header.frame_id = frame_id;tabletopPose.pose.position.x = 0;tabletopPose.pose.position.y = -0.25;tabletopPose.pose.position.z = table_height;tabletopPose.pose.orientation.w = 1.0;// 创建规划场景接口并将碰撞对象添加到场景中mtc_pour::cleanup();moveit::planning_interface::PlanningSceneInterface psi;std::vector<moveit_msgs::msg::CollisionObject> objs;mtc_pour::setupTable(objs, tabletopPose);mtc_pour::setupObjects(objs, bottlePose, glassPose,"package://mtc_pour/meshes/small_bottle.stl");psi.applyCollisionObjects(objs);
}// 执行任务的实现
void MTCTaskNode_Right::doTask()
{task_ = createTask();  // 创建任务// 尝试初始化任务try{task_.init();  // 初始化任务}catch (mtc::InitStageException& e)  // 捕获初始化失败的异常{RCLCPP_ERROR_STREAM(LOGGER, e);  // 打印错误信息return;}// 规划任务路径,最大规划尝试次数为 5if (!task_.plan(10)){RCLCPP_ERROR_STREAM(LOGGER, "Task planning failed");  // 打印任务规划失败的日志return;}// 发布任务解决方案以供检查task_.introspection().publishSolution(*task_.solutions().front());// 执行规划的解决方案auto result = task_.execute(*task_.solutions().front());if (result.val != moveit_msgs::msg::MoveItErrorCodes::SUCCESS){RCLCPP_ERROR_STREAM(LOGGER, "Task execution failed");  // 执行失败的错误日志return;}return;
}// 创建任务的实现
mtc::Task MTCTaskNode_Right::createTask()
{mtc::Task task;  // 创建一个 MTC 任务对象task.stages()->setName("grabbing the glass on the right");  // 为任务命名task.loadRobotModel(node_);  // 加载机器人模型// 定义机器人操作相关的参数// const auto& left_arm_group_name = "left_ur_manipulator";  // 机械臂的操作组名称// const auto& left_hand_group_name = "left_robotiq_2f_85_gripper";  // 手部操作组名称// const auto& left_hand_frame = "left_robotiq_85_base_link";  // 机械手的坐标系const auto& right_arm_group_name = "right_ur_manipulator";  // 机械臂的操作组名称const auto& right_hand_group_name = "right_robotiq_2f_85_gripper";  // 手部操作组名称const auto& right_hand_frame = "right_grasp_point";  // 机械手的坐标系// 设置任务的属性task.setProperty("group", right_arm_group_name);task.setProperty("eef", "right_robotiq_2f_85_gripper_ee");task.setProperty("ik_frame", right_hand_frame);// 忽略未使用变量的编译器警告
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-but-set-variable"mtc::Stage* current_state_ptr = nullptr;  // 将current_stage传递给grasp pose generator
#pragma GCC diagnostic pop// 创建并添加获取当前状态的阶段auto stage_state_current = std::make_unique<mtc::stages::CurrentState>("right-current");current_state_ptr = stage_state_current.get();task.add(std::move(stage_state_current));  // 添加当前状态阶段到任务中// 创建不同的规划器auto sampling_planner = std::make_shared<mtc::solvers::PipelinePlanner>(node_);  // 创建采样规划器auto interpolation_planner = std::make_shared<mtc::solvers::JointInterpolationPlanner>();  // 创建插值规划器// 创建笛卡尔路径规划器,并设置最大速度和加速度auto cartesian_planner = std::make_shared<mtc::solvers::CartesianPath>();cartesian_planner->setMaxVelocityScalingFactor(1.0);  // 设置最大速度缩放因子为 1.0cartesian_planner->setMaxAccelerationScalingFactor(1.0);  // 设置最大加速度缩放因子为 1.0cartesian_planner->setStepSize(.01);  // 设置步长为 0.01// 创建并添加手部动作的阶段(打开手)auto stage_open_right_hand =std::make_unique<mtc::stages::MoveTo>("open right_hand", interpolation_planner);  // 创建移动到目标状态的阶段stage_open_right_hand->setGroup(right_hand_group_name);  // 设置操作组为手部stage_open_right_hand->setGoal("right_open");  // 设置手部打开的目标状态task.add(std::move(stage_open_right_hand));  // 将阶段添加到任务中// Add the next lines of codes to define more stages hereauto stage_move_to_pick_right = std::make_unique<mtc::stages::Connect>("move to pick-right",mtc::stages::Connect::GroupPlannerVector{{right_arm_group_name,sampling_planner}});stage_move_to_pick_right->setTimeout(5.0);stage_move_to_pick_right->properties().configureInitFrom(mtc::Stage::PARENT);task.add(std::move(stage_move_to_pick_right));mtc::Stage* attach_object_stage_right = nullptr;// Forward attach_object_stage  to place pose generator{auto grasp_right = std::make_unique<mtc::SerialContainer>("pick glass-right");task.properties().exposeTo(grasp_right->properties(),{"eef","group","ik_frame"});grasp_right->properties().configureInitFrom(mtc::Stage::PARENT,{"eef","group","ik_frame"});{auto stage = std::make_unique<mtc::stages::MoveRelative>("approach glass-right",cartesian_planner);stage->properties().set("marker_ns","approach_glass-right");stage->properties().set("link",right_hand_frame);// TODO:猜测这是与物体发生接触的linkstage->properties().configureInitFrom(mtc::Stage::PARENT,{"group"});stage->setMinMaxDistance(0.05,0.15);// Set hand forward directiongeometry_msgs::msg::Vector3Stamped vec;vec.header.frame_id = right_hand_frame;vec.vector.z =1.0;stage->setDirection(vec);grasp_right->insert(std::move(stage));}{//Sample grasp poseauto stage = std::make_unique<mtc::stages::GenerateGraspPose>("generate grasp pose -right");stage->properties().configureInitFrom(mtc::Stage::PARENT);stage->properties().set("marker_ns","grasp_pose-right");stage->setPreGraspPose("right_open");stage->setObject("glass");stage->setAngleDelta(M_PI / 12);stage->setMonitoredStage(current_state_ptr);//Hook into current stateEigen::Isometry3d grasp_frame_transform_right;//末端执行器坐标系的Z轴朝向杯子的X轴,末端执行器坐标系的X轴朝向杯子的Y轴,末端执行器坐标系的Y轴朝向杯子的Z轴Eigen::Quaterniond q = Eigen:: AngleAxisd(-M_PI/2,Eigen::Vector3d::UnitY())*Eigen::AngleAxisd(-M_PI/2,Eigen::Vector3d::UnitX());// //末端执行器坐标系的Y轴朝向杯子的X轴,末端执行器坐标系的X轴朝向杯子的Y轴,末端执行器坐标系的Z轴朝向杯子的-Z轴// Eigen::Quaterniond q = Eigen:: AngleAxisd(M_PI/2,Eigen::Vector3d::UnitZ())*//                       Eigen::AngleAxisd(-M_PI,Eigen::Vector3d::UnitX());grasp_frame_transform_right.linear() = q.matrix();grasp_frame_transform_right.translation().z()=0;// Compute IK// 将stage对象的所有权转移给wrapper_right// wrapper 通常指的是一层封装,用于将某个功能或一组功能封装起来,auto wrapper = std::make_unique<mtc::stages::ComputeIK>("grasp pose IK - right",std::move(stage));wrapper->setMaxIKSolutions(8);wrapper->setMinSolutionDistance(1.0);wrapper->setIKFrame(grasp_frame_transform_right,right_hand_frame);wrapper->properties().configureInitFrom(mtc::Stage::PARENT,{"eef","group"});wrapper->properties().configureInitFrom(mtc::Stage::INTERFACE,{"target_pose"});grasp_right->insert(std::move(wrapper));}{auto stage = std::make_unique<mtc::stages::ModifyPlanningScene>("allow collision (hand,object) - right");stage->allowCollisions("glass",task.getRobotModel()->getJointModelGroup(right_hand_group_name)->getLinkModelNamesWithCollisionGeometry(),true);grasp_right->insert(std::move(stage));}{auto stage = std::make_unique<mtc::stages::MoveTo>("close hand-right",interpolation_planner);stage->setGroup(right_hand_group_name);stage->setGoal("right_close");grasp_right->insert(std::move(stage));}{auto stage = std::make_unique<mtc::stages::ModifyPlanningScene>("attcah object - right");stage->attachObject("glass",right_hand_frame);attach_object_stage_right = stage.get();grasp_right->insert(std::move(stage));}{auto stage = std::make_unique<mtc::stages::MoveRelative>("lift object - right",cartesian_planner);stage->properties().configureInitFrom(mtc::Stage::PARENT,{"group"});stage->setMinMaxDistance(0.1,0.3);stage->setIKFrame(right_hand_frame);stage->properties().set("marker_ns","lift_object_right");// Set upward directiongeometry_msgs::msg::Vector3Stamped vec;vec.header.frame_id = "dual_base";vec.vector.y = 1.0;stage->setDirection(vec);grasp_right->insert(std::move(stage));}task.add(std::move(grasp_right));  }{auto stage_move_to_place_right = std::make_unique<mtc::stages::Connect>("move to place -right",mtc::stages::Connect::GroupPlannerVector{{right_arm_group_name,sampling_planner},{right_hand_group_name,sampling_planner} });stage_move_to_place_right->setTimeout(5.0);stage_move_to_place_right->properties().configureInitFrom(mtc::Stage::PARENT);task.add(std::move(stage_move_to_place_right));}{auto place_right = std::make_unique<mtc::SerialContainer>("place object -right");task.properties().exposeTo(place_right->properties(),{"eef","group","ik_frame"});place_right->properties().configureInitFrom(mtc::Stage::PARENT,{"eef","group","ik_frame"});// {//   //Sample place pose//   auto stage = std::make_unique<mtc::stages::GeneratePlacePose>("generate place pose");//   stage->properties().configureInitFrom(mtc::Stage::PARENT);//   stage->properties().set("marker_ns","place_pose_right");//   stage->setObject("glass");//   geometry_msgs::msg::PoseStamped target_pose_msg_right;//   target_pose_msg_right.header.frame_id = "dual_base";//   target_pose_msg_right.pose.position.x = -0.5;//   target_pose_msg_right.pose.position.y = -0.5;//   target_pose_msg_right.pose.position.z = 0.55;//   tf2::Quaternion qtn;//   qtn.setRPY(0.0,0.0,-1.57);//   target_pose_msg_right.pose.orientation.x = qtn.x();//   target_pose_msg_right.pose.orientation.y = qtn.y();//   target_pose_msg_right.pose.orientation.z = qtn.z();//   target_pose_msg_right.pose.orientation.w = qtn.w();//   stage->setPose(target_pose_msg_right);//   stage->setMonitoredStage(attach_object_stage_right); //Hook into attach_object_stage//   // Compute IK//   auto wrapper = std::make_unique<mtc::stages::ComputeIK>("place pose IK",std::move(stage));//   wrapper->setMaxIKSolutions(2);//   wrapper->setMinSolutionDistance(1.0);//   wrapper->setIKFrame("glass");//   wrapper->properties().configureInitFrom(mtc::Stage::PARENT,{"eef","group"});//   wrapper->properties().configureInitFrom(mtc::Stage::INTERFACE,{"target_pose"});//   place_right->insert(std::move(wrapper));//  }//  {//     //Sample place pose//     auto stage = std::make_unique<mtc::stages::GeneratePlacePose>("generate place pose -right");//     stage->properties().configureInitFrom(mtc::Stage::PARENT);//     stage->properties().set("marker_ns","place_pose_right");//     stage->setObject("glass");//     // 定义放置位姿//     geometry_msgs::msg::PoseStamped target_pose_msg_right;//     target_pose_msg_right.header.frame_id = "dual_base";//     target_pose_msg_right.pose.position.x = -0.5;//     target_pose_msg_right.pose.position.y = 0.5;//     target_pose_msg_right.pose.position.z = 0.2;//     tf2::Quaternion qtn;//     qtn.setRPY(0.0, 0.0, -M_PI );  // 将RPY角度转换成四元数//     target_pose_msg_right.pose.orientation.x = qtn.x();//     target_pose_msg_right.pose.orientation.y = qtn.y();//     target_pose_msg_right.pose.orientation.z = qtn.z();//     target_pose_msg_right.pose.orientation.w = qtn.w();//     stage->setPose(target_pose_msg_right);//     stage->setMonitoredStage(attach_object_stage_right); //Hook into attach_object_stage//     // 定义放置时的末端执行器坐标系变换//     Eigen::Isometry3d place_frame_transform_right;//     Eigen::Quaterniond q = Eigen::AngleAxisd(-M_PI / 2, Eigen::Vector3d::UnitY()) *//                           Eigen::AngleAxisd(-M_PI / 2, Eigen::Vector3d::UnitX());//     place_frame_transform_right.linear() = q.matrix();//     place_frame_transform_right.translation().z() = 0;//     // 计算IK//     auto wrapper = std::make_unique<mtc::stages::ComputeIK>("place pose IK - right", std::move(stage));//     wrapper->setMaxIKSolutions(8); // 设置最大解的数量//     wrapper->setMinSolutionDistance(1.0);//     wrapper->setIKFrame(place_frame_transform_right, right_hand_frame);//     wrapper->properties().configureInitFrom(mtc::Stage::PARENT, {"eef", "group"});//     wrapper->properties().configureInitFrom(mtc::Stage::INTERFACE, {"target_pose"});//     place_right->insert(std::move(wrapper));// }{// Sample place poseauto stage = std::make_unique<mtc::stages::GeneratePlacePose>("generate place pose -right");stage->properties().configureInitFrom(mtc::Stage::PARENT);stage->properties().set("marker_ns", "place_pose_right");stage->setObject("glass");// 定义放置位姿geometry_msgs::msg::PoseStamped target_pose_msg_right;target_pose_msg_right.header.frame_id = "dual_base";target_pose_msg_right.pose.position.x = -0.3;target_pose_msg_right.pose.position.y = -0.5;target_pose_msg_right.pose.position.z = 0.3;// 计算放置位姿的正确姿态Eigen::Quaterniond q_place = Eigen::AngleAxisd(-M_PI / 2, Eigen::Vector3d::UnitZ())*Eigen::AngleAxisd(0, Eigen::Vector3d::UnitX());Eigen::Quaterniond q_object = q_place.inverse();tf2::Quaternion qtn(q_object.x(), q_object.y(), q_object.z(), q_object.w());target_pose_msg_right.pose.orientation = tf2::toMsg(qtn);stage->setPose(target_pose_msg_right);stage->setMonitoredStage(attach_object_stage_right); // Hook into attach_object_stage// 设置 IK 框架,与抓取阶段一致Eigen::Isometry3d place_frame_transform_right;place_frame_transform_right.linear() = q_place.toRotationMatrix();place_frame_transform_right.translation().z() = 0;// 计算 IKauto wrapper = std::make_unique<mtc::stages::ComputeIK>("place pose IK - right", std::move(stage));wrapper->setMaxIKSolutions(8); // 设置最大解的数量wrapper->setMinSolutionDistance(1.0);wrapper->setIKFrame(place_frame_transform_right, right_hand_frame);wrapper->properties().configureInitFrom(mtc::Stage::PARENT, { "eef", "group" });wrapper->properties().configureInitFrom(mtc::Stage::INTERFACE, { "target_pose" });place_right->insert(std::move(wrapper));}{auto stage = std::make_unique<mtc::stages::MoveTo>("open hand-right",interpolation_planner);stage->setGroup(right_hand_group_name);stage->setGoal("right_open");place_right->insert(std::move(stage));}{auto stage = std::make_unique<mtc::stages::ModifyPlanningScene>("forbid collision (hand,object)-right");stage->allowCollisions("glass",task.getRobotModel()->getJointModelGroup(right_hand_group_name)->getLinkModelNamesWithCollisionGeometry(),false);place_right->insert(std::move(stage));}{auto stage = std::make_unique<mtc::stages::ModifyPlanningScene>("detach object-right");stage->detachObject("glass",right_hand_frame);place_right->insert(std::move(stage));}{auto stage = std::make_unique<mtc::stages::MoveRelative>("retreat -right",cartesian_planner);stage->properties().configureInitFrom(mtc::Stage::PARENT,{"group"});stage->setMinMaxDistance(0.1,0.3);stage->setIKFrame(right_hand_frame);stage->properties().set("marker_ns","retreat-right");// Set retreat directiongeometry_msgs::msg::Vector3Stamped vec;vec.header.frame_id = "world";vec.vector.z=0.5;stage->setDirection(vec);place_right->insert(std::move(stage));}task.add(std::move(place_right));}{auto stage = std::make_unique<mtc::stages::MoveTo>("return home -right",interpolation_planner);stage->properties().configureInitFrom(mtc::Stage::PARENT,{"group"});stage->setGoal("right_home");task.add(std::move(stage));}// Stages all added to the task above this linereturn task;  // 返回创建的任务
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.xdnf.cn/news/1537260.html

如若内容造成侵权/违法违规/事实不符,请联系一条长河网进行投诉反馈,一经查实,立即删除!

相关文章

棋盘格角点检测-libcbdetect

libcbdetect libcbdetect 是一个用于自动子像素级别的棋盘格&#xff08;checkerboard&#xff09;、棋盘&#xff08;chessboard&#xff09;以及 Deltille 图案检测的库。它主要由 C 编写&#xff0c;旨在提供高精度、高鲁棒性的角点检测和图案组合功能&#xff0c;是一种基…

使用HTML和CSS制作网页的全面指南

目录 引言 一、理解HTML 1. 什么是HTML&#xff1f; 2. HTML文档的基本结构 3. 常用的HTML标签 4. 示例&#xff1a;创建一个简单的HTML页面 二、理解CSS 1. 什么是CSS&#xff1f; 2. CSS的使用方式 3. CSS选择器和属性 4. 常用的CSS属性 三、创建网页的步骤 1. 规…

【Java数据结构】二叉树

目录 树树的特征树的概念 二叉树两种特殊的二叉树二叉树的性质二叉树的基本操作4 种遍历二叉树的方式判断一棵树是不是完全二叉树获取二叉树总共的节点个数获取叶子节点的个数获取第 k 层的节点个数获取二叉树的高度检测值为 value 的元素是否存在 二叉树基本操作完整代码 树 …

VS code 安装使用配置 Continue

Continue 插件介绍 Continue 是一款高效的 VS Code 插件&#xff0c;提供类似 GitHub Copilot 的功能&#xff0c;旨在提升开发者的编程效率。其配置简单&#xff0c;使用体验流畅&#xff0c;深受开发者喜爱。 主要功能特点 智能代码补全 Continue 能够基于当前代码上下文生…

年化60.7%,最大回撤-16.5%,RSRS标准分择时效果差不多

原创内容第653篇&#xff0c;专注量化投资、个人成长与财富自由。 中秋节&#xff0c;祝大家中秋快乐&#xff01; 人有悲欢离合&#xff0c;月有阴晴圆缺&#xff0c;此事古难全。但愿人长久&#xff0c;千里共婵娟。 今天引入RSRS来择时&#xff0c;看下策略效果。 年化60.7…

Python编码系列—Python代理模式:为对象赋予超能力的魔法

&#x1f31f;&#x1f31f; 欢迎来到我的技术小筑&#xff0c;一个专为技术探索者打造的交流空间。在这里&#xff0c;我们不仅分享代码的智慧&#xff0c;还探讨技术的深度与广度。无论您是资深开发者还是技术新手&#xff0c;这里都有一片属于您的天空。让我们在知识的海洋中…

C++掉血迷宫

目录 开头程序程序的流程图程序游玩的效果下一篇博客要说的东西 开头 大家好&#xff0c;我叫这是我58。 程序 #include <iostream> #include <string> #include <cstring> using namespace std; enum RBYG {R 1,B 2,Y 4,G 7, }; struct heal {int ix…

【例题】lanqiao549 扫雷

输入 3 4 0 1 0 0 1 0 1 0 0 0 1 0输出 2 9 2 1 9 4 9 2 1 3 9 2解题思路 分类讨论&#xff1a; 如果原来的方格整数为1&#xff0c;输出9如果原来的方格整数为0&#xff0c;输出周围8个&#xff08;最多八个&#xff09;的地雷数量和 代码 如何遍历一个方格mp[i][j]周围…

c++中引用是通过指针的方式实现

其实在汇编层面上&#xff0c;引用的代码和指针的代码是一致的。 先看指针情况下的代码分析&#xff0c;如下所示&#xff1a; #include <iostream>using namespace std;void fuzhi(int *x)//引用传参 {*x 10; }int main(int argc, char** argv) {int a 0;int b;a …

架构设计——概念和基础

&#x1f3e0;1 架构基础 想要搞清楚架构到底指什么&#xff0c;架构与框架的区别&#xff0c;就需要了解梳理系统、子系统、模块、组件、框架和架构 1.1系统与子系统 1.1.1系统 wiki:系统泛指由一群有关联的个体组成&#xff0c;根据某种规则运作&#xff0c;能完成个别元…

Python编码系列—Python外观模式:简化复杂系统的快捷方式

&#x1f31f;&#x1f31f; 欢迎来到我的技术小筑&#xff0c;一个专为技术探索者打造的交流空间。在这里&#xff0c;我们不仅分享代码的智慧&#xff0c;还探讨技术的深度与广度。无论您是资深开发者还是技术新手&#xff0c;这里都有一片属于您的天空。让我们在知识的海洋中…

QT安装时出现错误(镜像)

QT下载网站 下载网址 QT安装时出现错误 解决方法 按“win+R”键弹出“运行”窗口,输入"cmd",点击确定; 打开如下图运行框,将Qt文件拖到窗口里->空一格输入“–mirror https://mirrors.aliyun.com/qt”->按enter键进入,即可成功安装 正式安

gazebo遇到的阶段性问题汇总

目录 1 gazebo中碰撞模型崩坏或者飞的问题2 编译报错解决方法 3 控制器无法正常启动解决方法 4 xacro:macro 定义函数5 xacro:property 定义变量的值报错截图解决方法 6 gazebo 模型视觉穿模&#xff08;已设置碰撞体积&#xff09;解决方法穿模截图 1 gazebo中碰撞模型崩坏或者…

王道408考研数据结构-绪论

1.1 数据结构的基本概念 数据结构 数据结构是相互之间存在一种或多种特定关系的数据元素的集合。在任何问题中&#xff0c;数据元素 都不是孤立存在的&#xff0c;它们之间存在某种关系&#xff0c;这种数据元素相互之间的关系称为结构(Structure)。 数据结构包括三方面的内…

中秋的“超级月亮”在哪?来竹海幻境寻找心中的白月光

夜幕低垂&#xff0c;一场视觉盛宴悄然拉开序幕——《桃花江竹海幻境》&#xff08;下文简称《竹海幻境》&#xff09;剧场中。一轮轮明月仿佛穿越时空的使者&#xff0c;与葱郁的竹林交相辉映&#xff0c;与天际那轮皎洁的明月共同编织出一幅“超级月亮”的绝美画卷&#xff0…

sizeof与strlen()函数的对比总结

目录 1.sizeof操作符1.1sizeof操作符特点 2.strlen( )函数2.1 函数简介2.2 创建字符串 3.sizeof 和 strlen的对比 1.sizeof操作符 在学习操作符的时候&#xff0c;我们学习了 sizeof &#xff0c; sizeof 计算变量所占内存内存空间⼤⼩的&#xff0c;单位是字节&#xff0c;如…

C++的类与对象下

目录 1.初始化列表 2.隐式类型转换 1.单参数 2.多参数&#xff08;C11提供的新功能&#xff09; 3.static成员 4.友元 5.内部类 6.匿名对象 1.初始化列表 C祖师爷规定初始化列表是成员变量定义与初始化的地方。 class Time { public:Time(int hour):_hour(hour){cout &…

从虚拟机安装CentOS到自定义Dockerfile构建tomcat镜像

写在开头 整个过程中涉及的三方软件均来源于三方的官网&#xff0c;因此需要有一个稳定良好的访问公网网络的环境&#xff0c;可能需要科学上网 下载并安装 VMware Workstation Player 下载 需要先注册登录&#xff1a;https://login.broadcom.com/signin 下载页面&#xff1a…

7-23 还原二叉树

代码&#xff1a; #include<iostream> using namespace std; int n; char a[55],b[55]; int dfs(int l,int r,int x,int y){ // printf("**l%d,r%d,x%d,y%d\n",l,r,x,y);if(l>r) return 0; // if(lr) return 1;int i;for(ix;i<y;i){if(a[l]b[i]) break;…

信息安全工程师(6)网络信息安全现状与问题

一、网络信息安全现状 威胁日益多样化&#xff1a;网络攻击手段不断翻新&#xff0c;从传统的病毒、木马、蠕虫等恶意软件&#xff0c;到勒索软件、钓鱼攻击、DDoS攻击、供应链攻击等&#xff0c;威胁形式多种多样。这些攻击不仅针对个人用户&#xff0c;还广泛影响企业、政府等…