{"id":38,"date":"2026-03-20T21:36:49","date_gmt":"2026-03-20T13:36:49","guid":{"rendered":"http:\/\/120.26.182.148:23333\/?p=38"},"modified":"2026-04-05T18:08:37","modified_gmt":"2026-04-05T10:08:37","slug":"ros2%e5%ad%a6%e4%b9%a0%e8%ae%b0%e5%bd%95","status":"publish","type":"post","link":"https:\/\/374969782.xyz\/index.php\/2026\/03\/20\/ros2%e5%ad%a6%e4%b9%a0%e8%ae%b0%e5%bd%95\/","title":{"rendered":"ROS2\u5b66\u4e60\u8bb0\u5f55\uff081\uff09"},"content":{"rendered":"\n<p>\u5de5\u4f5c\u7a7a\u95f4\uff08workspace\uff09\uff1a\u5b58\u653e\u9879\u76ee\u5f00\u53d1\u76f8\u5173\u6587\u4ef6\u7684\u6587\u4ef6\u5939\uff0c\u9879\u76ee\u7684\u6839\u76ee\u5f55\u3002<\/p>\n\n\n\n<details class=\"wp-block-details is-layout-flow wp-block-details-is-layout-flow\"><summary>\u5de5\u4f5c\u7a7a\u95f4\u7ed3\u6784\u5982\u4e0b\uff1a<\/summary>\n<ul class=\"wp-block-list\">\n<li>src\uff1a\u4ee3\u7801\u7a7a\u95f4(Source Space)\uff0c\u6e90\u7801\u6240\u5728\u5730<\/li>\n\n\n\n<li>install\uff1a\u5b89\u88c5\u7a7a\u95f4(Install Space)\uff0c\u4ee3\u7801\u7684\u7f16\u8bd1\u7ed3\u679c\uff0c\u53ef\u6267\u884c\u7a0b\u5e8f<\/li>\n\n\n\n<li>build\uff1a\u7f16\u8bd1\u7a7a\u95f4\uff08Build Space\uff09\uff0c\u7f16\u8bd1\u8fc7\u7a0b\u4ea7\u751f\u7684\u4e2d\u95f4\u6587\u4ef6\uff0c\u4e00\u822c\u4e0d\u53ef\u8bfb<\/li>\n\n\n\n<li>log\uff1a\u65e5\u5fd7\u7a7a\u95f4(Log Space)<\/li>\n<\/ul>\n<\/details>\n\n\n\n<details class=\"wp-block-details is-layout-flow wp-block-details-is-layout-flow\"><summary>\u521b\u5efa\u5de5\u4f5c\u7a7a\u95f4\uff1a<\/summary>\n<p><code>mkdir -p .\/test_ws\/src<\/code><\/p>\n\n\n\n<p>\u5728\u5f53\u524d\u76ee\u5f55\u4e0b\u521b\u5efa\u5de5\u4f5c\u7a7a\u95f4test_ws\u53ca\u5176\u4ee3\u7801\u7a7a\u95f4\uff0c-p\u6307\u5b9a\u81ea\u52a8\u521b\u5efa\u76ee\u6807\u8def\u5f84\u4e2d\u6240\u6709\u4e0d\u5b58\u5728\u7684\u7236\u76ee\u5f55\uff0c\u4e14\u5982\u679c\u76ee\u6807\u76ee\u5f55\u5df2\u5b58\u5728\u4e5f\u4e0d\u4f1a\u62a5\u9519\u3002<\/p>\n<\/details>\n\n\n\n<p>\u5e38\u89c4python\u73af\u5883\u914d\u7f6e\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt install -y python3-pip<\/code><\/pre>\n\n\n\n<p>\u4e3a\u4e86\u4fbf\u4e8eros2\u73af\u5883\u7ba1\u7406\uff0c\u8fd8\u9700\u5b89\u88c5python\u7684rosdep\u5e93\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo pip3 install rosdepc\nsudo rosdepc init\nrosdepc update<\/code><\/pre>\n\n\n\n<p>\u5728\u5b9e\u9645\u64cd\u4f5c\u60c5\u51b5\u4e0b\uff0c\u6267\u884c\u7b2c\u4e09\u6761\u8bed\u53e5\u65f6\u51fa\u73b0\u4e86\u5982\u4e0b\u95ee\u9898\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ERROR: unable to process source &#91;file:\/\/\/usr\/share\/python3-rosdep2\/debian.yaml]:\n\t&lt;urlopen error &#91;Errno 2] No such file or directory: '\/usr\/share\/python3-rosdep2\/debian.yaml'> (file:\/\/\/usr\/share\/python3-rosdep2\/debian.yaml)<\/code><\/pre>\n\n\n\n<p>\u8be2\u95eedeepseek\u8001\u5e08\u5f97\u77e5\uff0c\u9700\u8981\u7528apt\u65b9\u5f0f\u5b89\u88c5rosdepc\u624d\u4f1a\u51fa\u73b0\u90a3\u4e2a\u6587\u4ef6\uff0c\u907f\u514d\u62a5\u9519\u3002<\/p>\n\n\n\n<p>\u6267\u884c\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt update\nsudo apt install python3-rosdep2\nrosdepc update<\/code><\/pre>\n\n\n\n<p>\u6b64\u5916\uff0c\u8fd8\u9700\u8981\u914d\u7f6e\u53e6\u4e00\u4e2a\u5de5\u4f5c\u7a7a\u95f4\u642d\u5efa\u5de5\u5177\uff0c\u6267\u884c\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt install python3-colcon-ros<\/code><\/pre>\n\n\n\n<p>\u5230\u6b64\uff0c\u73af\u5883\u5df2\u6b63\u5e38\u914d\u7f6e\u3002<\/p>\n\n\n\n<p>\u521b\u5efa\u5de5\u4f5c\u7a7a\u95f4\u540e\uff0c\u53ef\u4ee5\u4f7f\u7528rosdep\u4fbf\u6377\u5730\u5f15\u5165\u6240\u9700\u4f9d\u8d56\uff0c\u5728\u5de5\u4f5c\u7a7a\u95f4\u76ee\u5f55\u4e0b\u6267\u884c\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>rosdepc install -i --from-path src --rosdistro humble -y<\/code><\/pre>\n\n\n\n<p>\u7136\u540e\u51c6\u5907\u6b63\u5f0f\u542f\u52a8\u9879\u76ee\uff0c\u6765\u5230\u5de5\u4f5c\u7a7a\u95f4\u76ee\u5f55\u4e0b\uff0c\u6267\u884c\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>colcon build<\/code><\/pre>\n\n\n\n<p>\u81ea\u52a8\u5bf9\u5de5\u4f5c\u7a7a\u95f4\u8fdb\u884c\u7f16\u8bd1\u3002\u5728\u9879\u76ee\u5199\u5b8c\u540e\uff08\u5373src\u5185\u7684\u6e90\u7801\u5199\u5b8c\uff09\u6267\u884c\u8be5\u8bed\u53e5\uff0c\u4f1a\u5728install\u5185\u6784\u5efa\u5bf9\u5e94\u7684\u53ef\u6267\u884c\u7a0b\u5e8f\u3002<\/p>\n\n\n\n<p>\u6b64\u65f6\u8fd8\u5e94\u5c06\u4f9d\u8d56\u7b49\u73af\u5883\u5f15\u5165\u73af\u5883\u53d8\u91cf\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>source install\/local_setup.sh<\/code><\/pre>\n\n\n\n<p>\u987b\u77e5\uff0c\u8be5\u547d\u4ee4\u4ec5\u5bf9\u5f53\u524d\u547d\u4ee4\u884c\u7a97\u53e3\u6709\u6548\u3002\u60f3\u8981\u907f\u514d\u6bcf\u4e2a\u7a97\u53e3\u591a\u6b21\u8bbe\u7f6e\uff0c\u53ef\u4ee5\u53bbhome\u6587\u4ef6\u5939\u5185\uff0c\u627e\u5230.bashrc\u6587\u4ef6\uff08\u672c\u8eab\u662f\u9690\u85cf\u6587\u4ef6\uff09\uff0c\u5728\u6587\u672b\u52a0\u5165\u76f8\u5173\u8bed\u53e5\u3002<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u529f\u80fd\u5305<\/strong><\/h2>\n\n\n\n<p>\u964d\u4f4e\u4e0d\u540c\u529f\u80fd\u95f4\u7684\u8026\u5408\u5ea6\uff0c\u589e\u52a0\u7a0b\u5e8f\u53ef\u590d\u7528\u6027\u3002<\/p>\n\n\n\n<p>\u5728\u5de5\u4f5c\u7a7a\u95f4\u7684src\u76ee\u5f55\u4e0b\u521b\u5efa\u529f\u80fd\u5305\u4ee3\u7801\u5f62\u5f0f\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ros2 pkg create --build-type &lt;build-type> &lt;package_name><\/code><\/pre>\n\n\n\n<p>\u521b\u5efac++\u529f\u80fd\u5305\u65f6\uff0cbuild-type\u53c2\u6570\u7c7b\u578b\u4e3aament_cmake\uff1b\u521b\u5efapython\u529f\u80fd\u5305\u65f6\uff0cbuild-type\u53c2\u6570\u7c7b\u578b\u4e3aament_python\u3002<\/p>\n\n\n\n<p>\u5728\u529f\u80fd\u5305\u5185\u7f16\u5199\u6e90\u7801\u540e\uff0c\u9700\u8981\u7f16\u8bd1\uff08\u5373colcon build\u8bed\u53e5\uff09\u540e\u624d\u80fd\u52a0\u5165\u5230install\u5f62\u6210\u53ef\u6267\u884c\u6587\u4ef6\uff0c\u5e76\u518d\u6b21\u6267\u884csource\u4ee3\u7801\u66f4\u65b0\u73af\u5883\u53d8\u91cf\u624d\u53ef\u88ab\u6267\u884c\u3002<\/p>\n\n\n\n<details class=\"wp-block-details is-layout-flow wp-block-details-is-layout-flow\"><summary>c++\u6587\u4ef6\u529f\u80fd\u5305\u5fc5\u7136\u5b58\u5728\u4e24\u4e2a\u6587\u4ef6\uff1a<strong>package.xml<\/strong>\u548c<strong>CMakerLists.txt<\/strong>\u3002<\/summary>\n<p>package.xml\u6587\u4ef6\u7684\u4e3b\u8981\u5185\u5bb9\u5982\u4e0b\uff0c\u5305\u542b\u529f\u80fd\u5305\u7684\u7248\u6743\u63cf\u8ff0\uff0c\u548c\u5404\u79cd\u4f9d\u8d56\u7684\u58f0\u660e\u3002<\/p>\n\n\n\n<p>CMakeLists.txt\u6587\u4ef6\u662f\u7f16\u8bd1\u89c4\u5219\uff0cC++\u4ee3\u7801\u9700\u8981\u7f16\u8bd1\u624d\u80fd\u8fd0\u884c\uff0c\u6240\u4ee5\u5fc5\u987b\u8981\u5728\u8be5\u6587\u4ef6\u4e2d\u8bbe\u7f6e\u5982\u4f55\u7f16\u8bd1\uff0c\u4f7f\u7528CMake\u8bed\u6cd5\u3002<\/p>\n<\/details>\n\n\n\n<details class=\"wp-block-details is-layout-flow wp-block-details-is-layout-flow\"><summary>python\u529f\u80fd\u5305\u4f1a\u6709\u8fd9\u4e24\u4e2a\u6587\u4ef6\uff1a<strong>package.xml<\/strong>\u548c<strong>setup.py<\/strong>\u3002<\/summary>\n<p>package.xml\u6587\u4ef6\u7684\u4e3b\u8981\u5185\u5bb9\u548cC++\u7248\u672c\u529f\u80fd\u5305\u4e00\u6837\uff0c\u5305\u542b\u529f\u80fd\u5305\u7684\u7248\u6743\u63cf\u8ff0\uff0c\u548c\u5404\u79cd\u4f9d\u8d56\u7684\u58f0\u660e\u3002<\/p>\n\n\n\n<p>setup.py\u6587\u4ef6\u91cc\u8fb9\u4e5f\u5305\u542b\u4e00\u4e9b\u7248\u6743\u4fe1\u606f\uff0c\u9664\u6b64\u4e4b\u5916\uff0c\u8fd8\u6709\u201centry_points\u201d\u914d\u7f6e\u7684\u7a0b\u5e8f\u5165\u53e3\u3002<\/p>\n<\/details>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5de5\u4f5c\u7a7a\u95f4\uff08workspace\uff09\uff1a\u5b58\u653e\u9879\u76ee\u5f00\u53d1\u76f8\u5173\u6587\u4ef6\u7684\u6587\u4ef6\u5939\uff0c\u9879\u76ee\u7684\u6839\u76ee\u5f55\u3002 \u5e38\u89c4python\u73af\u5883\u914d\u7f6e\uff1a \u4e3a\u4e86 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[],"class_list":["post-38","post","type-post","status-publish","format-standard","hentry","category-ros2"],"_links":{"self":[{"href":"https:\/\/374969782.xyz\/index.php\/wp-json\/wp\/v2\/posts\/38","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/374969782.xyz\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/374969782.xyz\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/374969782.xyz\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/374969782.xyz\/index.php\/wp-json\/wp\/v2\/comments?post=38"}],"version-history":[{"count":6,"href":"https:\/\/374969782.xyz\/index.php\/wp-json\/wp\/v2\/posts\/38\/revisions"}],"predecessor-version":[{"id":59,"href":"https:\/\/374969782.xyz\/index.php\/wp-json\/wp\/v2\/posts\/38\/revisions\/59"}],"wp:attachment":[{"href":"https:\/\/374969782.xyz\/index.php\/wp-json\/wp\/v2\/media?parent=38"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/374969782.xyz\/index.php\/wp-json\/wp\/v2\/categories?post=38"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/374969782.xyz\/index.php\/wp-json\/wp\/v2\/tags?post=38"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}