rosros kinetic gazeboo地图怎么添加坐标

他的最新文章
他的热门文章
您举报文章:
举报原因:
原文地址:
原因补充:
(最多只允许输入30个字)他的最新文章
他的热门文章
您举报文章:
举报原因:
原文地址:
原因补充:
(最多只允许输入30个字)ROS Control教程官方
下图概述了仿真、硬件、控制器和传输之间的关系:
(图片分 gazebo仿真 和真实硬件两部分.两者实现方式是不同的)
Add transmission elements to a URDF
To use ros_control with your robot, you need to add some additional elements to your URDF. The &transmission& element is used to link actuators to joints, see the &transmission& spec for exact XML format.
在URDF文件里添加transmission元素
使用 ros_control 必须要在urdf里添加一些可选元素&transmission&用于连杆关节的执行器,...
Add the gazebo_ros_control plugin
The default plugin XML should be added to your URDF:
默认插件xml:
&plugin name=&gazebo_ros_control& filename=&libgazebo_ros_control.so&&
&robotNamespace&/MYROBOT&/robotNamespace&
The gazebo_ros_control &plugin& tag also has the following optional child elements:
&&& &robotNamespace&: The ROS namespace to be used for this instance of the plugin, defaults to robot name in URDF/SDF名称空间
&&& &controlPeriod&: The period of the controller update (in seconds), defaults to Gazebo's period更新周期单位秒
&&& &robotParam&: The location of the robot_description (URDF) on the parameter server, defaults to '/robot_description'
&&& &robotSimType&: The pluginlib name of a custom robot sim interface to be used (see below for more details), defaults to 'DefaultRobotHWSim'默认是DefaultRobotHWSim
Default gazebo_ros_control Behavior
By default, without a &robotSimType& tag, gazebo_ros_control will attempt to get all of the information it needs to interface with a ros_control-based controller out of the URDF. This is sufficient for most cases, and good for at least getting started.
The default behavior provides the following ros_control interfaces:
默认情况下提供了下面的控制接口:
&&& hardware_interface::JointStateInterface
&&& hardware_interface::EffortJointInterface
&&& hardware_interface::VelocityJointInterface - not fully implemented
Advanced: custom gazebo_ros_control Simulation Plugins
高级:自定义gazebo_ros_control仿真插件
The gazebo_ros_control Gazebo plugin also provides a pluginlib-based interface to implement custom interfaces between Gazebo and ros_control for simulating more complex mechanisms (nonlinear springs, linkages, etc).
提供基础库接口实现自定义接口
These plugins must inherit gazebo_ros_control::RobotHWSim which implements a simulated ros_control hardware_interface::RobotHW. RobotHWSim provides API-level access to read and command joint properties in the Gazebo simulator.
自定义插件必须继承自gazebo_ros_control::RobotHWSim实现了模拟ros_control hardware_interface::RobotHW...
The respective RobotHWSim sub-class is specified in a URDF model and is loaded when the robot model is loaded. For example, the following XML will load the default plugin (same behavior as when using no &robotSimType& tag):
自己的RobotHWSim子类在urdf里定义.模型加载完子类也被加载.
&plugin name=&gazebo_ros_control& filename=&libgazebo_ros_control.so&&
&robotNamespace&/MYROBOT&/robotNamespace&
&robotSimType&gazebo_ros_control/DefaultRobotHWSim&/robotSimType&&!-- gazebo_ros_control/DefaultRobotHWSim 可以改成自定义的子类 --&
自己的配置gazebo.urdf.xacro
&?xml version=&1.0&?&
&plugin name=&gazebo_ros_control& filename=&libgazebo_ros_control.so&&
&robotNamespace&/zzz_arm&/robotNamespace&
&!--&robotSimType&gazebo_ros_control/DefaultRobotHWSim&/robotSimType&
使用默认配置手臂轨迹会执行,但抓手抓取会失败
&robotSimType&rosbook_arm_hardware_gazebo/ROSBookArmHardwareGazebo&/robotSimType&
&!--使用一个教程中的自定义插件后抓取放置执行成功,源码见下--&
&controlPeriod&0.001&/controlPeriod&
使用默认配置失败信息输出
attaching world object 'coke_can' to link 'grasping_frame'
attached object 'coke_can' to link 'grasping_frame'
Found successful manipution plan!
warn controller handle zzz_arm/fakegazebo_grapper_controller reports status RUNNING
pick up goal failed :Solution found but controller failed during execution.
transmission
&robot xmlns:xacro=&http://ros.org/wiki/xacro&&
&xacro:macro name=&arm_simple_transmission& params=&name reduction&&
&transmission name=&${name}_transmission&&
&type&transmission_interface/SimpleTransmission&/type&
&actuator name=&${name}_motor&&
&mechanicalReduction&${reduction}&/mechanicalReduction&
&hardwareInterface&hardware_interface/PositionJointInterface&/hardwareInterface&
&/actuator&
&joint name=&${name}_joint&&
&hardwareInterface&hardware_interface/PositionJointInterface&/hardwareInterface&
&/transmission&
&/xacro:macro&
gazebo 使用的参数配置文件:
joint_trajectory_controllers.yaml
fakegazebo_arm_controller:
type: position_controllers/JointTrajectoryController
- shoulder_zhuan_joint
- upper_arm_joint
- fore_arm_joint
- hand_wan_joint
- hand_zhuan_joint
constraints:
goal_time: &goal_time_constraint 10.0
shoulder_zhuan_joint:
goal: &goal_pos_constraint 0.5
upper_arm_joint:
goal: *goal_pos_constraint
fore_arm_joint:
goal: *goal_pos_constraint
hand_wan_joint:
goal: *goal_pos_constraint
hand_zhuan_joint:
goal: *goal_pos_constraint
shoulder_zhuan_joint:
{p: 1000.0, i: 0.0, d: 0.1, i_clamp: 0.0}
upper_arm_joint:
{p: 1000.0, i: 0.0, d: 0.1, i_clamp: 0.0}
fore_arm_joint:
{p: 1000.0, i: 0.0, d: 0.1, i_clamp: 0.0}
hand_wan_joint:
{p: 1000.0, i: 0.0, d: 0.1, i_clamp: 0.0}
hand_zhuan_joint:
{p: 1000.0, i: 0.0, d: 0.1, i_clamp: 0.0}
fakegazebo_grapper_controller:
type: position_controllers/JointTrajectoryController
- finger_1_joint
- finger_2_joint
constraints:
goal_time: *goal_time_constraint
finger_1_joint:
goal: *goal_pos_constraint
finger_2_joint:
goal: *goal_pos_constraint
finger_1_joint:
{p: 50.0, d: 1.0, i: 0.01, i_clamp: 1.0}
finger_2_joint:
{p: 50.0, d: 1.0, i: 0.01, i_clamp: 1.0}
# Publish all joint states -----------------------------------
joint_state_controller:
type: joint_state_controller/JointStateController
publish_rate: 50
moveit使用的参数配置文件:
fakegazebo_controllers.yaml
controller_manager_ns: controller_manager
controller_list:
- name: zzz_arm/fakegazebo_arm_controller
action_ns: follow_joint_trajectory
type: FollowJointTrajectory
default: true
- shoulder_zhuan_joint
- upper_arm_joint
- fore_arm_joint
- hand_wan_joint
- hand_zhuan_joint
- name: zzz_arm/fakegazebo_grapper_controller
action_ns: follow_joint_trajectory
type: FollowJointTrajectory
default: true
- finger_1_joint
- finger_2_joint
rosbook_arm_hardware_gazebo/ROSBookArmHardwareGazebo插件源码
rosbook_arm_hardware_gazebo.cpp
#include &angles/angles.h&
#include &urdf_parser/urdf_parser.h&
#include &joint_limits_interface/joint_limits_urdf.h&
#include &joint_limits_interface/joint_limits_rosparam.h&
#include &pluginlib/class_list_macros.h&
#include &rosbook_arm_hardware_gazebo/rosbook_arm_hardware_gazebo.h&
namespace rosbook_arm_hardware_gazebo
using namespace hardware_
ROSBookArmHardwareGazebo::ROSBookArmHardwareGazebo()
: gazebo_ros_control::RobotHWSim()
bool ROSBookArmHardwareGazebo::initSim(const std::string& robot_namespace,
ros::NodeHandle nh,
gazebo::physics::ModelPtr model,
const urdf::Model* const urdf_model,
std::vector&transmission_interface::TransmissionInfo& transmissions)
using gazebo::physics::JointP
// Cleanup
sim_joints_.clear();
jnt_pos_.clear();
jnt_vel_.clear();
jnt_eff_.clear();
jnt_pos_cmd_.clear();
// Simulation joints
sim_joints_ = model-&GetJoints();
n_dof_ = sim_joints_.size();
std::vector&std::string& jnt_
for (size_t i = 0; i & n_dof_; ++i)
jnt_names.push_back(sim_joints_[i]-&GetName());
// Raw data
jnt_pos_.resize(n_dof_);
jnt_vel_.resize(n_dof_);
jnt_eff_.resize(n_dof_);
jnt_pos_cmd_.resize(n_dof_);
// Hardware interfaces
for (size_t i = 0; i & n_dof_; ++i)
jnt_state_interface_.registerHandle(
JointStateHandle(jnt_names[i], &jnt_pos_[i], &jnt_vel_[i], &jnt_eff_[i]));
jnt_pos_cmd_interface_.registerHandle(
JointHandle(jnt_state_interface_.getHandle(jnt_names[i]), &jnt_pos_cmd_[i]));
ROS_DEBUG_STREAM(&Registered joint '& && jnt_names[i] && &' in the PositionJointInterface.&);
registerInterface(&jnt_state_interface_);
registerInterface(&jnt_pos_cmd_interface_);
// Position joint limits interface
std::vector&std::string& cmd_handle_names = jnt_pos_cmd_interface_.getNames();
for (size_t i = 0; i & n_dof_; ++i)
const std::string name = cmd_handle_names[i];
JointHandle cmd_handle = jnt_pos_cmd_interface_.getHandle(name);
using namespace joint_limits_
boost::shared_ptr&const urdf::Joint& urdf_joint = urdf_model-&getJoint(name);
SoftJointLimits soft_
if (!getJointLimits(urdf_joint, limits) || !getSoftJointLimits(urdf_joint, soft_limits))
ROS_WARN_STREAM(&Joint limits won't be enforced for joint '& && name && &'.&);
jnt_limits_interface_.registerHandle(
PositionJointSoftLimitsHandle(cmd_handle, limits, soft_limits));
ROS_DEBUG_STREAM(&Joint limits will be enforced for joint '& && name && &'.&);
// PID controllers
pids_.resize(n_dof_);
for (size_t i = 0; i & n_dof_; ++i)
ros::NodeHandle joint_nh(nh, &gains/& + jnt_names[i]);
if (!pids_[i].init(joint_nh))
void ROSBookArmHardwareGazebo::readSim(ros::Time time, ros::Duration period)
for (size_t i = 0; i & n_dof_; ++i)
jnt_pos_[i] += angles::shortest_angular_distance
(jnt_pos_[i], sim_joints_[i]-&GetAngle(0u).Radian());
jnt_vel_[i] = sim_joints_[i]-&GetVelocity(0u);
jnt_eff_[i] = sim_joints_[i]-&GetForce(0u);
void ROSBookArmHardwareGazebo::writeSim(ros::Time time, ros::Duration period)
// Enforce joint limits
jnt_limits_interface_.enforceLimits(period);
// Compute and send commands
for (size_t i = 0; i & n_dof_; ++i)
const double error = jnt_pos_cmd_[i] - jnt_pos_[i];
const double effort = pids_[i].computeCommand(error, period);
sim_joints_[i]-&SetForce(0u, effort);
} // namespace rosbook_hardware_gazebo
PLUGINLIB_EXPORT_CLASS(rosbook_arm_hardware_gazebo::ROSBookArmHardwareGazebo, gazebo_ros_control::RobotHWSim)
Robot Hardware Interface and Resource Manager.
This class provides a standardized interface to a set of robot hardware interfaces to the controller manager. It performs resource conflict checking for a given set of controllers and maintains a map of hardware interfaces. It is meant to be used as a base
class for abstracting custom robot hardware.
机器人硬件接口与资源管理器。
这个类为控制器管理器提供了一组机器人硬件接口的标准化接口。它对给定的控制器集执行资源冲突检查,并维护硬件接口映射。它将被用作抽象自定义机器人硬件的基类。
gazebo仿真抓取时,抓不起来或者很容易滑落的问题.
如图夹住的物体不断下滑甚至掉落.
想必是跟摩擦有关
官方 小车轮子对地摩擦的一个例子
Since the wheels are actually going to touch the ground and thus interact with it physically, we also specify some additional information about the material of the wheels.
当轮子转动,轮子对地就会有一个物理的交互.我们也要指定一些轮子材质的相关信息.
材质信息包含摩擦信息示例如下
&gazebo reference=&${prefix}_${suffix}_wheel&&
&mu1 value=&200.0&/&
&mu2 value=&100.0&/&
&kp value=&& /&
&kd value=&1.0& /&
&material&Gazebo/Grey&/material&
for more details.
&gazebo& Elements For Links
List of elements that are individually parsed:
Description
Material of visual element
Use gravity
dampingFactor
Exponential velocity decay of the link velocity - takes the value and multiplies the previous link velocity by (1-dampingFactor).
maximum contact correction velocity truncation term.
minimum allowable depth before contact correction impulse is applied
Friction coefficients μ for the principal contact directions along the contact surface as defined by the (see parameter descriptions in)
3-tuple specifying direction of mu1 in the collision local reference frame.
Contact stiffness k_p and damping k_d for rigid body contacts as defined by ODE ( but there is a)
selfCollide
If true, the link can collide with other links in the model.
maxContacts
Maximum number of contacts allowed between two entities. This value overrides the max_contacts element defined in physics.
laserRetro
intensity value returned by laser sensor.
Similar to &gazebo& elements for
&robot&, any arbitrary blobs that are not parsed according to the table above are inserted into the the corresponding&link& element in the SDF. This is particularly useful for plugins, as discussed in the tutorial.
Friction coefficients μ for the principal contact directions along the contact surface as defined by the Open Dynamics Engine (ODE) (see parameter descriptions in ODE's user
由ODE定义的接触面的主要接触方向上的摩擦系数μ
Contact stiffness k_p and damping k_d for rigid body contacts as defined by ODE (ODE uses erp and cfm but there is a mapping between erp/cfm and stiffness/damping)
由ODE定义的刚体接触的接触强度k_p和阻尼k_d (ODE使用 erp和cfm ,erp/cfm 和 stiffness/damping之间是有映射关系的)
什么是ODE?
Introduction
The Open Dynamics Engine (ODE) is a free, industrial quality library for simulating articulated rigid body dynamics. Proven applications include simulating ground vehicles, legged creatures, and moving objects in VR environments. It is fast, flexible and robust,
and has built-in collision detection. ODE is being developed by Russell Smith() with help from several contributors.(http://ode.org/)
......似乎要跑题
转回来修改设置
urdf 内抓手材质的设置
&gazebo reference=&finger_1_link&&
&mu1&2000.0&/mu1&
&mu2&1000.0&/mu2&
&kd&1.0&/kd&
&gazebo reference=&finger_2_link&&
&mu1&2000.0&/mu1&
&mu2&1000.0&/mu2&
&kd&1.0&/kd&
仿真环境中物体以及被抓物体的材质设置
grasp.world
&?xml version='1.0' ?&
&sdf version='1.4'&
&world name='empty'&
&!-- A global light source --&
&uri&model://sun&/uri&
&/include&
&!-- A ground plane --&
&uri&model://ground_plane&/uri&
&/include&
&uri&model://file:///home/myrobot1/src/zzz_arm_2_gazebo/model/beer/model.sdf&/uri&
&/include&
&!-- Physics settings for simulation --&
&physics type='ode'&
&max_step_size&0.001&/max_step_size&
&real_time_factor&1&/real_time_factor&
&real_time_update_rate&1000&/real_time_update_rate&
&gravity&0 0 -9.81&/gravity&
&/physics&
&model name='coke_can_box_model'&
&pose frame=''&0.175 0.0 0. 0&/pose&
&link name='coke_can'&
&inertial&
&mass&0.001&/mass&
&ixx&0.00016&/ixx&
&ixy&0&/ixy&
&ixz&0&/ixz&
&iyy&0.00016&/iyy&
&iyz&0&/iyz&
&izz&0.00006&/izz&
&/inertia&
&/inertial&
&collision name='collision'&
&geometry&
&!--cylinder&
&radius&0.0075&/radius&
&length&.05&/length&
&/cylinder--&
&size&0.015 0.015 0.05&/size&
&uri&model://coke_can/meshes/coke_can.dae&/uri&
&scale&0.095 0.095 0.18&/scale&
&/geometry&
&max_contacts&10&/max_contacts&
&friction&
&mu&100.0&/mu&
&mu2&100.0&/mu2&
&/friction&
&kd&1.0&/kd&
&min_depth&0.001&/min_depth&
&max_vel&0.1&/max_vel&
&/contact&
&/surface&
&/collision&
&visual name='visual'&
&geometry&
&!--cylinder&
&radius&0.0075&/radius&
&length&.05&/length&
&/cylinder--&
&size&0.015 0.015 0.05&/size&
&uri&model://coke_can/meshes/coke_can.dae&/uri&
&scale&0.095 0.095 0.18&/scale&
&/geometry&
&material&
&name&Gazebo/Green&/name&
&uri&file://media/materials/scripts/gazebo.material&/uri&
&/material&
&self_collide&0&/self_collide&
&kinematic&0&/kinematic&
&model name='table_box_model'&
&static&true&/static&
&pose frame=''&0.15 0.0 0.1 0 -0 1.&/pose&
&link name='table_box_link'&
&inertial&
&mass&1&/mass&
&ixx&0.166667&/ixx&
&ixy&0&/ixy&
&ixz&0&/ixz&
&iyy&0.166667&/iyy&
&iyz&0&/iyz&
&izz&0.166667&/izz&
&/inertia&
&/inertial&
&collision name='collision'&
&geometry&
&size&0.15 0.08 0.2&/size&
&/geometry&
&max_contacts&10&/max_contacts&
&/contact&
&friction&
&mu&0.6&/mu&
&mu2&0.6&/mu2&
&torsional&
&/torsional&
&/friction&
&/surface&
&/collision&
&visual name='visual'&
&geometry&
&size&0.15 0.08 0.2&/size&
&/geometry&
&material&
&name&Gazebo/Grey&/name&
&uri&file://media/materials/scripts/gazebo.material&/uri&
&/material&
&self_collide&0&/self_collide&
&kinematic&0&/kinematic&
gazebo 仿真尝试抓取圆柱体,立方体,和mesh可乐罐
经测试,在同样的设置下圆柱最容易滑落,立方体次之.可乐罐最不容易掉落.
&gazebo与ros_control学习 (1) &
&ROS& Gazebo Ros Control 及 Controller运用
学习机械臂的一些文章
Gazebo与ros_control(1):让模型动起来
Gazebo与ros_control(2):七自由度机械臂和两轮差速运动小车
Gazebo与ros_control(3):Moveit输出规划轨迹到Gazebo
Gazebo与ros_control(4):举一反三,实战youBot
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:6289次
排名:千里之外
原创:33篇
(4)(2)(5)(3)(5)(16)(4)First step with gazebo and ros
o setup a ROS workspace
o create projects for your simulated robot
o create a Gazebo world
o create your own robot model
o connect your robot model to ROS
o use a teleoperation node to control your robot
o add a camera to your robot
o use Rviz to vizualize all the robot information
Setup a new workspace
mkdir -p ~/catkin_ws/src
cd ~/catkin_ws/src
catkin_init_workspace
catkin_make
source ~/catkin_ws/devel/setup.bash
Create projects for your simulated robot
cd ~/catkin_ws/src
catkin_create_pkg mybot_gazebo gazebo_ros
catkin_create_pkg mybot_description
catkin_create_pkg mybot_control
Creating your own World
roscd mybot_gazebo
mkdir launch worlds
vim mybot.world
A basic world file defines at least a name:
&?xml version=&1.0&?&
&sdf version=&1.4&&
&world name=&myworld&&
At first we just want to add some basic objects, like a ground and a basic illumination source inside the world tag.
&uri&model://sun&/uri&
&/include&
&uri&model://ground_plane&/uri&
&/include&
&uri&model://turtlebot&/uri&
&/include&
roscd mybot_gazebo/launch
vim mybot_world.launch
mybot_world.launch
&include file=&$(find gazebo_ros)/launch/empty_world.launch&&
&arg name=&world_name& value=&$(find mybot_gazebo)/worlds/mybot.world&/&
&arg name=&gui& value=&true&/&
&/include&
make a test
roslaunch mybot_gazebo mybot_world.launch
Creating your own Model
roscd mybot_description
mkdir urdf
gedit mybot.xacro
XACRO CONCEPTS
o xacro:include: Import the content from other file. We can divide the content in different xacros and merge them using xacro:include.
o property: Useful to define constant values. Use it later using ${property_name}
o xacro:macro: Macro with variable values. Later, we can use this macro from another xacro file, and we specify the required value for the variables. To use a macro, you have to include the file where the macro is, and call it using the macro's name and filling
the required values.
mybot.xacro
This file will be the main description of our robot. Let's put some xacro basic structure:
&?xml version=&1.0&?&
&robot name=&mybot& xmlns:xacro=&http://www.ros.org/wiki/xacro&&
&!-- Put here the robot description --&
Let's define some physical properties for our robot, mainly the dimensions of the chassis, the caster wheel, the wheels and the camera:
&xacro:property name=&PI& value=&3.7931&/&
&xacro:property name=&chassisHeight& value=&0.1&/&
&xacro:property name=&chassisLength& value=&0.4&/&
&xacro:property name=&chassisWidth& value=&0.2&/&
&xacro:property name=&chassisMass& value=&50&/&
&xacro:property name=&casterRadius& value=&0.05&/&
&xacro:property name=&casterMass& value=&5&/&
&xacro:property name=&wheelWidth& value=&0.05&/&
&xacro:property name=&wheelRadius& value=&0.1&/&
&xacro:property name=&wheelPos& value=&0.2&/&
&xacro:property name=&wheelMass& value=&5&/&
&xacro:property name=&cameraSize& value=&0.05&/&
&xacro:property name=&cameraMass& value=&0.1&/&
We will also include three files :
&xacro:include filename=&$(find mybot_description)/urdf/mybot.gazebo& /&
&xacro:include filename=&$(find mybot_description)/urdf/materials.xacro& /&
&xacro:include filename=&$(find mybot_description)/urdf/macros.xacro& /&
These three correspond respectively to:
o all the gazebo-specific aspects of our robot
o definition of the materials used (mostly colors)
o definitions of some macros for easier description of the robot
Add it to mybot.xacro
&link name='chassis'&
&collision&
&origin xyz=&0 0 ${wheelRadius}& rpy=&0 0 0&/&
&geometry&
&box size=&${chassisLength} ${chassisWidth} ${chassisHeight}&/&
&/geometry&
&/collision&
&origin xyz=&0 0 ${wheelRadius}& rpy=&0 0 0&/&
&geometry&
&box size=&${chassisLength} ${chassisWidth} ${chassisHeight}&/&
&/geometry&
&material name=&orange&/&
&inertial&
&origin xyz=&0 0 ${wheelRadius}& rpy=&0 0 0&/&
&mass value=&${chassisMass}&/&
&box_inertia m=&${chassisMass}& x=&${chassisLength}& y=&${chassisWidth}& z=&${chassisHeight}&/&
&/inertial&
Add it to mybot.gazebo
&gazebo reference=&chassis&&
&material&Gazebo/Orange&/material&
Add this in the “materials.xacro” :
&?xml version=&1.0&?&
&material name=&black&&
&color rgba=&0.0 0.0 0.0 1.0&/&
&/material&
&material name=&blue&&
&color rgba=&0.0 0.0 0.8 1.0&/&
&/material&
&material name=&green&&
&color rgba=&0.0 0.8 0.0 1.0&/&
&/material&
&material name=&grey&&
&color rgba=&0.2 0.2 0.2 1.0&/&
&/material&
&material name=&orange&&
&color rgba=&${255/255} ${108/255} ${10/255} 1.0&/&
&/material&
&material name=&brown&&
&color rgba=&${222/255} ${207/255} ${195/255} 1.0&/&
&/material&
&material name=&red&&
&color rgba=&0.8 0.0 0.0 1.0&/&
&/material&
&material name=&white&&
&color rgba=&1.0 1.0 1.0 1.0&/&
&/material&
Add this in the macros.xacro file, within the robot tag
&?xml version=&1.0& ?&
&robot name=&mybot& xmlns:xacro=&http://www.ros.org/wiki/xacro&&
&macro name=&cylinder_inertia& params=&m r h&&
ixx=&${m*(3*r*r+h*h)/12}& ixy = &0& ixz = &0&
iyy=&${m*(3*r*r+h*h)/12}& iyz = &0&
izz=&${m*r*r/2}&
&macro name=&box_inertia& params=&m x y z&&
ixx=&${m*(y*y+z*z)/12}& ixy = &0& ixz = &0&
iyy=&${m*(x*x+z*z)/12}& iyz = &0&
izz=&${m*(x*x+z*z)/12}&
&macro name=&sphere_inertia& params=&m r&&
ixx=&${2*m*r*r/5}& ixy = &0& ixz = &0&
iyy=&${2*m*r*r/5}& iyz = &0&
izz=&${2*m*r*r/5}&
Add this before the chassis link in the mybot.xacro file :
&link name=&footprint& /&
&joint name=&base_joint& type=&fixed&&
&parent link=&footprint&/&
&child link=&chassis&/&
mybot_world.launch by adding the following two tags in the launch tag:
&!-- urdf xml robot description loaded on the Parameter Server, converting the xacro into a proper urdf file--&
&param name=&robot_description& command=&$(find xacro)/xacro.py '$(find mybot_description)/urdf/mybot.xacro'& /&
&!-- push robot_description to factory and spawn robot in gazebo --&
&node name=&mybot_spawn& pkg=&gazebo_ros& type=&spawn_model& output=&screen&
args=&-urdf -param robot_description -model mybot& /&
make a test
roslaunch mybot_gazebo mybot_world.launch
mybot.xacro As a next step we add a caster wheel to the robot. This is the simplest wheel as we have no axis and no friction
&joint name=&fixed& type=&fixed&&
&parent link=&chassis&/&
&child link=&caster_wheel&/&
&link name=&caster_wheel&&
&collision&
&origin xyz=&${casterRadius-chassisLength/2} 0 ${casterRadius-chassisHeight+wheelRadius}& rpy=&0 0 0&/&
&geometry&
&sphere radius=&${casterRadius}&/&
&/geometry&
&/collision&
&origin xyz=&${casterRadius-chassisLength/2} 0 ${casterRadius-chassisHeight+wheelRadius}& rpy=&0 0 0&/&
&geometry&
&sphere radius=&${casterRadius}&/&
&/geometry&
&material name=&red&/&
&inertial&
&origin xyz=&${casterRadius-chassisLength/2} 0 ${casterRadius-chassisHeight+wheelRadius}& rpy=&0 0 0&/&
&mass value=&${casterMass}&/&
&sphere_inertia m=&${casterMass}& r=&${casterRadius}&/&
&/inertial&
mybot.gazebo Add a gazebo tag in the gazebo file for this link :
&gazebo reference=&caster_wheel&&
&mu1&0.0&/mu1&
&mu2&0.0&/mu2&
&material&Gazebo/Red&/material&
As usual, we specify the color used in material. We also added mu1 and mu2, with value 0 to remove the friction.
macros.xacro .We could add the two links in the main file, but let's make one macro to make it simple.
&macro name=&wheel& params=&lr tY&&
&link name=&${lr}_wheel&&
&collision&
&origin xyz=&0 0 0& rpy=&0 ${PI/2} ${PI/2}& /&
&geometry&
&cylinder length=&${wheelWidth}& radius=&${wheelRadius}&/&
&/geometry&
&/collision&
&origin xyz=&0 0 0& rpy=&0 ${PI/2} ${PI/2}& /&
&geometry&
&cylinder length=&${wheelWidth}& radius=&${wheelRadius}&/&
&/geometry&
&material name=&black&/&
&inertial&
&origin xyz=&0 0 0& rpy=&0 ${PI/2} ${PI/2}& /&
&mass value=&${wheelMass}&/&
&cylinder_inertia m=&${wheelMass}& r=&${wheelRadius}& h=&${wheelWidth}&/&
&/inertial&
&gazebo reference=&${lr}_wheel&&
&mu1 value=&1.0&/&
&mu2 value=&1.0&/&
value=&& /&
value=&1.0& /&
&fdir1 value=&1 0 0&/&
&material&Gazebo/Black&/material&
&joint name=&${lr}_wheel_hinge& type=&continuous&&
&parent link=&chassis&/&
&child link=&${lr}_wheel&/&
&origin xyz=&${-wheelPos+chassisLength/2} ${tY*wheelWidth/2+tY*chassisWidth/2} ${wheelRadius}& rpy=&0 0 0& /&
&axis xyz=&0 1 0& rpy=&0 0 0& /&
&limit effort=&100& velocity=&100&/&
&joint_properties damping=&0.0& friction=&0.0&/&
&transmission name=&${lr}_trans&&
&type&transmission_interface/SimpleTransmission&/type&
&joint name=&${lr}_wheel_hinge&&
&hardwareInterface&EffortJointInterface&/hardwareInterface&
&actuator name=&${lr}Motor&&
&hardwareInterface&EffortJointInterface&/hardwareInterface&
&mechanicalReduction&10&/mechanicalReduction&
&/actuator&
&/transmission&
mybot.xacro
&wheel lr=&left& tY=&1&/&
&wheel lr=&right& tY=&-1&/&
Connect your robot to ROS
Alright, our robot is all nice and has this new car smell, but we can't do anything with it yet as it has no connection with
ROS In order to add this connection we need to add gazebeo plugins to our model. There are different kinds of plugins:
World: Dynamic changes to the world, e.g. Physics, like illumination or gravity, inserting models
Model: Manipulation of models (robots), e.g. move the robots
Sensor: Feedback from virtual sensor, like camera, laser scanner
System: Plugins that are loaded by the GUI, like saving images
First of all we'll use a plugin to provide access to the joints of the wheels. The transmission tags in our URDF will be used by this plugin the define how to link the joints to controllers. To activate the plugin, add the following to mybot.gazebo:
&plugin name=&gazebo_ros_control& filename=&libgazebo_ros_control.so&&
&robotNamespace&/mybot&/robotNamespace&
With this plugin, we will be able to control the joints, however we need to provide some extra configuration and explicitely
start controllers for the joints. In order to do so, we'll use the package mybot_control that we have defined before. Let's first create the configuration file:
roscd mybot_control
mkdir config
vim mybot_control.yaml
This file will define three controllers: one for each wheel, connections to the joint by the transmission tag, one for
publishing the joint states. It also defined the PID gains to use for this controller:
# Publish all joint states -----------------------------------
joint_state_controller:
type: joint_state_controller/JointStateController
publish_rate: 50
# Effort Controllers ---------------------------------------
leftWheel_effort_controller:
type: effort_controllers/JointEffortController
joint: left_wheel_hinge
pid: {p: 100.0, i: 0.1, d: 10.0}
rightWheel_effort_controller:
type: effort_controllers/JointEffortController
joint: right_wheel_hinge
pid: {p: 100.0, i: 0.1, d: 10.0}
Now we need to create a launch file to start the controllers. For this let's do:
roscd mybot_control
mkdir launch
vim mybot_control.launch
In this file we'll put two things. First we'll load the configuration and the controllers, and we'll also start a node that will
provide 3D transforms (tf) of our robot. This is not mandatory but that makes the simulation more complete
&!-- Load joint controller configurations from YAML file to parameter server --&
&rosparam file=&$(find mybot_control)/config/mybot_control.yaml& command=&load&/&
&!-- load the controllers --&
&node name=&controller_spawner&
pkg=&controller_manager&
type=&spawner& respawn=&false&
output=&screen& ns=&/mybot&
args=&joint_state_controller
rightWheel_effort_controller
leftWheel_effort_controller&/&
&!-- convert joint states to TF transforms for rviz, etc --&
&node name=&robot_state_publisher& pkg=&robot_state_publisher& type=&robot_state_publisher& respawn=&false& output=&screen&&
&param name=&robot_description& command=&$(find xacro)/xacro.py '$(find mybot_description)/urdf/mybot.xacro'& /&
&remap from=&/joint_states& to=&/mybot/joint_states& /&
make a test
roslaunch mybot_gazebo mybot_world.launch
roslaunch mybot_control mybot.launch
rostopic list
We could launch our model on gazebo and then launch the controller, but to save some time (and terminals), we'll start the controllers automatically by adding a line to the mybot_world.launch in the mybot_gazebo package :
&!-- ros_control mybot launch file --&
&include file=&$(find mybot_control)/launch/mybot_control.launch& /&
rostopic pub -1 /mybot/leftWheel_effort_controller/command std_msgs/Float64 &data: 1.5&
rostopic pub -1 /mybot/rightWheel_effort_controller/command std_msgs/Float64 &data: 1.0&
rostopic echo /mybot/joint_states
Teleoperation of your robot
Adding a camera
&joint name=&camera_joint& type=&fixed&&
&axis xyz=&0 1 0& /&
&origin xyz=&0 0 0.2& rpy=&0 0 0&/&
&parent link=&footprint&/&
&child link=&camera&/&
&link name=&camera&&
&collision&
&origin xyz=&0 0 0& rpy=&0 0 0&/&
&geometry&
&box size=&${cameraSize} ${cameraSize} ${cameraSize}&/&
&/geometry&
&/collision&
&origin xyz=&0 0 0& rpy=&0 0 0&/&
&geometry&
&box size=&${cameraSize} ${cameraSize} ${cameraSize}&/&
&/geometry&
&material name=&blue&/&
&inertial&
&mass value=&${cameraMass}& /&
&origin xyz=&0 0 0& rpy=&0 0 0&/&
&box_inertia m=&${cameraMass}& x=&${cameraSize}& y=&${cameraSize}& z=&${cameraSize}& /&
&/inertial&
Add the plugin to gazebo file
&gazebo reference=&camera&&
&material&Gazebo/Blue&/material&
&sensor type=&camera& name=&camera1&&
&update_rate&30.0&/update_rate&
&camera name=&head&&
&horizontal_fov&1.3962634&/horizontal_fov&
&width&800&/width&
&height&800&/height&
&format&R8G8B8&/format&
&near&0.02&/near&
&far&300&/far&
&plugin name=&camera_controller& filename=&libgazebo_ros_camera.so&&
&alwaysOn&true&/alwaysOn&
&updateRate&0.0&/updateRate&
&cameraName&mybot/camera1&/cameraName&
&imageTopicName&image_raw&/imageTopicName&
&cameraInfoTopicName&camera_info&/cameraInfoTopicName&
&frameName&camera_link&/frameName&
&hackBaseline&0.07&/hackBaseline&
&distortionK1&0.0&/distortionK1&
&distortionK2&0.0&/distortionK2&
&distortionK3&0.0&/distortionK3&
&distortionT1&0.0&/distortionT1&
&distortionT2&0.0&/distortionT2&
rosrun image_view image_view image:=/mybot/camera1/image_raw
Visualisation with RViz
rosrun rviz rviz
整个代码框架如下:
阅读(...) 评论()}

我要回帖

更多关于 ros indigo安装gazebo 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信