资源简介
ros机器人小车,加载urdf示例程序
在机器人操作系统(ROS)中,经常需要模拟机器人运动,那么首先需要新建一个机器人。
创建简单的机器人模型的步骤如下:
(1)创建硬件描述包
(2)建立urdf文件
(3)建立launch命令文件
(4)效果演示
代码片段和文件信息
# -*- coding: utf-8 -*-
from __future__ import print_function
import argparse
import os
import stat
import sys
# find the import for catkin‘s python package - either from source space or from an installed underlay
if os.path.exists(os.path.join(‘/opt/ros/indigo/share/catkin/cmake‘ ‘catkinConfig.cmake.in‘)):
sys.path.insert(0 os.path.join(‘/opt/ros/indigo/share/catkin/cmake‘ ‘..‘ ‘python‘))
try:
from catkin.environment_cache import generate_environment_script
except ImportError:
# search for catkin package in all workspaces and prepend to path
for workspace in “/opt/ros/indigo“.split(‘;‘):
python_path = os.path.join(workspace ‘lib/python2.7/dist-packages‘)
if os.path.isdir(os.path.join(python_path ‘catkin‘)):
sys.path.insert(0 python_path)
break
from catkin.environment_cache import generate_environment_script
code = generate_environment_script(‘/home/rootroot/smartcar_description/devel/env.sh‘)
output_filename = ‘/home/rootroot/smartcar_description/build/catkin_generated/setup_cached.sh‘
with open(output_filename ‘w‘) as f:
#print(‘Generate script for cached setup “%s“‘ % output_filename)
f.write(‘\n‘.join(code))
mode = os.stat(output_filename).st_mode
os.chmod(output_filename mode | stat.S_IXUSR)
评论
共有 条评论