Ubuntu 22.04安装和使用ROS1可行吗_ubuntu22.04安装ros1-CSDN博客
Parrot系统
如果你还不了解这个系统,如下文字就不用接着看了。
为何使用
为何更好的应用各类互联网信息,仅此而已。
开发利器
终端
ROS1和ROS2支持所有操作系统,支持的硬件芯片也是越来越多。
大部分ROS1支持安装如下:
sudo apt install ros-desktop-full ros-desktop-full-dev
sudo apt install ros-desktop-full ros-desktop-full-dev
sudo apt install ros-desktop-full ros-desktop-full-dev
等待结束就行,无需其他任何配置。
未安装
配色
白底黑字
安装ROS1后
启动roscore
ros1是debian永久支持的。常见发行版如ubuntu。
15是N之后的那个字母吧,noetic之后的。O
cocubesim
这个就是turtlesim改的。
zhangrelay / cocubesim · GitCode
git clone https://gitcode.net/ZhangRelay/cocubesim
常用和编程相关的软件parrot都默认安装了,非常方便,使用多年,但是不推荐Linux初学者使用。
解压缩:
tar -xf cocubesim.tar
然后到对应文件夹下编译:
catkin_make
如果要使用catkin build,需要配置一下。
sudo apt install catkin-tools
等待一小会就ok。
运行顺畅
修改代码
/** Copyright (c) 2009, Willow Garage, Inc.* All rights reserved.** Redistribution and use in source and binary forms, with or without* modification, are permitted provided that the following conditions are met:** * Redistributions of source code must retain the above copyright* notice, this list of conditions and the following disclaimer.* * Redistributions in binary form must reproduce the above copyright* notice, this list of conditions and the following disclaimer in the* documentation and/or other materials provided with the distribution.* * Neither the name of the Willow Garage, Inc. nor the names of its* contributors may be used to endorse or promote products derived from* this software without specific prior written permission.** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE* POSSIBILITY OF SUCH DAMAGE.*/#include "turtlesim/turtle_frame.h"#include <QPointF>#include <ros/package.h>
#include <cstdlib>
#include <ctime>#define DEFAULT_BG_R 0xff
#define DEFAULT_BG_G 0xff
#define DEFAULT_BG_B 0xffnamespace turtlesim
{TurtleFrame::TurtleFrame(QWidget* parent, Qt::WindowFlags f)
: QFrame(parent, f)
, path_image_(500, 500, QImage::Format_ARGB32)
, path_painter_(&path_image_)
, frame_count_(0)
, id_counter_(0)
{setFixedSize(500, 500);setWindowTitle("CoCubeSim");srand(time(NULL));update_timer_ = new QTimer(this);update_timer_->setInterval(16);update_timer_->start();connect(update_timer_, SIGNAL(timeout()), this, SLOT(onUpdate()));nh_.setParam("background_r", DEFAULT_BG_R);nh_.setParam("background_g", DEFAULT_BG_G);nh_.setParam("background_b", DEFAULT_BG_B);QVector<QString> turtles;turtles.append("cocubea.png");turtles.append("cocubeb.png");turtles.append("cocubec.png");turtles.append("cocubed.png");turtles.append("cocubee.png");turtles.append("cocubef.png");turtles.append("cocubeg.png");turtles.append("cocubeh.png");turtles.append("cocubei.png");turtles.append("cocubej.png");turtles.append("cocubek.png");
/* turtles.append("box-turtle.png");turtles.append("robot-turtle.png");turtles.append("sea-turtle.png");turtles.append("diamondback.png");turtles.append("electric.png");turtles.append("fuerte.png");turtles.append("groovy.png");turtles.append("hydro.svg");turtles.append("indigo.svg");turtles.append("jade.png");turtles.append("kinetic.png");*/QString images_path = (ros::package::getPath("turtlesim") + "/images/").c_str();for (int i = 0; i < turtles.size(); ++i){QImage img;img.load(images_path + turtles[i]);turtle_images_.append(img);}meter_ = turtle_images_[0].height();clear();clear_srv_ = nh_.advertiseService("clear", &TurtleFrame::clearCallback, this);reset_srv_ = nh_.advertiseService("reset", &TurtleFrame::resetCallback, this);spawn_srv_ = nh_.advertiseService("spawn", &TurtleFrame::spawnCallback, this);kill_srv_ = nh_.advertiseService("kill", &TurtleFrame::killCallback, this);ROS_INFO("Starting turtlesim with node name %s", ros::this_node::getName().c_str()) ;width_in_meters_ = (width() - 1) / meter_;height_in_meters_ = (height() - 1) / meter_;spawnTurtle("", width_in_meters_ / 2.0, height_in_meters_ / 2.0, 0);// spawn all available turtle typesif(false){for(int index = 0; index < turtles.size(); ++index){QString name = turtles[index];name = name.split(".").first();name.replace(QString("-"), QString(""));spawnTurtle(name.toStdString(), 1.0 + 1.5 * (index % 7), 1.0 + 1.5 * (index / 7), PI / 2.0, index);}}
}TurtleFrame::~TurtleFrame()
{delete update_timer_;
}bool TurtleFrame::spawnCallback(turtlesim::Spawn::Request& req, turtlesim::Spawn::Response& res)
{std::string name = spawnTurtle(req.name, req.x, req.y, req.theta);if (name.empty()){ROS_ERROR("A turtled named [%s] already exists", req.name.c_str());return false;}res.name = name;return true;
}bool TurtleFrame::killCallback(turtlesim::Kill::Request& req, turtlesim::Kill::Response&)
{M_Turtle::iterator it = turtles_.find(req.name);if (it == turtles_.end()){ROS_ERROR("Tried to kill turtle [%s], which does not exist", req.name.c_str());return false;}turtles_.erase(it);update();return true;
}bool TurtleFrame::hasTurtle(const std::string& name)
{return turtles_.find(name) != turtles_.end();
}std::string TurtleFrame::spawnTurtle(const std::string& name, float x, float y, float angle)
{return spawnTurtle(name, x, y, angle, rand() % turtle_images_.size());
}std::string TurtleFrame::spawnTurtle(const std::string& name, float x, float y, float angle, size_t index)
{std::string real_name = name;if (real_name.empty()){do{std::stringstream ss;ss << "turtle" << ++id_counter_;real_name = ss.str();} while (hasTurtle(real_name));}else{if (hasTurtle(real_name)){return "";}}TurtlePtr t(new Turtle(ros::NodeHandle(real_name), turtle_images_[index], QPointF(x, height_in_meters_ - y), angle));turtles_[real_name] = t;update();ROS_INFO("Spawning turtle [%s] at x=[%f], y=[%f], theta=[%f]", real_name.c_str(), x, y, angle);return real_name;
}void TurtleFrame::clear()
{int r = DEFAULT_BG_R;int g = DEFAULT_BG_G;int b = DEFAULT_BG_B;nh_.param("background_r", r, r);nh_.param("background_g", g, g);nh_.param("background_b", b, b);path_image_.fill(qRgb(r, g, b));update();
}void TurtleFrame::onUpdate()
{ros::spinOnce();updateTurtles();if (!ros::ok()){close();}
}void TurtleFrame::paintEvent(QPaintEvent*)
{QPainter painter(this);painter.drawImage(QPoint(0, 0), path_image_);M_Turtle::iterator it = turtles_.begin();M_Turtle::iterator end = turtles_.end();for (; it != end; ++it){it->second->paint(painter);}
}void TurtleFrame::updateTurtles()
{if (last_turtle_update_.isZero()){last_turtle_update_ = ros::WallTime::now();return;}bool modified = false;M_Turtle::iterator it = turtles_.begin();M_Turtle::iterator end = turtles_.end();for (; it != end; ++it){modified |= it->second->update(0.001 * update_timer_->interval(), path_painter_, path_image_, width_in_meters_, height_in_meters_);}if (modified){update();}++frame_count_;
}bool TurtleFrame::clearCallback(std_srvs::Empty::Request&, std_srvs::Empty::Response&)
{ROS_INFO("Clearing turtlesim.");clear();return true;
}bool TurtleFrame::resetCallback(std_srvs::Empty::Request&, std_srvs::Empty::Response&)
{ROS_INFO("Resetting turtlesim.");turtles_.clear();id_counter_ = 0;spawnTurtle("", width_in_meters_ / 2.0, height_in_meters_ / 2.0, 0);clear();return true;
}}
太长了看不懂?之前博客也没看过……用AI工具吧
要将 TurtleFrame
窗口的尺寸改大一些,您需要修改窗口的尺寸属性。在您的代码中,您设置了窗口的固定大小为 500x500 像素。要修改这个尺寸,您需要修改 setFixedSize
方法的参数。
以下是如何修改代码以将窗口大小改为 800x800 像素:
cpp
TurtleFrame::TurtleFrame(QWidget* parent, Qt::WindowFlags f)
: QFrame(parent, f)
, path_image_(800, 800, QImage::Format_ARGB32) // 修改了 path_image_ 的尺寸
, path_painter_(&path_image_)
, frame_count_(0)
, id_counter_(0)
{ setFixedSize(800, 800); // 修改了窗口的固定大小 setWindowTitle("CoCubeSim");
}
TurtleFrame::TurtleFrame(QWidget* parent, Qt::WindowFlags f) | |
: QFrame(parent, f) | |
, path_image_(800, 800, QImage::Format_ARGB32) // 修改了 path_image_ 的尺寸 | |
, path_painter_(&path_image_) | |
, frame_count_(0) | |
, id_counter_(0) | |
{ | |
setFixedSize(800, 800); // 修改了窗口的固定大小 | |
setWindowTitle("CoCubeSim"); | |
} |
请注意,修改窗口大小可能会影响到您的应用程序的其他部分,比如布局和内容的大小。如果内容不能适应新的尺寸,您可能还需要相应地调整其他部分的代码。
懂不懂C++都没啥关系。AI实力远超普通程序员,顶级大牛AI目前还pk不过。
蝴蝶曲线搭配鹦鹉系统
Parrot OS是一款基于Debian的Linux发行版,其功能和特色主要包括以下几个方面:
- 安全和渗透测试工具:Parrot OS提供了广泛的安全和渗透测试工具,如Metasploit、Nmap和Aircrack-ng等。这些工具对于安全研究和网络测试至关重要。Parrot OS安全版则完全侧重于渗透测试和红队操作,包含计算机取证分析、反向工程、攻击和云渗透测试等功能。
- 隐私保护:Parrot OS自带Tor、Anonsurf和其他匿名工具,允许用户在网上保持匿名,这对于注重隐私的用户来说非常有用。
- 轻量级环境:Parrot OS使用MATE桌面环境,这是一个资源效率高、使用方便的界面。这使得它可以在资源有限的设备上运行,如老旧的电脑或低配置的硬件。
- 多用途使用:尽管Parrot OS主要面向安全领域,但它也提供了完整的日常使用软件套件,包括办公软件、网页浏览器和媒体工具。
- 系统规格:Parrot OS基于Debian 9,运行在自定义的增强的Linux内核4.5上,使用MATE桌面和Lightdm显示管理器。它还支持Qt5和.net / mono框架,以及嵌入式系统的开发框架等。
- 数字取证:Parrot OS支持“法证”启动选项来顺开机自动挂接,并提供了许多数字取证工具。
- 编程:Parrot OS支持多种编程语言、多编译器和调试器,以及嵌入式系统的开发框架等。
- 加密工具:Parrot OS带有定制的反取证工具,支持GPG和cryptsetup接口,还支持加密工具如LUKS、Truecrypt和VeraCrypt等。
总之,Parrot OS是一款专注于安全和隐私的Linux发行版,提供了丰富的安全和渗透测试工具、隐私保护功能、轻量级环境和多用途使用等特色。同时,它还支持数字取证、编程和加密工具等扩展功能。