UR机械臂控制2--熟悉头文件和例程熟悉功能

C++通讯控制UR机械臂,大神给我拷了很多C++控制UR机械臂的例程,在补全例程依赖的头文件和库使,涉及了两个库:boost和rtde

1、RTDE

Real-Time Data Exchange (RTDE) interface

https://sdurobotics.gitlab.io/ur_rtde/installation/installation.html

 

大神给我拷了直接可调用的RTDE接口库,原来是UR机械臂官网自带的通讯接口库 。

 

2、例程分析:

2.1

有一个movej路径与blend(“混合、融合”)的cpp例程

 

2.2move异步cpp,与move路径异步cpp,两个例程的区别(都用了movej):

2.2.1什么是异步运动?Move asynchronously

若异步为true,则运动可以被stopL或stopJ等中断指令中止。若异步为false(即不异步,默认不异步)

 

例子(例子中true参数为异步布尔变量bool async的值,在类RTDEControlInterface类及其对象有成员函数moveL):

moveL(target, 0.25, 0.5, true)

被调用头文件中 moveL的说明:

/**
* @brief Move to position (linear in tool-space)
* @param pose target pose
* @param speed tool speed [m/s]
* @param acceleration tool acceleration [m/s^2]
* @param async a bool specifying if the move command should be asynchronous. If async is true it is possible to
* stop a move command using either the stopJ or stopL function. Default is false, this means the function will
* block until the movement has completed.
*/

RTDE_EXPORT bool moveL(const std::vector<double> &pose, double speed = 0.25, double acceleration = 1.2,
bool async = false);

 

 

 2.2.2休眠

(1)std::this_thread::sleep_for

std::this_thread::sleep_for函数是C11的休眠函数,表示当前线程休眠一段时间,休眠期间不与其他线程竞争CPU,根据线程需求,等待若干时间。

由于是一个跨平台的函数,因此在代码中大量应用,避免了在不同平台之间所以通过宏定义编译问题。在windows下,可以简单替代Sleep, 在Linux下,替代usleep

头文件定义:#include <thread>

调用例子: std::this_thread::sleep_for(std::chrono::milliseconds(50));//睡眠50毫秒

(2)延申boost sleep_for

基本作用跟std::this_thread::sleep_for是一样的

头文件定义:#include <boost/thread.hpp>

调用例子:boost::this_thread::sleep_for(boost::chrono::milliseconds(1000));//延时1秒

2.3头文件学习

头文件rtde_control_interface.h中类RTDEControlInterface的各成员函数学习(*重中之重,复习用的问答*)

2.3.1问:以恒定速度,在末端在末端空间,以线性或曲率圆运动到指定位姿pose是什么函数?

答:moveP(std::vector<double> &pose, double )

2.3.2问:bool moveJ(const std::vector<std::vector<double>> &path, bool async = false);

中主要轴的关节最大速度和加速度和blend在哪里规定?

答:该函数用于在关节空间内线性运动到路径中指定的各组关节角位置。

路径由关节角位置组成,路径也包括路径各组关节角对应位置的速度、加速度、曲率。

2.3.3问:move系列函数必须包括各点的速度加速度,

那么bool moveL(const std::vector<std::vector<double>> &path, bool async = false);

是做什么的?各点速度加速度有没有规定?

 

答:在工具位姿空间内线性运动到路径中指定的各组工具位姿。

路径由工具位姿组成,路径也包括路径各组工具位姿对应位置的速度、加速度、曲率。

 

2.3.4问:

bool moveJ_IK(const std::vector<double> &pose, double speed = 1.05, double acceleration = 1.4,
bool async = false);

bool moveL(const std::vector<double> &pose, double speed = 0.25, double acceleration = 1.2,
bool async = false);

都是运动到一个指定的末端工具位姿,都是线性运动,有什么区别?都指定了速度加速度,有什么区别?

答:moveJ_IK在关节空间线性运动到指定位姿pose,而moveL在工具位姿空间线性运动到指定位姿pose。

前者是关节角空间内线性运动时主要轴关节角的速度加速度,后者是工具位姿空间线性运动时工具运动的速度加速度

