1. 将ROS2的Bag文件转换为CSV、JSON等
具体代码地址:https://github.com/fishros/ros2bag_convert
2.动手学Moveit2|使用配置助手创建自己机械臂的功能包
运行如下配置助手:
ros2 run moveit_setup_assistant moveit_setup_assistant
如果运行报如下错误:
terminate called after throwing an instance of 'ament_index_cpp::PackageNotFoundError'
what(): package 'elite_description' not found, searching: [/home/zy0035/piper_ros/install/piper_with_gripper_moveit, /home/zy0035/piper_ros/install/piper_no_gripper_moveit, /home/zy0035/piper_ros/install/piper_mujoco, /home/zy0035/piper_ros/install/piper_msgs, /home/zy0035/piper_ros/install/piper_humble, /home/zy0035/piper_ros/install/piper_gazebo, /home/zy0035/piper_ros/install/piper_description, /home/zy0035/piper_ros/install/piper, /home/zy0035/ros2_ws/install/vision, /home/zy0035/ros2_ws/install/ur_bringup, /home/zy0035/ros2_ws/install/ur5e_octomap_moveit, /home/zy0035/ros2_ws/install/ur5e_gripper_control, /home/zy0035/ros2_ws/install/ur5e_gripper_moveit_config, /home/zy0035/ros2_ws/install/ur5e_gripper_description, /home/zy0035/ros2_ws/install/robotiq_moveit_config, /home/zy0035/ros2_ws/install/robotiq_description, /home/zy0035/ros2_ws/install/realsense2_description, /home/zy0035/ros2_ws/install/realsense2_camera_msgs, /home/zy0035/ros2_ws/install/octo_bringup, /home/zy0035/ros2_ws/install/gazebo_grasp_plugin_ros, /home/zy0035/ros2_ws/install/gazebo_version_helpers, /opt/ros/humble]
Stack trace (most recent call last):
#31 Object "/usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5.15.3", at 0x70a086572e46, in QApplicationPrivate::sendMouseEvent(QWidget*, QMouseEvent*, QWidget*, QWidget*, QWidget**, QPointer<QWidget>&, bool, bool)
#30 Object "/usr/lib/x86_64-linux-gnu/libQt5Core.so.5.15.3", at 0x70a0858b9e39, in QCoreApplication::notifyInternal2(QObject*, QEvent*)
#29 Object "/usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5.15.3", at 0x70a086574363, in QApplication::notify(QObject*, QEvent*)
#28 Object "/usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5.15.3", at 0x70a08656c712, in QApplicationPrivate::notify_helper(QObject*, QEvent*)
#27 Object "/usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5.15.3", at 0x70a0865af4ed, in QWidget::event(QEvent*)
#26 Object "/usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5.15.3", at 0x70a0866641e6, in QAbstractButton::mouseReleaseEvent(QMouseEvent*)
#25 Object "/usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5.15.3", at 0x70a086663fc3, in
#24 Object "/usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5.15.3", at 0x70a08666239d, in
#23 Object "/usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5.15.3", at 0x70a086662115, in QAbstractButton::clicked(bool)
#22 Object "/usr/lib/x86_64-linux-gnu/libQt5Core.so.5.15.3", at 0x70a0858f17c7, in
#21 Source "./src/helper_widgets.cpp", line 171, in btnFileDialog [0x70a086faf5ef]
#20 Object "/usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5.15.3", at 0x70a0866c2a91, in QWidgetLineControl::internalSetText(QString const&, int, bool)
#19 Object "/usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5.15.3", at 0x70a0866c27ce, in QWidgetLineControl::finishChange(int, bool, bool)
#18 Object "/usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5.15.3", at 0x70a0866bf0f8, in QWidgetLineControl::textChanged(QString const&)
#17 Object "/usr/lib/x86_64-linux-gnu/libQt5Core.so.5.15.3", at 0x70a0858f17c7, in
#16 Object "/usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5.15.3", at 0x70a0866b7845, in QLineEdit::textChanged(QString const&)
#15 Object "/usr/lib/x86_64-linux-gnu/libQt5Core.so.5.15.3", at 0x70a0858f17c7, in
#14 Source "./.obj-x86_64-linux-gnu/include/moveit_setup_framework/qt/moc_helper_widgets.cpp", line 222, in pathChanged [0x70a086fd86c5]
#13 Object "/usr/lib/x86_64-linux-gnu/libQt5Core.so.5.15.3", at 0x70a0858f17c7, in
#12 Source "./src/start_screen_widget.cpp", line 308, in onUrdfPathChanged [0x70a071141f19]
#11 Source "./src/start_screen.cpp", line 52, in loadURDFFile [0x70a0711400a0]
#10 Source "./src/urdf_config.cpp", line 80, in loadFromPath [0x70a086fba4f4]
#9 | Source "./src/urdf_config.cpp", line 104, in getSharePath
Source "./include/moveit_setup_framework/utilities.hpp", line 52, in setPackageName [0x70a086fba14f]
#8 Object "/opt/ros/humble/lib/libament_index_cpp.so", at 0x70a086bf0e42, in ament_index_cpp::get_package_share_directory(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)
#7 Object "/opt/ros/humble/lib/libament_index_cpp.so", at 0x70a086beeb19, in
#6 Object "/usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.30", at 0x70a0870ae4d7, in __cxa_throw
#5 Object "/usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.30", at 0x70a0870ae276, in std::terminate()
#4 Object "/usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.30", at 0x70a0870ae20b, in
#3 Object "/usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.30", at 0x70a0870a2b9d, in
#2 Source "./stdlib/abort.c", line 79, in abort [0x70a0852287f2]
#1 Source "../sysdeps/posix/raise.c", line 26, in raise [0x70a085242475]
#0 | Source "./nptl/pthread_kill.c", line 89, in __pthread_kill_internal
| Source "./nptl/pthread_kill.c", line 78, in __pthread_kill_implementation
Source "./nptl/pthread_kill.c", line 44, in __pthread_kill [0x70a0852969fc]
Aborted (Signal sent by tkill() 2007497 1000)
[ros2run]: Aborted
解决方案:
有stl文件在urdf里边,或者你应该在你的含有urdf文件的功能包的src目录下打开moveit setup assistant,然后再去找你的urdf文件
Moveit2生成的参数有BUG修复
具体配置参考:https://zhuanlan.zhihu.com/p/567246503
这里,给出我使用松灵的piper臂生成的文件下载地址:
https://download.csdn.net/download/caokaifa/91669593
不知道为啥生成的joint_limits.yaml调用ros2 launch piper_control_arm demo.launch.py会报错,只要把文件中的5改为5.0就OK了,正确的如下图参数。
# joint_limits.yaml allows the dynamics properties specified in the URDF to be overwritten or augmented as needed
# For beginners, we downscale velocity and acceleration limits.
# You can always specify higher scaling factors (<= 1.0) in your motion requests. # Increase the values below to 1.0 to always move at maximum speed.
default_velocity_scaling_factor: 0.1
default_acceleration_scaling_factor: 0.1
# Specific joint properties can be changed with the keys [max_position, min_position, max_velocity, max_acceleration]
# Joint limits can be turned off with [has_velocity_limits, has_acceleration_limits]
joint_limits:
joint1:
has_velocity_limits: true
max_velocity: 5.0
has_acceleration_limits: false
max_acceleration: 0
joint2:
has_velocity_limits: true
max_velocity: 5.0
has_acceleration_limits: false
max_acceleration: 0
joint3:
has_velocity_limits: true
max_velocity: 5.0
has_acceleration_limits: false
max_acceleration: 0
joint4:
has_velocity_limits: true
max_velocity: 5.0
has_acceleration_limits: false
max_acceleration: 0
joint5:
has_velocity_limits: true
max_velocity: 5.0
has_acceleration_limits: false
max_acceleration: 0
joint6:
has_velocity_limits: true
max_velocity: 5.0
has_acceleration_limits: false
max_acceleration: 0
生成的文件调用没有错误,但是控制不了臂,原谅是moveit_controllers.yaml中有问题:
把这个文件修改一下:原代码如下:
# MoveIt uses this configuration for controller management
moveit_controller_manager: moveit_simple_controller_manager/MoveItSimpleControllerManager
moveit_simple_controller_manager:
controller_names:
- piper_arm_controller
piper_arm_controller:
type: FollowJointTrajectory
joints:
- joint1
- joint2
- joint3
- joint4
- joint5
- joint6
修改后如下:
# MoveIt uses this configuration for controller management
moveit_controller_manager: moveit_simple_controller_manager/MoveItSimpleControllerManager
moveit_simple_controller_manager:
controller_names:
- piper_arm_controller
piper_arm_controller:
type: FollowJointTrajectory
action_ns: follow_joint_trajectory
default: true
joints:
- joint1
- joint2
- joint3
- joint4
- joint5
- joint6
这样就可以控制臂规划了!!!!
相关moveit应用例子代码参考:
https://github.com/LitchiCheng/ros2_package
Hybrid Planning — MoveIt Documentation: Rolling documentation
https://github.com/agilexrobotics/piper_ros/tree/humble
3.ROS2 查看话题是谁订阅以及发布指令
ros2 topic info /joint_states --verbose
就是通过info查看话题有几个发布,几个订阅,通过--verbose显示话题的详细信息