Linux Ubuntu20.04 下安装ros,及出现的roscore问题解决

快速安装ros系统:

wget http://fishros.com/install -O fishros && .fishros

//如果报错,在.fishros中间加个空格
wget http://fishros.com/install -O fishros && . fishros

sudo chmod a+x fishros

./fishros

问题:

    执行roscore命令时, 报错 

WARNING: unable to configure logging. No log files will be generated
Checking log directory for disk usage. This may take awhile.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.

Resource not found: roslaunch
The traceback for the exception was written to the log file

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/roslaunch/__init__.py", line 322, in main
    p.start()
  File "/usr/lib/python3/dist-packages/roslaunch/parent.py", line 277, in start
    self._start_infrastructure()
  File "/usr/lib/python3/dist-packages/roslaunch/parent.py", line 226, in _start_infrastructure
    self._load_config()
  File "/usr/lib/python3/dist-packages/roslaunch/parent.py", line 137, in _load_config
    self.config = roslaunch.config.load_config_default(self.roslaunch_files, self.port,
  File "/usr/lib/python3/dist-packages/roslaunch/config.py", line 447, in load_config_default
    load_roscore(loader, config, verbose=verbose)
  File "/usr/lib/python3/dist-packages/roslaunch/config.py", line 92, in load_roscore
    f_roscore = get_roscore_filename()
  File "/usr/lib/python3/dist-packages/roslaunch/config.py", line 84, in get_roscore_filename
    return os.path.join(r.get_path('roslaunch'), 'resources', 'roscore.xml')
  File "/usr/lib/python3/dist-packages/rospkg/rospack.py", line 207, in get_path
    raise ResourceNotFound(name, ros_paths=self._ros_paths)
rospkg.common.ResourceNotFound: roslaunch

解决:

  安装roslaunch

sudo apt install python3-roslaunch

  配置环境变量

echo "source /opt/ros/foxy/setup.bash" >> ~/.bashrc //ros2的foxy版本

source ~/.bashrc   //选择相应版本
echo "source /opt/ros/noetic/setup.bash" >> ~/.bashrc //ros1的noetic版本

source ~/.bashrc   //选择相应版本

测试:

  输入ros2

usage: ros2 [-h] Call `ros2 <command> -h` for more detailed usage. ...

ros2 is an extensible command-line tool for ROS 2.

optional arguments:
  -h, --help            show this help message and exit

Commands:
  action     Various action related sub-commands
  bag        Various rosbag related sub-commands
  component  Various component related sub-commands
  daemon     Various daemon related sub-commands
  doctor     Check ROS setup and other potential issues
  interface  Show information about ROS interfaces
  launch     Run a launch file
  lifecycle  Various lifecycle related sub-commands
  multicast  Various multicast related sub-commands
  node       Various node related sub-commands
  param      Various param related sub-commands
  pkg        Various package related sub-commands
  run        Run a package specific executable
  security   Various security related sub-commands
  service    Various service related sub-commands
  topic      Various topic related sub-commands
  wtf        Use `wtf` as alias to `doctor`

  输入roscore

... logging to /home/chen/.ros/log/68ed6b88-648a-11ed-a687-051feb7f109f/roslaunch-qian-50681.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://qian:36431/
ros_comm version 1.15.14


SUMMARY
========

PARAMETERS
 * /rosdistro: noetic
 * /rosversion: 1.15.14

NODES

auto-starting new master
process[master]: started with pid [50689]
ROS_MASTER_URI=http://qian:11311/

setting /run_id to 68ed6b88-648a-11ed-a687-051feb7f109f
process[rosout-1]: started with pid [50699]
started core service [/rosout]

  打开一个新终端,启动小海龟仿真器

//ros1:
rosrun turtlesim turtlesim_node

//ros2:
ros2 run turtlesim turtlesim_node

[ INFO] [1668478292.143024567]: Starting turtlesim with node name /turtlesim
[ INFO] [1668478292.154706717]: Spawning turtle [turtle1] at x=[5.544445], y=[5.544445], theta=[0.000000]

  再次打开一个新的终端,开启控制节点,控制小海龟动起来

//ros1:
rosrun turtlesim turtle_teleop_key

//ros2:
ros2 run turtlesim turtle_teleop_key

Reading from keyboard
---------------------------
Use arrow keys to move the turtle. 'q' to quit.

//在该终端通过上下左右方向键控制小海龟运动,q退出

 

  • 2
    点赞
  • 21
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值