2.3.5问:需要这种指令:机械臂运动到一组关节角位置的指定位置点,是线性运动,但需要一种在关节空间线性运动,另一种在工具笛卡尔坐标系的位姿空间线性运动,

能否提供这两种指令?

答:

RTDE_EXPORT bool moveL_FK(const std::vector<double> &q, double speed = 0.25, double acceleration = 1.2,
bool async = false);

RTDE_EXPORT bool moveJ(const std::vector<std::vector<double>> &path, bool async = false);

 

 

 

2.3.6问:ur_rtde有没有这样的指令模式:指定工具位姿空间的经过点路径(工具位姿空间的位姿作为点信息),但其中不需要设置经过点的速度加速度?

 

答:  没有。RTDE_EXPORT bool movePath(const Path &path, bool async = false);指令的类path及其中路点仍然需要速度加速度设置。

* Move to each waypoint specified in the given path

* @param path The path with waypoints

 

2.3.7 问:直接单独运行#include <ur_rtde/rtde_receive_interface.h>并绕开#include <ur_rtde/rtde_control_interface.h>可以吗?

答:不可以,编译会大量报错显示未定义

2.3.8

jog速度?; gripper夹爪;io(rtde_io_interface.h);servo伺服参数多; speed;getForwardKinematics;poseTrans;moveUntilContact(方向参数,约束检测方向?三个值在基座坐标系下的TCP方向?8个值?限制TCP运动方向?);stopScript()servoStop();addEntry添加path路点;

getAsyncOperationProgress(类似bool值,-1或0到2);

speedL和speedJ在手册里和知乎上并没有找到具体用法,所以头文件中下列相关叙述也无法理解

/**
* @brief Joint speed - Accelerate linearly in joint space and continue with constant joint speed
* @param qd joint speeds [rad/s]
* @param acceleration joint acceleration [rad/s^2] (of leading axis)
* @param time time [s] before the function returns (optional)
*/
RTDE_EXPORT bool speedJ(const std::vector<double> &qd, double acceleration = 0.5, double time = 0.0);

servoJ(const std::vector<double> &q, double speed, double acceleration, double time, double lookahead_time, double gain)

time和lookaheadTime均和控制周期无关,不影响机器人的响应延迟,也基本不影响机器人到达目标点的用时。和gain一样,二者仅影响动态过程。其中,lookaheadTime的最优值为一个控制周期。

以下实验中,控制周期均为100ms,观察周期为10ms

time:

time where the command is controlling the robot. The function is blocking for time t [S]

命令控制机器人的时间。函数阻塞时间t[S]

time越小,速度越快,实际使用中,time过小可能会产生震动,个人一般取0.1

lookahead_time

time [S], range [0.03,0.2] smoothens the trajectory with this lookahead time

time [S], range[0.03,0.2]用这个提前时间平滑轨迹

当lookaheadTime小于一个控制周期时,越小则超调量越大,该参数最优值应当为一个控制周期

proportional gain for following target position, range [100,2000]

跟踪目标位置的比例增益,范围[100,2000]

控制增益越大,到达目标位置的时间越长,超调量越小

gain

proportional gain for following target position, range [100,2000]

跟踪目标位置的比例增益,范围[100,2000]

控制增益越大,到达目标位置的时间越长,超调量越小

3、boost

PointCloudLib_x86_vc12_1_1\PointCloudLib_x86_vc12_1_1\include\boost_1_65_1\boost\bind里面的bind(捆绑装订)给我留下了印象,

 www.boost.org

提问:

1、C++标准库不是已经很全面了吗?Boost又不是界面库,它主要解决些什么问题呢?哪类问题?
2、Boost的开发人员都是C++标准委员会的吧,为什么没把它列做标准库,有什么不完善的问题吗?
3、Boost应用前景如何,现在开发用的多吗?

解答:

https://zhidao.baidu.com/question/294162274.html

