layabout4233629 / layabout

用来写写自己学习的技术心得,如果对您有帮助,别忘了加“星”
1 stars 0 forks source link

尝试在WIN10下使用ROS #13

Open layabout4233629 opened 4 years ago

layabout4233629 commented 4 years ago

win10下安装ROS1的过程

由于长期在windows环境写代码,对命令行的ubuntu不是很熟悉。突然想到能不能在windows下直接编译ROS?搜索了一下好像可以。

安装了大约1小时,大部分都成功了,还有部分包安装失败,有时间再单独一个一个安装。

ERROR: the following rosdeps failed to install
  pip: command [pip install -U matplotlib] failed
  pip: Failed to detect successful installation of [matplotlib]
  pip: command [pip install -U pillow] failed
  pip: Failed to detect successful installation of [pillow]
  chocolatey: command [choco upgrade -y libpcl] failed
  chocolatey: command [choco upgrade -y assimp] failed
  chocolatey: Failed to detect successful installation of [libpcl]
  chocolatey: Failed to detect successful installation of [assimp]
  pip: command [pip install -U opencv-python] failed
  pip: command [pip install -U wxPython] failed
  pip: Failed to detect successful installation of [opencv-python]
  pip: Failed to detect successful installation of [wxPython]
  pip: command [pip install -U numpy] failed
  pip: Failed to detect successful installation of [numpy]
  pip: command [pip install -U cairocffi] failed
  pip: Failed to detect successful installation of [cairocffi]
  chocolatey: command [choco upgrade -y libopencv] failed
  chocolatey: Failed to detect successful installation of [libopencv]
找不到批处理文件。

先cd到安装路径(C:\opt\ros\melodic\x64),然后在cmd窗口运行setup.bat(后面把setup放到快捷方式的命令里就不用每次启动都输了),再输入roscore,可以简单判断ros是否已经装成功。

C:\Windows\System32>cd C:\opt\ros\melodic\x64

C:\opt\ros\melodic\x64>setup.bat

C:\opt\ros\melodic\x64>roscore
... logging to C:\Users\ASUS\.ros\log\71cda780-327f-11ea-b7c8-b4d5bd9bf9a0\roslaunch-LAPTOP-N75PUEPK-2160.log
Checking log directory for disk usage. This may take a while.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.
started roslaunch server http://LAPTOP-N75PUEPK:60083/
ros_comm version 1.14.3

SUMMARY
========

PARAMETERS
 * /rosdistro: melodic
 * /rosversion: 1.14.3

NODES

auto-starting new master
process[master]: started with pid [1964]
ROS_MASTER_URI=http://LAPTOP-N75PUEPK:11311/
setting /run_id to 71cda780-327f-11ea-b7c8-b4d5bd9bf9a0
process[rosout-1]: started with pid [19680]
started core service [/rosout]

再输入以下命令就是可以玩自带的小乌龟了

rosrun turtlesim turtle_teleop_key.exe
rosrun turtlesim turtlesim_node

ROS在wins10下使用

windows下用ROS编写C++版本的helloworld

创建一个保存代码的文件夹(顶级目录)

创建一个workspace

catkin_init_workspace

用catkin_create_pkg来创建一个包

catkin_create_pkg hello_ros

运行效果

C:\ljj\00 work\02 code\202001 AGVRos>catkin_create_pkg hello_ros
Created file hello_ros\CMakeLists.txt
Created file hello_ros\package.xml
Successfully created files in C:\ljj\00 work\02 code\202001 AGVRos\hello_ros. Please adjust the values in package.xml.

创建hellword.cpp文件

#include <ros/ros.h>
 int main(int argc, char **argv) 
{ 
    ros::init(argc,argv,"hello world"); 
    ros::NodeHandle n; 
    ROS_INFO("Hello WORLD!");
    ros::spinOnce(); 
}

修改cmake.txt文件(注意是修改,可以加到末尾。)

find_package(catkin REQUIRED COMPONENTS
roscpp
)
add_executable(hello hello.cpp)
target_link_libraries(hello ${catkin_LIBRARIES})