一、Boost库是一个可移植、提供源代码的C++库,作为标准库的后备,是C++标准化进程的开发引擎之一。 Boost库由C++标准委员会库工作组成员发起,其中有些内容有望成为下一代C++标准库内容。在C++社区中影响甚大,是不折不扣的“准”标准库。Boost由于其对跨平台的强调,对标准C++的强调,与编写平台无关。大部分boost库功能的使用只需包括相应头文件即可,少数(如正则表达式库,文件系统库等)需要链接库。但Boost中也有很多是实验性质的东西,在实际的开发中实用需要谨慎。
二、按照实现的功能,Boost可为大致归入以下20个分类,在下面的分类中,有些库同时归入几种类别。
1. 字符串和文本处理
a) Conversion
b) Format
c) IOStream
d) Lexical Cast
e) Regex
f) Spirit
g) String Algo
h) Tokenizer
i) Wave
j) Xpressive
2. 容器
a) Array
b) Bimap
c) Circular Buffer循环缓冲区 

d) Disjoint Sets
e) Dynamic Bitset
f) GIL
g) Graph
h) ICL
i) Intrusive
j) Multi-Array
k) Multi-Index
l) Pointer Container
m) Property Map
n) Property Tree
o) Unordered
p) Variant
3. 迭代器
a) GIL
b) Graph
c) Iterators
d) Operators
e) Tokenizer
4. 算法
a) Foreach
b) GIL
c) Graph
d) Min-Max
e) Range
f) String Algo
g) Utility
5. 函数对象和高阶编程
a) Bind
b) Function
c) Functional
d) Functional/Factory
e) Functional/Forward
f) Functional/Hash
g) Lambda
h) Member Function
i) Ref
j) Result Of
k) Signals
l) Signals2
m) Utility
6. 泛型编程
a) Call Traits
b) Concept Check
c) Enable If
d) Function Types
e) GIL
f) In Place Factory, Typed In Place Factory
g) Operators
h) Property Map
i) Static Assert
j) Type Traits
7. 模板元编程
a) Function Types
b) Fusion
c) MPL
d) Proto
e) Static Assert
f) Type Traits
8. 预处理元编程
a) Preprocessors
9. 并发编程
a) Asio
b) Interprocess
c) MPI
d) Thread
10. 数学和数字
a) Accumulators蓄电池蓄能器累加器
b) Integer整数整型
c) Interval
d) Math
e) Math Common Factor
f) Math Octonion
g) Math Quaternion(四元数:是以相当紧凑的方式决定对象的旋转,且仍然具有良好的效能。所有旋转方向都是以右手为准。)
h) Math/Special Functions
i) Math/Statistical Distributions
j) Multi-Array
k) Numeric Conversion数值转换
l) Operators
m) Random
n) Rational有理数
o) uBLAS
11. 排错和测试
a) Concept Check
b) Static Assert
c) Test
12. 数据结构
a) Any
b) Bitmap
c) Compressed Pair
d) Fusion
e) ICL
f) Multi-Index
g) Pointer Container
h) Property Tree
i) Tuple
j) Uuid
k) Variant
13. 图像处理
a) GIL
14. 输入输出
a) Asio
b) Assign
c) Format
d) IO State Savers
e) IOStreams
f) Program Options
g) Serialization
15. 跨语言混合编程
a) Python
16. 内存管理
a) Pool
b) Smart Ptr
c) Utility
17. 解析
a) Spirit
18. 编程接口
a) Function
b) Parameter
19. 杂项
a) Compressed Pair
b) Conversion
c) CRC
d) Date Time
e) Exception
f) Filesystem
g) Flyweight
h) Lexical Cast
i) Meta State Machine
j) Numeric Conversion数值转换
k) Optional
l) Polygon
m) Program Options
n) Scope Exit
o) Statechart
p) Swap
q) System
r) Timer
s) Tribool
t) Typeof
u) Units
v) Utility
w) Value Initialized
20. 编译器问题的变通方案
a) Compatibility
b) Config

 

 