输入catkin_make编译heloword

C:\ljj\00_work\02_code\202001_AGVRos>catkin_make
Base path: C:\ljj\00_work\02_code\202001_AGVRos
Source space: C:\ljj\00_work\02_code\202001_AGVRos\src
Build space: C:\ljj\00_work\02_code\202001_AGVRos\build
Devel space: C:\ljj\00_work\02_code\202001_AGVRos\devel
Install space: C:\ljj\00_work\02_code\202001_AGVRos\install
####
#### Running command: "cmake C:\ljj\00_work\02_code\202001_AGVRos\src -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCATKIN_DEVEL_PREFIX=C:\ljj\00_work\02_code\202001_AGVRos\devel -DCMAKE_INSTALL_PREFIX=C:\ljj\00_work\02_code\202001_AGVRos\install -G NMake Makefiles" in "C:\ljj\00_work\02_code\202001_AGVRos\build"
####
CMake Warning (dev) in CMakeLists.txt:
  No project() command is present.  The top-level CMakeLists.txt file must
  contain a literal, direct call to the project() command.  Add a line of
  code such as

    project(ProjectName)

  near the top of the file, but after cmake_minimum_required().

  CMake is pretending there is a "project(Project)" command on the first
  line.
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Using CATKIN_DEVEL_PREFIX: C:/ljj/00_work/02_code/202001_AGVRos/devel
-- Using CMAKE_PREFIX_PATH: C:/opt/ros/melodic/x64;C:/opt/rosdeps/x64;C:/opt/vcpkg/installed/x64-windows
-- This workspace overlays: C:/opt/ros/melodic/x64
-- Using PYTHON_EXECUTABLE: C:/opt/python27amd64/python.exe
-- Using default Python package layout
-- Using empy: C:/opt/python27amd64/lib/site-packages/em.pyc
-- Using CATKIN_ENABLE_TESTING: ON
-- Call enable_testing()
-- Using CATKIN_TEST_RESULTS_DIR: C:/ljj/00_work/02_code/202001_AGVRos/build/test_results
-- Found gtest: gtests will be built
-- Using Python nosetests: C:/opt/python27amd64/Scripts/nosetests-2.7.exe
-- catkin 0.7.18
-- BUILD_SHARED_LIBS is on
-- BUILD_SHARED_LIBS is on
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- ~~  traversing 3 packages in topological order:
-- ~~  - hello_ros
-- ~~  - py_demo
-- ~~  - beginner_tutorials
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- +++ processing catkin package: 'hello_ros'
-- ==> add_subdirectory(hello_ros)
-- +++ processing catkin package: 'py_demo'
-- ==> add_subdirectory(py_demo)
-- Using these message generators: gencpp;geneus;genlisp;gennodejs;genpy
-- py_demo: 2 messages, 0 services
-- +++ processing catkin package: 'beginner_tutorials'
-- ==> add_subdirectory(beginner_tutorials)
-- Configuring done
CMake Warning (dev) at beginner_tutorials/CMakeLists.txt:212 (add_dependencies):
  Policy CMP0046 is not set: Error on non-existent dependency in
  add_dependencies.  Run "cmake --help-policy CMP0046" for policy details.
  Use the cmake_policy command to set the policy and suppress this warning.

  The dependency target "beginner_tutorials_generate_messages_cpp" of target
  "talker" does not exist.
This warning is for project developers.  Use -Wno-dev to suppress it.

CMake Warning (dev) at beginner_tutorials/CMakeLists.txt:216 (add_dependencies):
  Policy CMP0046 is not set: Error on non-existent dependency in
  add_dependencies.  Run "cmake --help-policy CMP0046" for policy details.
  Use the cmake_policy command to set the policy and suppress this warning.

  The dependency target "beginner_tutorials_generate_messages_cpp" of target
  "listener" does not exist.
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Generating done
-- Build files have been written to: C:/ljj/00_work/02_code/202001_AGVRos/build
####
#### Running command: "nmake" in "C:\ljj\00_work\02_code\202001_AGVRos\build"
####