accumulators
algorithm
align对齐对准
align.hpp
aligned_storage.hpp
any.hpp
archive
array.hpp
asio
asio.hpp
assert.hpp
assign
assign.hpp
atomic
atomic.hpp
bimap
bimap.hpp
bind
bind.hpp
blank.hpp
blank_fwd.hpp
call_traits.hpp
cast.hpp
cerrno.hpp
checked_delete.hpp
chrono
chrono.hpp
circular_buffer
circular_buffer.hpp
circular_buffer_fwd.hpp
compatibility
compressed_pair.hpp
compute
compute.hpp
concept
concept_archetype.hpp
concept_check
concept_check.hpp
config
config.hpp
container
context
convert
convert.hpp
core
coroutine
coroutine2
crc.hpp
cregex.hpp
cstdfloat.hpp
cstdint.hpp
cstdlib.hpp
current_function.hpp
cxx11_char_types.hpp
date_time
date_time.hpp
detail
dll
dll.hpp
dynamic_bitset
dynamic_bitset.hpp
dynamic_bitset_fwd.hpp
enable_shared_from_this.hpp
endian
exception
exception_ptr.hpp
fiber
filesystem
filesystem.hpp
flyweight
flyweight.hpp
foreach.hpp
foreach_fwd.hpp
format
format.hpp
function
function.hpp
functional
functional.hpp
function_equal.hpp
function_output_iterator.hpp
function_types
fusion
generator_iterator.hpp
geometry
geometry.hpp
get_pointer.hpp
gil
graph
hana
hana.hpp
heap
icl
implicit_cast.hpp
indirect_reference.hpp
integer
integer.hpp
integer_fwd.hpp
integer_traits.hpp
interprocess
intrusive
intrusive_ptr.hpp
io
iostreams
io_fwd.hpp
is_placeholder.hpp
iterator
iterator.hpp
iterator_adaptors.hpp
lambda
last_value.hpp
lexical_cast
lexical_cast.hpp
limits.hpp
locale
locale.hpp
local_function
local_function.hpp
lockfree
log
logic
make_default.hpp
make_shared.hpp
make_unique.hpp
math
math_fwd.hpp
memory_order.hpp
mem_fn.hpp
metaparse
metaparse.hpp
move
mpi
mpi.hpp
mpl
msm
multiprecision
multi_array
multi_array.hpp
multi_index
multi_index_container.hpp
multi_index_container_fwd.hpp
next_prior.hpp
noncopyable.hpp
nondet_random.hpp
none.hpp
none_t.hpp
non_type.hpp
numeric
operators.hpp
operators_v1.hpp
optional
optional.hpp
parameter
parameter.hpp
pending
phoenix
phoenix.hpp
pointee.hpp
pointer_cast.hpp
pointer_to_other.hpp
polygon
polymorphic_cast.hpp
polymorphic_pointer_cast.hpp
poly_collection
pool
predef
predef.h
preprocessor
preprocessor.hpp
process
process.hpp
program_options
program_options.hpp
progress.hpp
property_map
property_tree
proto
ptr_container
python
python.hpp
qvm
random
random.hpp
range
range.hpp
ratio
ratio.hpp
rational.hpp
ref.hpp
regex
regex.h
regex.hpp
regex_fwd.hpp
scoped_array.hpp
scoped_ptr.hpp
scope_exit.hpp
serialization
shared_array.hpp
shared_container_iterator.hpp
shared_ptr.hpp
signal.hpp
signals
signals.hpp
signals2
signals2.hpp
smart_ptr
smart_ptr.hpp
sort
spirit
spirit.hpp
stacktrace
stacktrace.hpp
statechart
static_assert.hpp
swap.hpp
system
test
thread
thread.hpp
throw_exception.hpp
timer
timer.hpp
tokenizer.hpp
token_functions.hpp
token_iterator.hpp
tti
tuple
type.hpp
typeof
type_erasure
type_index
type_index.hpp
type_traits
type_traits.hpp
units
unordered
unordered_map.hpp
unordered_set.hpp
utility
utility.hpp
uuid
variant
variant.hpp
version.hpp
visit_each.hpp
vmd
wave
wave.hpp
weak_ptr.hpp
xpressive

posted @ 2021-08-19 14:48  Lu_STEEL  阅读(51)  评论(0编辑  收藏  举报