Microsoft (R) 程序维护实用工具 14.16.27034.0 版
版权所有 (C) Microsoft Corporation。  保留所有权利。

[ 10%] Built target _setup_util.py_executable_install_python
Scanning dependencies of target hello
[ 15%] Building CXX object hello_ros/CMakeFiles/hello.dir/hello.cpp.obj
hello.cpp
[ 20%] Linking CXX executable C:\ljj\00_work\02_code\202001_AGVRos\devel\lib\hello_ros\hello.exe
[ 20%] Built target hello
Scanning dependencies of target std_msgs_generate_messages_eus
[ 20%] Built target std_msgs_generate_messages_eus
[ 20%] Built target _py_demo_generate_messages_check_deps_batterydata
[ 20%] Built target _py_demo_generate_messages_check_deps_motordata
[ 35%] Built target py_demo_generate_messages_eus
Scanning dependencies of target std_msgs_generate_messages_cpp
[ 35%] Built target std_msgs_generate_messages_cpp
[ 45%] Built target py_demo_generate_messages_cpp
Scanning dependencies of target std_msgs_generate_messages_py
[ 45%] Built target std_msgs_generate_messages_py
[ 60%] Built target py_demo_generate_messages_py
Scanning dependencies of target std_msgs_generate_messages_lisp
[ 60%] Built target std_msgs_generate_messages_lisp
[ 70%] Built target py_demo_generate_messages_lisp
Scanning dependencies of target std_msgs_generate_messages_nodejs
[ 70%] Built target std_msgs_generate_messages_nodejs
[ 80%] Built target py_demo_generate_messages_nodejs
[ 80%] Built target py_demo_generate_messages
[ 90%] Built target talker
[100%] Built target listener

然后你会发现多出来了build和devel两个文件夹。

让ROS知道你编译的节点

在devel文件夹下执行setup.bat(在linux下是执行setup.bash),在命令行执行。

激动的时刻

C:\ljj\00_work\02_code\202001_AGVRos>cd devel
C:\ljj\00_work\02_code\202001_AGVRos\devel>setup.bat
C:\ljj\00_work\02_code\202001_AGVRos\devel>rosrun hello_ros hello
[ INFO] [1578556044.825813500]: Hello ROS!

参考

cwbzzz commented 3 years ago

win10的ros可以录制rosbag吗?和ubuntu下的rosbag可以通用吗

layabout4233629 commented 3 years ago

这个不清楚

---原始邮件--- 发件人: @.> 发送时间: 2021年5月11日(周二) 下午3:32 收件人: @.>; 抄送: @.**@.>; 主题: Re: [layabout4233629/layabout] 尝试在WIN10下使用ROS (#13)

win10的ros可以录制rosbag吗?和ubuntu下的rosbag可以通用吗

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

ysingfun commented 3 weeks ago

win10安装ros noetic 需要翻墙代理吗?之前安装过一次,可以正常使用。现在重新安装总是失败。 D:>choco upgrade ros-noetic-desktop_full -y --execution-timeout=0 Chocolatey v2.3.0 Upgrading the following packages: ros-noetic-desktop_full By upgrading, you accept licenses for the packages. ros-noetic-desktop_full is not installed. Installing... Unable to connect to source 'https://aka.ms/ros/public': Failed to fetch results from V2 feed at 'https://ros.org/Packages()?$filter=(tolower(Id)%20eq%20'ros-noetic-desktop_full')%20and%20IsLatestVersion&semVerLevel=2.0.0' with following message : 响应状态代码不指示成功: 404 (Not Found)。 ros-noetic-desktop_full not installed. The package was not found with the source(s) listed. Source(s): 'https://aka.ms/ros/public;https://community.chocolatey.org/api/v2/' NOTE: When you specify explicit sources, it overrides default sources. If the package version is a prerelease and you didn't specify --pre, the package may not be found. Please see https://docs.chocolatey.org/en-us/troubleshooting for more assistance.

Chocolatey upgraded 0/1 packages. 1 packages failed. See the log for details (c:\opt\chocolatey\logs\chocolatey.log).

Failures

D:>