mirror of
https://github.com/elephantrobotics/mycobot_ros.git
synced 2026-07-05 19:47:04 +00:00
add Mira ROS1
This commit is contained in:
parent
a455c93be9
commit
954411ca66
80 changed files with 4841 additions and 0 deletions
41
Mira/mira/CMakeLists.txt
Normal file
41
Mira/mira/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
cmake_minimum_required(VERSION 2.8.3)
|
||||
project(mira)
|
||||
add_compile_options(-std=c++11)
|
||||
|
||||
## Find catkin and any catkin packages
|
||||
find_package(catkin REQUIRED COMPONENTS
|
||||
roscpp
|
||||
rospy
|
||||
std_msgs
|
||||
actionlib
|
||||
image_transport
|
||||
cv_bridge
|
||||
)
|
||||
|
||||
## Declare a catkin package
|
||||
catkin_package(
|
||||
CATKIN_DEPENDS std_msgs actionlib
|
||||
)
|
||||
|
||||
## Build talker and listener
|
||||
include_directories(include ${catkin_INCLUDE_DIRS} ${OpenCV_INCLUDE_DIRS})
|
||||
|
||||
catkin_install_python(PROGRAMS
|
||||
scripts/follow_display.py
|
||||
scripts/slider_control.py
|
||||
scripts/teleop_keyboard.py
|
||||
scripts/listen_real.py
|
||||
scripts/listen_real_of_topic.py
|
||||
scripts/simple_gui.py
|
||||
DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
|
||||
)
|
||||
|
||||
install(DIRECTORY launch DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
|
||||
PATTERN "setup_assistant.launch" EXCLUDE)
|
||||
install(DIRECTORY config DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION})
|
||||
|
||||
# find_package(OpenCV REQUIRED)
|
||||
# add_executable(opencv_camera src/opencv_camera)
|
||||
# target_link_libraries(opencv_camera ${catkin_LIBRARIES} ${OpenCV_LIBRARIES})
|
||||
# add_executable(camera_display src/camera_display)
|
||||
# target_link_libraries(camera_display ${catkin_LIBRARIES} ${OpenCV_LIBRARIES})
|
||||
25
Mira/mira/LICENSE
Normal file
25
Mira/mira/LICENSE
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
BSD 2-Clause License
|
||||
|
||||
Copyright (c) 2020, Elephant Robotics
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
185
Mira/mira/config/mira.rviz
Normal file
185
Mira/mira/config/mira.rviz
Normal file
|
|
@ -0,0 +1,185 @@
|
|||
Panels:
|
||||
- Class: rviz/Displays
|
||||
Help Height: 78
|
||||
Name: Displays
|
||||
Property Tree Widget:
|
||||
Expanded:
|
||||
- /Global Options1
|
||||
- /Status1
|
||||
- /TF1
|
||||
- /TF1/Frames1
|
||||
Splitter Ratio: 0.5
|
||||
Tree Height: 591
|
||||
- Class: rviz/Selection
|
||||
Name: Selection
|
||||
- Class: rviz/Tool Properties
|
||||
Expanded:
|
||||
- /2D Pose Estimate1
|
||||
- /2D Nav Goal1
|
||||
- /Publish Point1
|
||||
Name: Tool Properties
|
||||
Splitter Ratio: 0.5886790156364441
|
||||
- Class: rviz/Views
|
||||
Expanded:
|
||||
- /Current View1
|
||||
Name: Views
|
||||
Splitter Ratio: 0.5
|
||||
- Class: rviz/Time
|
||||
Experimental: false
|
||||
Name: Time
|
||||
SyncMode: 0
|
||||
SyncSource: ""
|
||||
Preferences:
|
||||
PromptSaveOnExit: true
|
||||
Toolbars:
|
||||
toolButtonStyle: 2
|
||||
Visualization Manager:
|
||||
Class: ""
|
||||
Displays:
|
||||
- Alpha: 0.5
|
||||
Cell Size: 1
|
||||
Class: rviz/Grid
|
||||
Color: 160; 160; 164
|
||||
Enabled: true
|
||||
Line Style:
|
||||
Line Width: 0.029999999329447746
|
||||
Value: Lines
|
||||
Name: Grid
|
||||
Normal Cell Count: 0
|
||||
Offset:
|
||||
X: 0
|
||||
Y: 0
|
||||
Z: 0
|
||||
Plane: XY
|
||||
Plane Cell Count: 10
|
||||
Reference Frame: <Fixed Frame>
|
||||
Value: true
|
||||
- Alpha: 1
|
||||
Class: rviz/RobotModel
|
||||
Collision Enabled: false
|
||||
Enabled: true
|
||||
Links:
|
||||
All Links Enabled: true
|
||||
Expand Joint Details: false
|
||||
Expand Link Details: false
|
||||
Expand Tree: false
|
||||
Link Tree Style: Links in Alphabetic Order
|
||||
base:
|
||||
Alpha: 1
|
||||
Show Axes: false
|
||||
Show Trail: false
|
||||
Value: true
|
||||
link1:
|
||||
Alpha: 1
|
||||
Show Axes: false
|
||||
Show Trail: false
|
||||
Value: true
|
||||
link2:
|
||||
Alpha: 1
|
||||
Show Axes: false
|
||||
Show Trail: false
|
||||
Value: true
|
||||
link3:
|
||||
Alpha: 1
|
||||
Show Axes: false
|
||||
Show Trail: false
|
||||
Value: true
|
||||
Name: RobotModel
|
||||
Robot Description: robot_description
|
||||
TF Prefix: ""
|
||||
Update Interval: 0
|
||||
Value: true
|
||||
Visual Enabled: true
|
||||
- Class: rviz/TF
|
||||
Enabled: true
|
||||
Frame Timeout: 15
|
||||
Frames:
|
||||
All Enabled: true
|
||||
base:
|
||||
Value: true
|
||||
link1:
|
||||
Value: true
|
||||
link2:
|
||||
Value: true
|
||||
link3:
|
||||
Value: true
|
||||
Marker Alpha: 1
|
||||
Marker Scale: 0.30000001192092896
|
||||
Name: TF
|
||||
Show Arrows: true
|
||||
Show Axes: true
|
||||
Show Names: true
|
||||
Tree:
|
||||
base:
|
||||
link1:
|
||||
link2:
|
||||
link3:
|
||||
{}
|
||||
Update Interval: 0
|
||||
Value: true
|
||||
Enabled: true
|
||||
Global Options:
|
||||
Background Color: 48; 48; 48
|
||||
Default Light: true
|
||||
Fixed Frame: base
|
||||
Frame Rate: 30
|
||||
Name: root
|
||||
Tools:
|
||||
- Class: rviz/Interact
|
||||
Hide Inactive Objects: true
|
||||
- Class: rviz/MoveCamera
|
||||
- Class: rviz/Select
|
||||
- Class: rviz/FocusCamera
|
||||
- Class: rviz/Measure
|
||||
- Class: rviz/SetInitialPose
|
||||
Theta std deviation: 0.2617993950843811
|
||||
Topic: /initialpose
|
||||
X std deviation: 0.5
|
||||
Y std deviation: 0.5
|
||||
- Class: rviz/SetGoal
|
||||
Topic: /move_base_simple/goal
|
||||
- Class: rviz/PublishPoint
|
||||
Single click: true
|
||||
Topic: /clicked_point
|
||||
Value: true
|
||||
Views:
|
||||
Current:
|
||||
Class: rviz/Orbit
|
||||
Distance: 0.7698503136634827
|
||||
Enable Stereo Rendering:
|
||||
Stereo Eye Separation: 0.05999999865889549
|
||||
Stereo Focal Distance: 1
|
||||
Swap Stereo Eyes: false
|
||||
Value: false
|
||||
Field of View: 0.7853981852531433
|
||||
Focal Point:
|
||||
X: 0
|
||||
Y: 0
|
||||
Z: 0
|
||||
Focal Shape Fixed Size: true
|
||||
Focal Shape Size: 0.05000000074505806
|
||||
Invert Z Axis: false
|
||||
Name: Current View
|
||||
Near Clip Distance: 0.009999999776482582
|
||||
Pitch: 0.40479761362075806
|
||||
Target Frame: <Fixed Frame>
|
||||
Yaw: 2.270383358001709
|
||||
Saved: ~
|
||||
Window Geometry:
|
||||
Displays:
|
||||
collapsed: false
|
||||
Height: 888
|
||||
Hide Left Dock: false
|
||||
Hide Right Dock: false
|
||||
QMainWindow State: 000000ff00000000fd000000040000000000000156000002dafc0200000008fb0000001200530065006c0065006300740069006f006e00000001e10000009b0000005c00fffffffb0000001e0054006f006f006c002000500072006f007000650072007400690065007302000001ed000001df00000185000000a3fb000000120056006900650077007300200054006f006f02000001df000002110000018500000122fb000000200054006f006f006c002000500072006f0070006500720074006900650073003203000002880000011d000002210000017afb000000100044006900730070006c006100790073010000003d000002da000000c900fffffffb0000002000730065006c0065006300740069006f006e00200062007500660066006500720200000138000000aa0000023a00000294fb00000014005700690064006500530074006500720065006f02000000e6000000d2000003ee0000030bfb0000000c004b0069006e0065006300740200000186000001060000030c00000261000000010000010f000002dafc0200000003fb0000001e0054006f006f006c002000500072006f00700065007200740069006500730100000041000000780000000000000000fb0000000a00560069006500770073010000003d000002da000000a400fffffffb0000001200530065006c0065006300740069006f006e010000025a000000b200000000000000000000000200000490000000a9fc0100000001fb0000000a00560069006500770073030000004e00000080000002e10000019700000003000007380000003efc0100000002fb0000000800540069006d0065010000000000000738000002eb00fffffffb0000000800540069006d00650100000000000004500000000000000000000004c7000002da00000004000000040000000800000008fc0000000100000002000000010000000a0054006f006f006c00730100000000ffffffff0000000000000000
|
||||
Selection:
|
||||
collapsed: false
|
||||
Time:
|
||||
collapsed: false
|
||||
Tool Properties:
|
||||
collapsed: false
|
||||
Views:
|
||||
collapsed: false
|
||||
Width: 1848
|
||||
X: 72
|
||||
Y: 27
|
||||
14
Mira/mira/launch/follow.launch
Normal file
14
Mira/mira/launch/follow.launch
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
<launch>
|
||||
<!-- Load file model .加载文件模型-->
|
||||
<arg name="model" default="$(find mycobot_description)/urdf/mira_urdf/mira.urdf"/>
|
||||
<arg name="rvizconfig" default="$(find mira)/config/mira.rviz" />
|
||||
|
||||
<param name="robot_description" command="$(find xacro)/xacro --inorder $(arg model)" />
|
||||
|
||||
<!-- Combinejoin values to TF .将值合并到 TF-->
|
||||
<node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher" >
|
||||
<rosparam param="source_list" subst_value="true">["joint_states"]</rosparam>
|
||||
</node>
|
||||
<!-- Show in Rviz ,显示在Rviz-->
|
||||
<node name="rviz" pkg="rviz" type="rviz" args="-d $(arg rvizconfig)" required="true" />
|
||||
</launch>
|
||||
24
Mira/mira/launch/simple_gui.launch
Normal file
24
Mira/mira/launch/simple_gui.launch
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
<launch>
|
||||
<!-- Select connecting device and serial port ,选择连接设备及串口-->
|
||||
<arg name="port" default="/dev/ttyUSB0" />
|
||||
<arg name="baud" default="115200" />
|
||||
<!-- Load file model ,加载文件模型-->
|
||||
<arg name="model" default="$(find mycobot_description)/urdf/mira_urdf/mira.urdf"/>
|
||||
<arg name="rvizconfig" default="$(find mira)/config/mira.rviz" />
|
||||
<arg name="gui" default="false" />
|
||||
|
||||
<param name="robot_description" command="$(find xacro)/xacro --inorder $(arg model)" />
|
||||
|
||||
<!-- Combinejoin values to TF,将值合并到 TF-->
|
||||
<node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher" />
|
||||
<!-- Show in Rviz -->
|
||||
<node name="rviz" pkg="rviz" type="rviz" args="-d $(arg rvizconfig)" required="true" />
|
||||
<!-- mycobot-topics, mycobot-话题-->
|
||||
<include file="$(find mira_communication)/launch/communication_service.launch">
|
||||
<arg name="port" value="$(arg port)" />
|
||||
<arg name="baud" value="$(arg baud)" />
|
||||
</include>
|
||||
<!-- listen and pub the real angles ,监听并发布真实角度-->
|
||||
<node name="real_listener" pkg="mira" type="listen_real.py" />
|
||||
<node name="simple_gui" pkg="mira" type="simple_gui.py" />
|
||||
</launch>
|
||||
25
Mira/mira/launch/slider_control.launch
Normal file
25
Mira/mira/launch/slider_control.launch
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
<launch>
|
||||
<!-- <arg name="port" default="/dev/ttyUSB0" />
|
||||
<arg name="baud" default="115200" /> -->
|
||||
|
||||
<!-- Load file model ,加载文件模型-->
|
||||
<arg name="model" default="$(find mycobot_description)/urdf/mira_urdf/mira.urdf"/>
|
||||
<arg name="rvizconfig" default="$(find mira)/config/mira.rviz" />
|
||||
<arg name="gui" default="true" />
|
||||
|
||||
<param name="robot_description" command="$(find xacro)/xacro --inorder $(arg model)" />
|
||||
|
||||
<!-- Combinejoin values to TF, 将值合并到TF-->
|
||||
<node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher" />
|
||||
<node name="joint_state_publisher_gui" pkg="joint_state_publisher_gui" type="joint_state_publisher_gui">
|
||||
<!-- <param name="use_gui" value="$(arg gui)" /> -->
|
||||
<!-- <rosparam param="source_list" subst_value="true">["joint_states"]</rosparam> -->
|
||||
</node>
|
||||
<!-- Open control script -->
|
||||
<!-- <node name="control_slider" pkg="mycobot_280" type="slider_control.py">
|
||||
<param name="port" type="string" value="$(arg port)" />
|
||||
<param name="baud" type="int" value="$(arg baud)" />
|
||||
</node> -->
|
||||
<!-- Show in Rviz,显示在Rviz -->
|
||||
<node name="rviz" pkg="rviz" type="rviz" args="-d $(arg rvizconfig)" required="true" />
|
||||
</launch>
|
||||
28
Mira/mira/launch/teleop_keyboard.launch
Normal file
28
Mira/mira/launch/teleop_keyboard.launch
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
<launch>
|
||||
<!-- Select connecting device and serial port ,选择连接设备及串口-->
|
||||
<arg name="port" default="/dev/ttyUSB0" />
|
||||
<arg name="baud" default="115200" />
|
||||
|
||||
<!-- Load file model ,加载文件模型-->
|
||||
<!-- <arg name="model" default="$(find mycobot_description)/urdf/260_urdf/mycobot_urdf.urdf"/>
|
||||
<arg name="rvizconfig" default="$(find mycobot_280)/config/mycobot.rviz" /> -->
|
||||
<arg name="model" default="$(find mycobot_description)/urdf/mira_urdf/mira.urdf"/>
|
||||
<arg name="rvizconfig" default="$(find mira)/config/mira.rviz" />
|
||||
<arg name="gui" default="false" />
|
||||
|
||||
<param name="robot_description" command="$(find xacro)/xacro --inorder $(arg model)" />
|
||||
|
||||
<!-- Combinejoin values to TF ,将值合并到TF-->
|
||||
<node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher" />
|
||||
<!-- Show in Rviz -->
|
||||
<node name="rviz" pkg="rviz" type="rviz" args="-d $(arg rvizconfig)" required="true" />
|
||||
|
||||
<!-- mycobot-topics,mycobot-话题 -->
|
||||
<include file="$(find mira_communication)/launch/communication_service.launch">
|
||||
<arg name="port" value="$(arg port)" />
|
||||
<arg name="baud" value="$(arg baud)" />
|
||||
</include>
|
||||
|
||||
<!-- listen and pub the real angles ,监听并发布真实话题-->
|
||||
<node name="real_listener" pkg="mira" type="listen_real.py" />
|
||||
</launch>
|
||||
18
Mira/mira/launch/test.launch
Normal file
18
Mira/mira/launch/test.launch
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
<launch>
|
||||
<!-- Load file model,加载文件模型 -->
|
||||
<arg name="model" default="$(find mycobot_description)/urdf/mira_urdf/mira.urdf"/>
|
||||
<arg name="rvizconfig" default="$(find mira)/config/mira.rviz" />
|
||||
<arg name="gui" default="true" />
|
||||
|
||||
<param name="robot_description" command="$(find xacro)/xacro --inorder $(arg model)" />
|
||||
|
||||
<!-- Combinejoin values to TF ,将值合并到TF-->
|
||||
<node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher" />
|
||||
<node name="joint_state_publisher_gui" pkg="joint_state_publisher_gui" type="joint_state_publisher_gui">
|
||||
<param name="use_gui" value="$(arg gui)" />
|
||||
<!-- <rosparam param="source_list" subst_value="true">["joint_states"]</rosparam> -->
|
||||
</node>
|
||||
<!-- Show in Rviz.显示在Rviz -->
|
||||
<node name="rviz" pkg="rviz" type="rviz" args="-d $(arg rvizconfig)" required="true" />
|
||||
<!-- <node name="rviz" pkg="rviz" type="rviz" /> -->
|
||||
</launch>
|
||||
47
Mira/mira/package.xml
Normal file
47
Mira/mira/package.xml
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
<?xml version="1.0"?>
|
||||
<package format="2">
|
||||
<name>mira</name>
|
||||
<version>0.3.0</version>
|
||||
<description>The mira package</description>
|
||||
|
||||
<author email="lijun.zhang@elephantrobotics.com">ZhangLijun</author>
|
||||
<maintainer email="lijun.zhang@elephantrobotics.com">ZhangLijun</maintainer>
|
||||
|
||||
<license>BSD</license>
|
||||
|
||||
<url type="website">https://github.com/elephantrobotics/mycobot_ros</url>
|
||||
|
||||
<buildtool_depend>catkin</buildtool_depend>
|
||||
|
||||
<build_depend>roscpp</build_depend>
|
||||
<build_depend>rospy</build_depend>
|
||||
<build_depend>std_msgs</build_depend>
|
||||
<build_depend>actionlib</build_depend>
|
||||
<build_depend>mycobot_description</build_depend>
|
||||
<build_depend>mira_communication</build_depend>
|
||||
|
||||
<build_export_depend>mira_communication</build_export_depend>
|
||||
<build_export_depend>mycobot_description</build_export_depend>
|
||||
|
||||
<exec_depend>roscpp</exec_depend>
|
||||
<exec_depend>rospy</exec_depend>
|
||||
<exec_depend>std_msgs</exec_depend>
|
||||
<exec_depend>actionlib</exec_depend>
|
||||
<exec_depend>joint_state_publisher</exec_depend>
|
||||
<exec_depend>joint_state_publisher_gui</exec_depend>
|
||||
<exec_depend>robot_state_publisher</exec_depend>
|
||||
<exec_depend>xacro</exec_depend>
|
||||
<exec_depend>joy</exec_depend>
|
||||
<exec_depend>rviz</exec_depend>
|
||||
<exec_depend>controller_manager</exec_depend>
|
||||
<exec_depend>python-tk</exec_depend>
|
||||
<exec_depend>mycobot_description</exec_depend>
|
||||
<exec_depend>mira_communication</exec_depend>
|
||||
|
||||
|
||||
<!-- The export tag contains other, unspecified, tags -->
|
||||
<export>
|
||||
<!-- Other tools can request additional information be placed here -->
|
||||
|
||||
</export>
|
||||
</package>
|
||||
109
Mira/mira/scripts/follow_display.py
Normal file
109
Mira/mira/scripts/follow_display.py
Normal file
|
|
@ -0,0 +1,109 @@
|
|||
#!/usr/bin/env python3
|
||||
import time
|
||||
|
||||
import rospy
|
||||
from sensor_msgs.msg import JointState
|
||||
from std_msgs.msg import Header
|
||||
from visualization_msgs.msg import Marker
|
||||
|
||||
|
||||
from pymycobot.mypalletizer import MyPalletizer
|
||||
|
||||
|
||||
def talker():
|
||||
rospy.init_node("display", anonymous=True)
|
||||
|
||||
print("Try connect real mypal...")
|
||||
port = rospy.get_param("~port", "/dev/ttyUSB0")
|
||||
baud = rospy.get_param("~baud", 115200)
|
||||
print("port: {}, baud: {}\n".format(port, baud))
|
||||
try:
|
||||
mira = MyPalletizer(port, baud)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
print(
|
||||
"""\
|
||||
\rTry connect mypalletizer failed!
|
||||
\rPlease check wether connected with MyPalletizer.
|
||||
\rPlease chckt wether the port or baud is right.
|
||||
"""
|
||||
)
|
||||
exit(1)
|
||||
mira.release_all_servos()
|
||||
time.sleep(0.1)
|
||||
print("Rlease all servos over.\n")
|
||||
|
||||
pub = rospy.Publisher("joint_states", JointState, queue_size=10)
|
||||
pub_marker = rospy.Publisher("visualization_marker", Marker, queue_size=10)
|
||||
rate = rospy.Rate(30) # 30hz
|
||||
|
||||
# pub joint state. 发布关节状态
|
||||
joint_state_send = JointState()
|
||||
joint_state_send.header = Header()
|
||||
|
||||
joint_state_send.name = [
|
||||
|
||||
"joint1_to_base",
|
||||
"joint2_to_joint1",
|
||||
"joint3_to_joint2",
|
||||
# "joint4_to_joint3",
|
||||
# "joint5_to_joint4",
|
||||
]
|
||||
joint_state_send.velocity = [0]
|
||||
joint_state_send.effort = []
|
||||
|
||||
marker_ = Marker()
|
||||
marker_.header.frame_id = "/base"
|
||||
marker_.ns = "my_namespace"
|
||||
|
||||
print("publishing ...")
|
||||
while not rospy.is_shutdown():
|
||||
joint_state_send.header.stamp = rospy.Time.now()
|
||||
|
||||
angles = mira.get_radians()
|
||||
data_list = []
|
||||
for index, value in enumerate(angles):
|
||||
data_list.append(value)
|
||||
|
||||
# rospy.loginfo('{}'.format(data_list))
|
||||
joint_state_send.position = data_list
|
||||
|
||||
# data_list.insert(3,0.0)
|
||||
print(joint_state_send.position)
|
||||
|
||||
pub.publish(joint_state_send)
|
||||
|
||||
coords = mira.get_coords()
|
||||
|
||||
# marker
|
||||
marker_.header.stamp = rospy.Time.now()
|
||||
marker_.type = marker_.SPHERE
|
||||
marker_.action = marker_.ADD
|
||||
marker_.scale.x = 0.04
|
||||
marker_.scale.y = 0.04
|
||||
marker_.scale.z = 0.04
|
||||
|
||||
# marker position initial. 标记初始位置
|
||||
# print(coords)
|
||||
if not coords:
|
||||
# coords = [0, 0, 0, 0, 0 ]
|
||||
coords = [0, 0, 0, 0]
|
||||
|
||||
# rospy.loginfo("error [101]: can not get coord values")
|
||||
|
||||
marker_.pose.position.x = coords[1] / 1000 * -1
|
||||
marker_.pose.position.y = coords[0] / 1000
|
||||
marker_.pose.position.z = coords[2] / 1000
|
||||
|
||||
marker_.color.a = 1.0
|
||||
marker_.color.g = 1.0
|
||||
pub_marker.publish(marker_)
|
||||
|
||||
rate.sleep()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
try:
|
||||
talker()
|
||||
except rospy.ROSInterruptException:
|
||||
pass
|
||||
67
Mira/mira/scripts/listen_real.py
Normal file
67
Mira/mira/scripts/listen_real.py
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
#!/usr/bin/env python3
|
||||
# license removed for brevity
|
||||
import time
|
||||
import math
|
||||
|
||||
import rospy
|
||||
from sensor_msgs.msg import JointState
|
||||
from std_msgs.msg import Header
|
||||
# from mycobot_communication.srv import GetAngles
|
||||
from mira_communication.srv import GetAngles
|
||||
# from pymycobot.mypalletizer import MyPalletizer
|
||||
|
||||
|
||||
def talker():
|
||||
rospy.loginfo("start ...")
|
||||
rospy.init_node("real_listener", anonymous=True)
|
||||
pub = rospy.Publisher("joint_states", JointState, queue_size=10)
|
||||
rate = rospy.Rate(30) # 30hz
|
||||
|
||||
# pub joint state 发布关节状态
|
||||
joint_state_send = JointState()
|
||||
joint_state_send.header = Header()
|
||||
|
||||
joint_state_send.name = [
|
||||
"joint1_to_base",
|
||||
"joint2_to_joint1",
|
||||
"joint3_to_joint2",
|
||||
# "joint4_to_joint3",
|
||||
# "joint5_to_joint4",
|
||||
]
|
||||
joint_state_send.velocity = [0]
|
||||
joint_state_send.effort = []
|
||||
|
||||
# waiting util server `get_joint_angles` enable.
|
||||
rospy.loginfo("wait service")
|
||||
rospy.wait_for_service("get_joint_angles")
|
||||
func = rospy.ServiceProxy("get_joint_angles", GetAngles)
|
||||
|
||||
rospy.loginfo("start loop ...")
|
||||
while not rospy.is_shutdown():
|
||||
# get real angles from server.
|
||||
# 从服务获取真实的角度
|
||||
res = func()
|
||||
if res.joint_1 == res.joint_2 == res.joint_3 == 0.0:
|
||||
continue
|
||||
radians_list = [
|
||||
res.joint_1 * (math.pi / 180),
|
||||
res.joint_2 * (math.pi / 180),
|
||||
res.joint_3 * (math.pi / 180),
|
||||
0,
|
||||
# res.joint_4 * (math.pi / 180),
|
||||
|
||||
]
|
||||
rospy.loginfo("res: {}".format(radians_list))
|
||||
|
||||
# publish angles. 发布角度
|
||||
joint_state_send.header.stamp = rospy.Time.now()
|
||||
joint_state_send.position = radians_list
|
||||
pub.publish(joint_state_send)
|
||||
rate.sleep()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
try:
|
||||
talker()
|
||||
except rospy.ROSInterruptException:
|
||||
pass
|
||||
66
Mira/mira/scripts/listen_real_of_topic.py
Normal file
66
Mira/mira/scripts/listen_real_of_topic.py
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
#!/usr/bin/env python2
|
||||
import math
|
||||
|
||||
import rospy
|
||||
from sensor_msgs.msg import JointState
|
||||
from std_msgs.msg import Header
|
||||
# from mycobot_communication.msg import MycobotAngles
|
||||
from mira_communication.msg import MiraAngles
|
||||
|
||||
|
||||
class Listener(object):
|
||||
def __init__(self):
|
||||
super(Listener, self).__init__()
|
||||
|
||||
rospy.loginfo("start ...")
|
||||
rospy.init_node("real_listener_1", anonymous=True)
|
||||
# init publisher. 初始化发布者
|
||||
self.pub = rospy.Publisher("joint_states", JointState, queue_size=10)
|
||||
# init subscriber. 初始化订阅者
|
||||
self.sub = rospy.Subscriber("mypal/angles_real", MiraAngles, self.callback)
|
||||
rospy.spin()
|
||||
|
||||
def callback(self, data):
|
||||
"""`mycobot/angles_real` subscriber callback method.
|
||||
|
||||
Args:
|
||||
data (MycobotAngles): callback argument.
|
||||
"""
|
||||
# ini publisher object.
|
||||
# 初始化发布者对象
|
||||
joint_state_send = JointState()
|
||||
joint_state_send.header = Header()
|
||||
|
||||
joint_state_send.name = [
|
||||
"joint1_to_base",
|
||||
"joint2_to_joint1",
|
||||
"joint3_to_joint2",
|
||||
"joint4_to_joint3",
|
||||
# "joint5_to_joint4",
|
||||
# "joint6_to_joint5",
|
||||
# "joint6output_to_joint6",
|
||||
]
|
||||
joint_state_send.velocity = [0]
|
||||
joint_state_send.effort = []
|
||||
joint_state_send.header.stamp = rospy.Time.now()
|
||||
|
||||
# process callback data. 处理回调数据
|
||||
radians_list = [
|
||||
data.joint_1 * (math.pi / 180),
|
||||
data.joint_2 * (math.pi / 180),
|
||||
data.joint_3 * (math.pi / 180),
|
||||
# data.joint_4 * (math.pi / 180),
|
||||
# data.joint_5 * (math.pi / 180),
|
||||
# data.joint_6 * (math.pi / 180),
|
||||
]
|
||||
rospy.loginfo("res: {}".format(radians_list))
|
||||
|
||||
joint_state_send.position = radians_list
|
||||
self.pub.publish(joint_state_send)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
try:
|
||||
Listener()
|
||||
except rospy.ROSInterruptException:
|
||||
pass
|
||||
378
Mira/mira/scripts/simple_gui.py
Normal file
378
Mira/mira/scripts/simple_gui.py
Normal file
|
|
@ -0,0 +1,378 @@
|
|||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
import tkinter as tk
|
||||
from mira_communication.srv import GetCoords, SetCoords, GetAngles, SetAngles, GripperStatus
|
||||
import rospy
|
||||
import time
|
||||
from rospy import ServiceException
|
||||
|
||||
|
||||
class Window:
|
||||
def __init__(self, handle):
|
||||
self.win = handle
|
||||
self.win.resizable(0, 0) # fixed window size 固定窗口大小
|
||||
|
||||
self.model = 0
|
||||
self.speed = rospy.get_param("~speed", 50)
|
||||
|
||||
# set default speed. 设置默认速度
|
||||
self.speed_d = tk.StringVar()
|
||||
self.speed_d.set(str(self.speed))
|
||||
# print(self.speed)
|
||||
self.connect_ser()
|
||||
|
||||
# Get robotic arm data. 获取机械臂数据
|
||||
self.record_coords = [0, 0, 0, self.speed,]
|
||||
self.res_angles = [0, 0, 0, self.speed,]
|
||||
self.get_date()
|
||||
|
||||
# get screen width and height. 获取屏幕宽度和高度
|
||||
self.ws = self.win.winfo_screenwidth()
|
||||
self.hs = self.win.winfo_screenheight()
|
||||
# calculate x and y coordinates for the Tk root window
|
||||
# 计算 Tk 根窗口的 x 和 y 坐标
|
||||
x = (self.ws / 2) - 190
|
||||
y = (self.hs / 2) - 250
|
||||
self.win.geometry("430x350+{}+{}".format(x, y))
|
||||
# layout. 布局
|
||||
self.set_layout()
|
||||
# input. 输入部分
|
||||
self.need_input()
|
||||
# show info. 展示部分
|
||||
self.show_init()
|
||||
|
||||
# Set joint button. 设置关节按钮
|
||||
tk.Button(self.frmLT, text="Set", width=5, command=self.get_joint_input).grid(
|
||||
row=6, column=1, sticky="w", padx=3, pady=2
|
||||
)
|
||||
|
||||
# Set Coordinate button. 设置坐标按钮
|
||||
tk.Button(self.frmRT, text="Set", width=5, command=self.get_coord_input).grid(
|
||||
row=6, column=1, sticky="w", padx=3, pady=2
|
||||
)
|
||||
|
||||
# Gripper Switch. 夹爪开关按钮
|
||||
tk.Button(self.frmLB, text="Gripper Open", command=self.gripper_open, width=10).grid(
|
||||
row=1, column=0, sticky="w", padx=3, pady=50
|
||||
)
|
||||
tk.Button(self.frmLB, text="Gripper Close", command=self.gripper_close, width=10).grid(
|
||||
row=1, column=1, sticky="w", padx=3, pady=2
|
||||
)
|
||||
|
||||
def connect_ser(self):
|
||||
rospy.init_node("simple_gui", anonymous=True, disable_signals=True)
|
||||
|
||||
rospy.wait_for_service("get_joint_angles")
|
||||
rospy.wait_for_service("set_joint_angles")
|
||||
rospy.wait_for_service("get_joint_coords")
|
||||
rospy.wait_for_service("set_joint_coords")
|
||||
rospy.wait_for_service("switch_gripper_status")
|
||||
try:
|
||||
self.get_coords = rospy.ServiceProxy("get_joint_coords", GetCoords)
|
||||
self.set_coords = rospy.ServiceProxy("set_joint_coords", SetCoords)
|
||||
self.get_angles = rospy.ServiceProxy("get_joint_angles", GetAngles)
|
||||
self.set_angles = rospy.ServiceProxy("set_joint_angles", SetAngles)
|
||||
self.switch_gripper = rospy.ServiceProxy(
|
||||
"switch_gripper_status", GripperStatus
|
||||
)
|
||||
except:
|
||||
print("start error ...")
|
||||
exit(1)
|
||||
|
||||
print("Connect service success.")
|
||||
|
||||
def set_layout(self):
|
||||
self.frmLT = tk.Frame(width=200, height=200)
|
||||
self.frmLC = tk.Frame(width=200, height=200)
|
||||
self.frmLB = tk.Frame(width=200, height=200)
|
||||
self.frmRT = tk.Frame(width=200, height=200)
|
||||
self.frmLT.grid(row=0, column=0, padx=1, pady=3)
|
||||
self.frmLC.grid(row=1, column=0, padx=1, pady=3)
|
||||
self.frmLB.grid(row=1, column=1, padx=2, pady=3)
|
||||
self.frmRT.grid(row=0, column=1, padx=2, pady=3)
|
||||
|
||||
def need_input(self):
|
||||
# input hint. 输入提示
|
||||
tk.Label(self.frmLT, text="Joint 1 ").grid(row=0)
|
||||
tk.Label(self.frmLT, text="Joint 2 ").grid(row=1)
|
||||
tk.Label(self.frmLT, text="Joint 3 ").grid(row=2)
|
||||
|
||||
|
||||
tk.Label(self.frmRT, text=" x ").grid(row=0)
|
||||
tk.Label(self.frmRT, text=" y ").grid(row=1)
|
||||
tk.Label(self.frmRT, text=" z ").grid(row=2)
|
||||
|
||||
|
||||
# Set the default value of the input box.
|
||||
# 设置输入框的默认值
|
||||
self.j1_default = tk.StringVar()
|
||||
self.j1_default.set(self.res_angles[0])
|
||||
self.j2_default = tk.StringVar()
|
||||
self.j2_default.set(self.res_angles[1])
|
||||
self.j3_default = tk.StringVar()
|
||||
self.j3_default.set(self.res_angles[2])
|
||||
|
||||
|
||||
|
||||
self.x_default = tk.StringVar()
|
||||
self.x_default.set(self.record_coords[0])
|
||||
self.y_default = tk.StringVar()
|
||||
self.y_default.set(self.record_coords[1])
|
||||
self.z_default = tk.StringVar()
|
||||
self.z_default.set(self.record_coords[2])
|
||||
|
||||
|
||||
# joint input box. 输入框
|
||||
self.J_1 = tk.Entry(self.frmLT, textvariable=self.j1_default)
|
||||
self.J_1.grid(row=0, column=1, pady=3)
|
||||
self.J_2 = tk.Entry(self.frmLT, textvariable=self.j2_default)
|
||||
self.J_2.grid(row=1, column=1, pady=3)
|
||||
self.J_3 = tk.Entry(self.frmLT, textvariable=self.j3_default)
|
||||
self.J_3.grid(row=2, column=1, pady=3)
|
||||
|
||||
|
||||
|
||||
# coord input box. 输入框
|
||||
self.x = tk.Entry(self.frmRT, textvariable=self.x_default)
|
||||
self.x.grid(row=0, column=1, pady=3, padx=0)
|
||||
self.y = tk.Entry(self.frmRT, textvariable=self.y_default)
|
||||
self.y.grid(row=1, column=1, pady=3)
|
||||
self.z = tk.Entry(self.frmRT, textvariable=self.z_default)
|
||||
self.z.grid(row=2, column=1, pady=3)
|
||||
|
||||
|
||||
|
||||
# All input boxes, used to get the input data. 所有输入框,用于拿输入的数据
|
||||
self.all_j = [self.J_1, self.J_2, self.J_3,]
|
||||
self.all_c = [self.x, self.y, self.z,]
|
||||
|
||||
|
||||
|
||||
# speed input box. 速度输入框
|
||||
tk.Label(
|
||||
self.frmLB,
|
||||
text="speed",
|
||||
).grid(row=0, column=0)
|
||||
self.get_speed = tk.Entry(self.frmLB, textvariable=self.speed_d, width=10)
|
||||
self.get_speed.grid(row=0, column=1)
|
||||
|
||||
def show_init(self):
|
||||
# display. 显示
|
||||
tk.Label(self.frmLC, text="Joint 1 ").grid(row=0)
|
||||
tk.Label(self.frmLC, text="Joint 2 ").grid(row=1)
|
||||
tk.Label(self.frmLC, text="Joint 3 ").grid(row=2)
|
||||
|
||||
self.cont_1 = tk.StringVar(self.frmLC)
|
||||
self.cont_1.set(str(self.res_angles[0]) + "°")
|
||||
self.cont_2 = tk.StringVar(self.frmLC)
|
||||
self.cont_2.set(str(self.res_angles[1]) + "°")
|
||||
self.cont_3 = tk.StringVar(self.frmLC)
|
||||
self.cont_3.set(str(self.res_angles[2]) + "°")
|
||||
|
||||
|
||||
self.cont_all = [
|
||||
self.cont_1,
|
||||
self.cont_2,
|
||||
self.cont_3,
|
||||
self.speed,
|
||||
]
|
||||
|
||||
self.show_j1 = tk.Label(
|
||||
self.frmLC,
|
||||
textvariable=self.cont_1,
|
||||
font=("Arial", 9),
|
||||
width=7,
|
||||
height=1,
|
||||
bg="white",
|
||||
).grid(row=0, column=1, padx=0, pady=5)
|
||||
|
||||
self.show_j2 = tk.Label(
|
||||
self.frmLC,
|
||||
textvariable=self.cont_2,
|
||||
font=("Arial", 9),
|
||||
width=7,
|
||||
height=1,
|
||||
bg="white",
|
||||
).grid(row=1, column=1, padx=0, pady=5)
|
||||
self.show_j3 = tk.Label(
|
||||
self.frmLC,
|
||||
textvariable=self.cont_3,
|
||||
font=("Arial", 9),
|
||||
width=7,
|
||||
height=1,
|
||||
bg="white",
|
||||
).grid(row=2, column=1, padx=0, pady=5)
|
||||
|
||||
self.all_jo = [
|
||||
self.show_j1,
|
||||
self.show_j2,
|
||||
self.show_j3,
|
||||
]
|
||||
|
||||
# display. 显示
|
||||
tk.Label(self.frmLC, text=" x ").grid(row=0, column=3)
|
||||
tk.Label(self.frmLC, text=" y ").grid(row=1, column=3) # the second row. 第二行
|
||||
tk.Label(self.frmLC, text=" z ").grid(row=2, column=3)
|
||||
|
||||
self.coord_x = tk.StringVar()
|
||||
self.coord_x.set(str(self.record_coords[0]))
|
||||
self.coord_y = tk.StringVar()
|
||||
self.coord_y.set(str(self.record_coords[1]))
|
||||
self.coord_z = tk.StringVar()
|
||||
self.coord_z.set(str(self.record_coords[2]))
|
||||
|
||||
|
||||
self.coord_all = [
|
||||
self.coord_x,
|
||||
self.coord_y,
|
||||
self.coord_z,
|
||||
self.speed,
|
||||
]
|
||||
|
||||
self.show_x = tk.Label(
|
||||
self.frmLC,
|
||||
textvariable=self.coord_x,
|
||||
font=("Arial", 9),
|
||||
width=7,
|
||||
height=1,
|
||||
bg="white",
|
||||
).grid(row=0, column=4, padx=5, pady=5)
|
||||
self.show_y = tk.Label(
|
||||
self.frmLC,
|
||||
textvariable=self.coord_y,
|
||||
font=("Arial", 9),
|
||||
width=7,
|
||||
height=1,
|
||||
bg="white",
|
||||
).grid(row=1, column=4, padx=5, pady=5)
|
||||
self.show_z = tk.Label(
|
||||
self.frmLC,
|
||||
textvariable=self.coord_z,
|
||||
font=("Arial", 9),
|
||||
width=7,
|
||||
height=1,
|
||||
bg="white",
|
||||
).grid(row=2, column=4, padx=5, pady=5)
|
||||
|
||||
# show label"mm" .mm 单位展示
|
||||
self.unit = tk.StringVar()
|
||||
self.unit.set("mm")
|
||||
for i in range(4):
|
||||
tk.Label(self.frmLC, textvariable=self.unit, font=("Arial", 9)).grid(
|
||||
row=i, column=5
|
||||
)
|
||||
|
||||
def gripper_open(self):
|
||||
try:
|
||||
self.switch_gripper(True)
|
||||
except ServiceException:
|
||||
pass
|
||||
|
||||
def gripper_close(self):
|
||||
try:
|
||||
self.switch_gripper(False)
|
||||
except ServiceException:
|
||||
pass
|
||||
|
||||
def get_coord_input(self):
|
||||
# Get the data input by coord and send it to the robotic arm
|
||||
# 获取 coord 输入的数据,发送给机械臂
|
||||
c_value = []
|
||||
for i in self.all_c:
|
||||
# print(type(i.get()))
|
||||
c_value.append(float(i.get()))
|
||||
self.speed = (
|
||||
int(float(self.get_speed.get())) if self.get_speed.get() else self.speed
|
||||
)
|
||||
c_value.append(self.speed)
|
||||
c_value.append(self.model)
|
||||
# print(c_value)
|
||||
try:
|
||||
self.set_coords(*c_value)
|
||||
except ServiceException:
|
||||
pass
|
||||
self.show_j_date(c_value[:-2], "coord")
|
||||
|
||||
def get_joint_input(self):
|
||||
# Get the data of the joint and send it to the robotic arm
|
||||
# 获取joint输入的数据,发送给机械臂
|
||||
j_value = []
|
||||
for i in self.all_j:
|
||||
# print(type(i.get()))
|
||||
j_value.append(float(i.get()))
|
||||
self.speed = (
|
||||
int(float(self.get_speed.get())) if self.get_speed.get() else self.speed
|
||||
)
|
||||
j_value.append(self.speed)
|
||||
|
||||
try:
|
||||
self.set_angles(*j_value)
|
||||
except ServiceException:
|
||||
pass
|
||||
self.show_j_date(j_value[:-1])
|
||||
# return j_value,c_value,speed
|
||||
|
||||
def get_date(self):
|
||||
# Get the data of robotic arm for display. 拿机械臂的数据,用于展示
|
||||
t = time.time()
|
||||
while time.time() - t < 2:
|
||||
self.res = self.get_coords()
|
||||
|
||||
print(self.res)
|
||||
|
||||
if self.res.x > 1:
|
||||
break
|
||||
time.sleep(0.1)
|
||||
|
||||
t = time.time()
|
||||
while time.time() - t < 2:
|
||||
self.angles = self.get_angles()
|
||||
if self.angles.joint_1 > 1:
|
||||
break
|
||||
time.sleep(0.1)
|
||||
# print(self.angles.joint_1)
|
||||
self.record_coords = [
|
||||
round(self.res.x, 2),
|
||||
round(self.res.y, 2),
|
||||
round(self.res.z, 2),
|
||||
self.speed,
|
||||
]
|
||||
self.res_angles = [
|
||||
round(self.angles.joint_1, 2),
|
||||
round(self.angles.joint_2, 2),
|
||||
round(self.angles.joint_3, 2),
|
||||
]
|
||||
# print('coord:',self.record_coords)
|
||||
# print('angles:',self.res_angles)
|
||||
|
||||
# def send_input(self,dates):
|
||||
def show_j_date(self, date, way=""):
|
||||
# Show data. 展示数据
|
||||
if way == "coord":
|
||||
for i, j in zip(date, self.coord_all):
|
||||
# print(i)
|
||||
j.set(str(i))
|
||||
else:
|
||||
for i, j in zip(date, self.cont_all):
|
||||
j.set(str(i) + "°")
|
||||
|
||||
def run(self):
|
||||
while True:
|
||||
try:
|
||||
self.win.update()
|
||||
time.sleep(0.001)
|
||||
except tk.TclError as e:
|
||||
if "application has been destroyed" in str(e):
|
||||
break
|
||||
else:
|
||||
raise
|
||||
|
||||
|
||||
def main():
|
||||
window = tk.Tk()
|
||||
window.title("mycobot ros GUI")
|
||||
Window(window).run()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
51
Mira/mira/scripts/slider_control.py
Normal file
51
Mira/mira/scripts/slider_control.py
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
"""[summary]
|
||||
This file obtains the joint angle of the manipulator in ROS,
|
||||
and then sends it directly to the real manipulator using `pymycobot` API.
|
||||
This file is [slider_control.launch] related script.
|
||||
Passable parameters:
|
||||
port: serial prot string. Defaults is '/dev/ttyUSB0'
|
||||
baud: serial prot baudrate. Defaults is 115200.
|
||||
"""
|
||||
|
||||
import rospy
|
||||
from sensor_msgs.msg import JointState
|
||||
|
||||
# from pymycobot.mycobot import MyCobot
|
||||
from pymycobot.mypalletizer import MyPalletizer
|
||||
|
||||
|
||||
mc = None
|
||||
|
||||
|
||||
def callback(data):
|
||||
# rospy.loginfo(rospy.get_caller_id() + "%s", data.position)
|
||||
print(data.position)
|
||||
data_list = []
|
||||
for index, value in enumerate(data.position):
|
||||
data_list.append(value)
|
||||
|
||||
# print(data_list)
|
||||
mc.send_radians(data_list, 80)
|
||||
# time.sleep(0.5)
|
||||
|
||||
|
||||
def listener():
|
||||
global mc
|
||||
rospy.init_node("control_slider", anonymous=True)
|
||||
|
||||
rospy.Subscriber("joint_states", JointState, callback)
|
||||
port = rospy.get_param("~port", "/dev/ttyUSB0") # Select connected device. 选择连接设备
|
||||
baud = rospy.get_param("~baud", 115200)
|
||||
print(port, baud)
|
||||
mc = MyPalletizer(port, baud)
|
||||
|
||||
# spin() simply keeps python from exiting until this node is stopped
|
||||
# spin() 只是阻止python退出,直到该节点停止
|
||||
print("spin ...")
|
||||
rospy.spin()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
listener()
|
||||
159
Mira/mira/scripts/teleop_keyboard.py
Normal file
159
Mira/mira/scripts/teleop_keyboard.py
Normal file
|
|
@ -0,0 +1,159 @@
|
|||
#!/usr/bin/env python3
|
||||
from __future__ import print_function
|
||||
# from mycobot_communication.srv import GetCoords, SetCoords, GetAngles, SetAngles, GripperStatus
|
||||
from mira_communication.srv import GetCoords, SetCoords, GetAngles, SetAngles, GripperStatus
|
||||
import rospy
|
||||
import sys
|
||||
import select
|
||||
import termios
|
||||
import tty
|
||||
import time
|
||||
|
||||
import roslib
|
||||
|
||||
# Terminal output prompt information. 终端输出提示信息
|
||||
msg = """\
|
||||
Mira Teleop Keyboard Controller
|
||||
---------------------------
|
||||
Movimg options(control coordinations [x,y,z]):
|
||||
w(x+)
|
||||
|
||||
a(y-) s(x-) d(y+)
|
||||
|
||||
z(z-) x(z+)
|
||||
|
||||
|
||||
|
||||
Gripper control:
|
||||
g - open
|
||||
h - close
|
||||
|
||||
Other:
|
||||
1 - Go to init pose
|
||||
2 - Go to home pose
|
||||
3 - Resave home pose
|
||||
q - Quit
|
||||
"""
|
||||
|
||||
|
||||
def vels(speed, turn):
|
||||
return "currently:\tspeed: %s\tchange percent: %s " % (speed, turn)
|
||||
|
||||
|
||||
class Raw(object):
|
||||
def __init__(self, stream):
|
||||
self.stream = stream
|
||||
self.fd = self.stream.fileno()
|
||||
|
||||
def __enter__(self):
|
||||
self.original_stty = termios.tcgetattr(self.stream)
|
||||
tty.setcbreak(self.stream)
|
||||
|
||||
def __exit__(self, type, value, traceback):
|
||||
termios.tcsetattr(self.stream, termios.TCSANOW, self.original_stty)
|
||||
|
||||
|
||||
def teleop_keyboard():
|
||||
rospy.init_node("teleop_keyboard")
|
||||
|
||||
model = 0
|
||||
speed = rospy.get_param("~speed", 40)
|
||||
change_percent = rospy.get_param("~change_percent", 5)
|
||||
|
||||
change_angle = 180 * change_percent / 100
|
||||
change_len = 250 * change_percent / 100
|
||||
|
||||
rospy.wait_for_service("get_joint_angles")
|
||||
rospy.wait_for_service("set_joint_angles")
|
||||
rospy.wait_for_service("get_joint_coords")
|
||||
rospy.wait_for_service("set_joint_coords")
|
||||
rospy.wait_for_service("switch_gripper_status")
|
||||
print("service ready.")
|
||||
try:
|
||||
get_coords = rospy.ServiceProxy("get_joint_coords", GetCoords)
|
||||
set_coords = rospy.ServiceProxy("set_joint_coords", SetCoords)
|
||||
get_angles = rospy.ServiceProxy("get_joint_angles", GetAngles)
|
||||
set_angles = rospy.ServiceProxy("set_joint_angles", SetAngles)
|
||||
switch_gripper = rospy.ServiceProxy(
|
||||
"switch_gripper_status", GripperStatus)
|
||||
except:
|
||||
print("start error ...")
|
||||
exit(1)
|
||||
|
||||
|
||||
init_pose = [0, 0,0, speed]
|
||||
home_pose = [0,30, 30,speed]
|
||||
|
||||
# rsp = set_angles(*init_pose)
|
||||
|
||||
while True:
|
||||
res = get_coords()
|
||||
if res.x > 1:
|
||||
break
|
||||
time.sleep(0.1)
|
||||
|
||||
record_coords = [res.x, res.y, res.z, speed, model]
|
||||
|
||||
print(record_coords)
|
||||
|
||||
try:
|
||||
print(msg)
|
||||
print(vels(speed, change_percent))
|
||||
# Keyboard keys call different motion functions. 键盘按键调用不同的运动功能
|
||||
while 1:
|
||||
try:
|
||||
# print("\r current coords: %s" % record_coords, end="")
|
||||
with Raw(sys.stdin):
|
||||
key = sys.stdin.read(1)
|
||||
if key == "q":
|
||||
break
|
||||
elif key in ["w", "W"]:
|
||||
record_coords[0] += change_len
|
||||
set_coords(*record_coords)
|
||||
elif key in ["s", "S"]:
|
||||
record_coords[0] -= change_len
|
||||
set_coords(*record_coords)
|
||||
elif key in ["a", "A"]:
|
||||
record_coords[1] -= change_len
|
||||
set_coords(*record_coords)
|
||||
elif key in ["d", "D"]:
|
||||
record_coords[1] += change_len
|
||||
set_coords(*record_coords)
|
||||
elif key in ["z", "Z"]:
|
||||
record_coords[2] -= change_len
|
||||
set_coords(*record_coords)
|
||||
elif key in ["x", "X"]:
|
||||
record_coords[2] += change_len
|
||||
set_coords(*record_coords)
|
||||
elif key in ["g", "G"]:
|
||||
switch_gripper(True)
|
||||
elif key in ["h", "H"]:
|
||||
switch_gripper(False)
|
||||
elif key == "1":
|
||||
rsp = set_angles(*init_pose)
|
||||
record_coords = [res.x, res.y, res.z, speed, model]
|
||||
elif key in "2":
|
||||
rsp = set_angles(*home_pose)
|
||||
record_coords = [res.x, res.y, res.z, speed, model]
|
||||
elif key in "3":
|
||||
rep = get_angles()
|
||||
home_pose[0] = rep.joint_1
|
||||
home_pose[1] = rep.joint_2
|
||||
home_pose[2] = rep.joint_3
|
||||
# home_pose[4] = rep.joint_5
|
||||
else:
|
||||
continue
|
||||
|
||||
except Exception as e:
|
||||
# print(e)
|
||||
continue
|
||||
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
try:
|
||||
teleop_keyboard()
|
||||
except rospy.ROSInterruptException:
|
||||
pass
|
||||
216
Mira/mira_communication/CMakeLists.txt
Normal file
216
Mira/mira_communication/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,216 @@
|
|||
cmake_minimum_required(VERSION 2.8.3)
|
||||
project(mira_communication)
|
||||
add_compile_options(-std=c++11)
|
||||
|
||||
## Compile as C++11, supported in ROS Kinetic and newer
|
||||
# add_compile_options(-std=c++11)
|
||||
|
||||
## Find catkin macros and libraries
|
||||
## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
|
||||
## is used, also find other catkin packages
|
||||
find_package(catkin REQUIRED COMPONENTS
|
||||
rospy
|
||||
std_msgs
|
||||
genmsg
|
||||
message_generation
|
||||
)
|
||||
|
||||
## System dependencies are found with CMake's conventions
|
||||
# find_package(Boost REQUIRED COMPONENTS system)
|
||||
|
||||
|
||||
## Uncomment this if the package has a setup.py. This macro ensures
|
||||
## modules and global scripts declared therein get installed
|
||||
## See http://ros.org/doc/api/catkin/html/user_guide/setup_dot_py.html
|
||||
# catkin_python_setup()
|
||||
|
||||
################################################
|
||||
## Declare ROS messages, services and actions ##
|
||||
################################################
|
||||
|
||||
## To declare and build messages, services or actions from within this
|
||||
## package, follow these steps:
|
||||
## * Let MSG_DEP_SET be the set of packages whose message types you use in
|
||||
## your messages/services/actions (e.g. std_msgs, actionlib_msgs, ...).
|
||||
## * In the file package.xml:
|
||||
## * add a build_depend tag for "message_generation"
|
||||
## * add a build_depend and a exec_depend tag for each package in MSG_DEP_SET
|
||||
## * If MSG_DEP_SET isn't empty the following dependency has been pulled in
|
||||
## but can be declared for certainty nonetheless:
|
||||
## * add a exec_depend tag for "message_runtime"
|
||||
## * In this file (CMakeLists.txt):
|
||||
## * add "message_generation" and every package in MSG_DEP_SET to
|
||||
## find_package(catkin REQUIRED COMPONENTS ...)
|
||||
## * add "message_runtime" and every package in MSG_DEP_SET to
|
||||
## catkin_package(CATKIN_DEPENDS ...)
|
||||
## * uncomment the add_*_files sections below as needed
|
||||
## and list every .msg/.srv/.action file to be processed
|
||||
## * uncomment the generate_messages entry below
|
||||
## * add every package in MSG_DEP_SET to generate_messages(DEPENDENCIES ...)
|
||||
|
||||
## Generate messages in the 'msg' folder
|
||||
add_message_files(FILES
|
||||
MiraAngles.msg
|
||||
MiraCoords.msg
|
||||
MiraSetAngles.msg
|
||||
MiraSetCoords.msg
|
||||
MiraGripperStatus.msg
|
||||
MiraPumpStatus.msg
|
||||
)
|
||||
|
||||
## Generate services in the 'srv' folder
|
||||
add_service_files(FILES
|
||||
GetAngles.srv
|
||||
SetAngles.srv
|
||||
GetCoords.srv
|
||||
SetCoords.srv
|
||||
GripperStatus.srv
|
||||
PumpStatus.srv
|
||||
)
|
||||
|
||||
## Generate added messages and services
|
||||
generate_messages(DEPENDENCIES std_msgs)
|
||||
|
||||
## Generate actions in the 'action' folder
|
||||
# add_action_files(
|
||||
# FILES
|
||||
# Action1.action
|
||||
# Action2.action
|
||||
# )
|
||||
|
||||
## Generate added messages and services with any dependencies listed here
|
||||
# generate_messages(
|
||||
# DEPENDENCIES
|
||||
# std_msgs # Or other packages containing msgs
|
||||
# )
|
||||
|
||||
################################################
|
||||
## Declare ROS dynamic reconfigure parameters ##
|
||||
################################################
|
||||
|
||||
## To declare and build dynamic reconfigure parameters within this
|
||||
## package, follow these steps:
|
||||
## * In the file package.xml:
|
||||
## * add a build_depend and a exec_depend tag for "dynamic_reconfigure"
|
||||
## * In this file (CMakeLists.txt):
|
||||
## * add "dynamic_reconfigure" to
|
||||
## find_package(catkin REQUIRED COMPONENTS ...)
|
||||
## * uncomment the "generate_dynamic_reconfigure_options" section below
|
||||
## and list every .cfg file to be processed
|
||||
|
||||
## Generate dynamic reconfigure parameters in the 'cfg' folder
|
||||
# generate_dynamic_reconfigure_options(
|
||||
# cfg/DynReconf1.cfg
|
||||
# cfg/DynReconf2.cfg
|
||||
# )
|
||||
|
||||
###################################
|
||||
## catkin specific configuration ##
|
||||
###################################
|
||||
## The catkin_package macro generates cmake config files for your package
|
||||
## Declare things to be passed to dependent projects
|
||||
## INCLUDE_DIRS: uncomment this if your package contains header files
|
||||
## LIBRARIES: libraries you create in this project that dependent projects also need
|
||||
## CATKIN_DEPENDS: catkin_packages dependent projects also need
|
||||
## DEPENDS: system dependencies of this project that dependent projects also need
|
||||
## Declare a catkin package
|
||||
catkin_package(
|
||||
CATKIN_DEPENDS message_runtime std_msgs
|
||||
)
|
||||
|
||||
###########
|
||||
## Build ##
|
||||
###########
|
||||
|
||||
## Specify additional locations of header files
|
||||
## Your package locations should be listed before other locations
|
||||
include_directories(
|
||||
# include
|
||||
# ${catkin_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
## Declare a C++ library
|
||||
# add_library(${PROJECT_NAME}
|
||||
# src/${PROJECT_NAME}/Mypal_commuication.cpp
|
||||
# )
|
||||
|
||||
## Add cmake target dependencies of the library
|
||||
## as an example, code may need to be generated before libraries
|
||||
## either from message generation or dynamic reconfigure
|
||||
# add_dependencies(${PROJECT_NAME} ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
|
||||
|
||||
## Declare a C++ executable
|
||||
## With catkin_make all packages are built within a single CMake context
|
||||
## The recommended prefix ensures that target names across packages don't collide
|
||||
# add_executable(${PROJECT_NAME}_node src/Mypal_commuication_node.cpp)
|
||||
|
||||
## Rename C++ executable without prefix
|
||||
## The above recommended prefix causes long target names, the following renames the
|
||||
## target back to the shorter version for ease of user use
|
||||
## e.g. "rosrun someones_pkg node" instead of "rosrun someones_pkg someones_pkg_node"
|
||||
# set_target_properties(${PROJECT_NAME}_node PROPERTIES OUTPUT_NAME node PREFIX "")
|
||||
|
||||
## Add cmake target dependencies of the executable
|
||||
## same as for the library above
|
||||
# add_dependencies(${PROJECT_NAME}_node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
|
||||
|
||||
## Specify libraries to link a library or executable target against
|
||||
# target_link_libraries(${PROJECT_NAME}_node
|
||||
# ${catkin_LIBRARIES}
|
||||
# )
|
||||
|
||||
#############
|
||||
## Install ##
|
||||
#############
|
||||
|
||||
# all install targets should use catkin DESTINATION variables
|
||||
# See http://ros.org/doc/api/catkin/html/adv_user_guide/variables.html
|
||||
|
||||
## Mark executable scripts (Python etc.) for installation
|
||||
## in contrast to setup.py, you can choose the destination
|
||||
catkin_install_python(PROGRAMS
|
||||
scripts/mira_services.py
|
||||
scripts/mira_topics.py
|
||||
DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
|
||||
)
|
||||
|
||||
## Mark executables for installation
|
||||
## See http://docs.ros.org/melodic/api/catkin/html/howto/format1/building_executables.html
|
||||
# install(TARGETS ${PROJECT_NAME}_node
|
||||
# RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
|
||||
# )
|
||||
|
||||
## Mark libraries for installation
|
||||
## See http://docs.ros.org/melodic/api/catkin/html/howto/format1/building_libraries.html
|
||||
# install(TARGETS ${PROJECT_NAME}
|
||||
# ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
|
||||
# LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
|
||||
# RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}
|
||||
# )
|
||||
|
||||
## Mark cpp header files for installation
|
||||
# install(DIRECTORY include/${PROJECT_NAME}/
|
||||
# DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
|
||||
# FILES_MATCHING PATTERN "*.h"
|
||||
# PATTERN ".svn" EXCLUDE
|
||||
# )
|
||||
|
||||
## Mark other files for installation (e.g. launch and bag files, etc.)
|
||||
# install(FILES
|
||||
# # myfile1
|
||||
# # myfile2
|
||||
# DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
|
||||
# )
|
||||
|
||||
#############
|
||||
## Testing ##
|
||||
#############
|
||||
|
||||
## Add gtest based cpp test target and link libraries
|
||||
# catkin_add_gtest(${PROJECT_NAME}-test test/test_Mypal_commuication.cpp)
|
||||
# if(TARGET ${PROJECT_NAME}-test)
|
||||
# target_link_libraries(${PROJECT_NAME}-test ${PROJECT_NAME})
|
||||
# endif()
|
||||
|
||||
## Add folders to be run by python nosetests
|
||||
# catkin_add_nosetests(test)
|
||||
25
Mira/mira_communication/LICENSE
Normal file
25
Mira/mira_communication/LICENSE
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
BSD 2-Clause License
|
||||
|
||||
Copyright (c) 2020, Elephant Robotics
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
10
Mira/mira_communication/launch/communication_jsnn.launch
Normal file
10
Mira/mira_communication/launch/communication_jsnn.launch
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<launch>
|
||||
<arg name="port" default="/dev/ttyUSB0" />
|
||||
<arg name="baud" default="115200" />
|
||||
|
||||
<!-- Open communication service -->
|
||||
<node name="mycobot_services" pkg="mycobot_communication" type="mycobot_topics_jsnn.py" output="screen">
|
||||
<param name="port" type="string" value="$(arg port)" />
|
||||
<param name="baud" type="int" value="$(arg baud)" />
|
||||
</node>
|
||||
</launch>
|
||||
10
Mira/mira_communication/launch/communication_seeed.launch
Normal file
10
Mira/mira_communication/launch/communication_seeed.launch
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<launch>
|
||||
<arg name="port" default="/dev/ttyUSB0" />
|
||||
<arg name="baud" default="115200" />
|
||||
|
||||
<!-- Open communication service -->
|
||||
<node name="mira_services" pkg="mira_communication" type="mira_topics_seeed.py" output="screen">
|
||||
<param name="port" type="string" value="$(arg port)" />
|
||||
<param name="baud" type="int" value="$(arg baud)" />
|
||||
</node>
|
||||
</launch>
|
||||
10
Mira/mira_communication/launch/communication_service.launch
Normal file
10
Mira/mira_communication/launch/communication_service.launch
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<launch>
|
||||
<arg name="port" default="/dev/ttyUSB0" />
|
||||
<arg name="baud" default="115200" />
|
||||
|
||||
<!-- Open communication service -->
|
||||
<node name="mira_services" pkg="mira_communication" type="mira_services.py" output="screen">
|
||||
<param name="port" type="string" value="$(arg port)" />
|
||||
<param name="baud" type="int" value="$(arg baud)" />
|
||||
</node>
|
||||
</launch>
|
||||
12
Mira/mira_communication/launch/communication_topic.launch
Normal file
12
Mira/mira_communication/launch/communication_topic.launch
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
<launch>
|
||||
<arg name="port" default="/dev/ttyUSB0" />
|
||||
<arg name="baud" default="115200" />
|
||||
|
||||
<!-- Open communication service -->
|
||||
<!-- <node name="mycobot_services" pkg="mycobot_communication" type="mycobot_topics.py" output="screen"> -->
|
||||
<node name="mira_services" pkg="mira_communication" type="mira_topics.py" output="screen">
|
||||
|
||||
<param name="port" type="string" value="$(arg port)" />
|
||||
<param name="baud" type="int" value="$(arg baud)" />
|
||||
</node>
|
||||
</launch>
|
||||
10
Mira/mira_communication/launch/communication_topic_pi.launch
Normal file
10
Mira/mira_communication/launch/communication_topic_pi.launch
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<launch>
|
||||
<arg name="port" default="/dev/ttyUSB0" />
|
||||
<arg name="baud" default="115200" />
|
||||
|
||||
<!-- Open communication service -->
|
||||
<node name="mycobot_services" pkg="mycobot_communication" type="mycobot_topics_pi.py" output="screen">
|
||||
<param name="port" type="string" value="$(arg port)" />
|
||||
<param name="baud" type="int" value="$(arg baud)" />
|
||||
</node>
|
||||
</launch>
|
||||
7
Mira/mira_communication/msg/MiraAngles.msg
Normal file
7
Mira/mira_communication/msg/MiraAngles.msg
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
# float32 base
|
||||
float32 joint_1
|
||||
float32 joint_2
|
||||
float32 joint_3
|
||||
# float32 joint_4
|
||||
# float32 joint_5
|
||||
# float32 joint_6
|
||||
6
Mira/mira_communication/msg/MiraCoords.msg
Normal file
6
Mira/mira_communication/msg/MiraCoords.msg
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
float32 x
|
||||
float32 y
|
||||
float32 z
|
||||
# float32 rx
|
||||
# float32 ry
|
||||
# float32 rz
|
||||
1
Mira/mira_communication/msg/MiraGripperStatus.msg
Normal file
1
Mira/mira_communication/msg/MiraGripperStatus.msg
Normal file
|
|
@ -0,0 +1 @@
|
|||
bool Status
|
||||
3
Mira/mira_communication/msg/MiraPumpStatus.msg
Normal file
3
Mira/mira_communication/msg/MiraPumpStatus.msg
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
bool Status
|
||||
int8 Pin1
|
||||
int8 Pin2
|
||||
9
Mira/mira_communication/msg/MiraSetAngles.msg
Normal file
9
Mira/mira_communication/msg/MiraSetAngles.msg
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
# float32 base
|
||||
float32 joint_1
|
||||
float32 joint_2
|
||||
float32 joint_3
|
||||
# float32 joint_4
|
||||
# float32 joint_5
|
||||
# float32 joint_6
|
||||
|
||||
int8 speed
|
||||
9
Mira/mira_communication/msg/MiraSetCoords.msg
Normal file
9
Mira/mira_communication/msg/MiraSetCoords.msg
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
float32 x
|
||||
float32 y
|
||||
float32 z
|
||||
# float32 rx
|
||||
# float32 ry
|
||||
# float32 rz
|
||||
|
||||
int8 speed
|
||||
int8 model
|
||||
86
Mira/mira_communication/package.xml
Normal file
86
Mira/mira_communication/package.xml
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
<?xml version="1.0"?>
|
||||
<package format="2">
|
||||
<name>mira_communication</name>
|
||||
<version>0.1.0</version>
|
||||
<description>The mira_communication package</description>
|
||||
|
||||
<!-- One maintainer tag required, multiple allowed, one person per tag -->
|
||||
<!-- Example: -->
|
||||
<!-- <maintainer email="jane.doe@example.com">Jane Doe</maintainer> -->
|
||||
<maintainer email="lijun.zhang@elephantrobotics.com">zachary</maintainer>
|
||||
|
||||
|
||||
<!-- One license tag required, multiple allowed, one license per tag -->
|
||||
<!-- Commonly used license strings: -->
|
||||
<!-- BSD, MIT, Boost Software License, GPLv2, GPLv3, LGPLv2.1, LGPLv3 -->
|
||||
<license>BSD</license>
|
||||
|
||||
|
||||
<!-- Url tags are optional, but multiple are allowed, one per tag -->
|
||||
<!-- Optional attribute type can be: website, bugtracker, or repository -->
|
||||
<!-- Example: -->
|
||||
<!-- <url type="website">http://wiki.ros.org/mycobot_commuication</url> -->
|
||||
|
||||
|
||||
<!-- Author tags are optional, multiple are allowed, one per tag -->
|
||||
<!-- Authors do not have to be maintainers, but could be -->
|
||||
<!-- Example: -->
|
||||
<!-- <author email="jane.doe@example.com">Jane Doe</author> -->
|
||||
|
||||
|
||||
<!-- The *depend tags are used to specify dependencies -->
|
||||
<!-- Dependencies can be catkin packages or system dependencies -->
|
||||
<!-- Examples: -->
|
||||
<!-- Use depend as a shortcut for packages that are both build and exec dependencies -->
|
||||
<!-- <depend>roscpp</depend> -->
|
||||
<!-- Note that this is equivalent to the following: -->
|
||||
<!-- <build_depend>roscpp</build_depend> -->
|
||||
<!-- <exec_depend>roscpp</exec_depend> -->
|
||||
<!-- Use build_depend for packages you need at compile time: -->
|
||||
<!-- <build_depend>message_generation</build_depend> -->
|
||||
<!-- Use build_export_depend for packages you need in order to build against this package: -->
|
||||
<!-- <build_export_depend>message_generation</build_export_depend> -->
|
||||
<!-- Use buildtool_depend for build tool packages: -->
|
||||
<!-- <buildtool_depend>catkin</buildtool_depend> -->
|
||||
<!-- Use exec_depend for packages you need at runtime: -->
|
||||
<!-- <exec_depend>message_runtime</exec_depend> -->
|
||||
<!-- Use test_depend for packages you need only for testing: -->
|
||||
<!-- <test_depend>gtest</test_depend> -->
|
||||
<!-- Use doc_depend for packages you need only for building documentation: -->
|
||||
<!-- <doc_depend>doxygen</doc_depend> -->
|
||||
<buildtool_depend>catkin</buildtool_depend>
|
||||
|
||||
<build_depend>rospy</build_depend>
|
||||
<build_depend>std_msgs</build_depend>
|
||||
<build_depend>message_generation</build_depend>
|
||||
<build_depend>roscpp</build_depend>
|
||||
<build_depend>rospy</build_depend>
|
||||
<build_depend>actionlib</build_depend>
|
||||
<build_depend>mycobot_description</build_depend>
|
||||
<!-- <build_depend>mypalletizer_communication</build_depend> -->
|
||||
|
||||
<!-- <build_export_depend>mypalletizer_communication</build_export_depend> -->
|
||||
<build_export_depend>mycobot_description</build_export_depend>
|
||||
|
||||
<exec_depend>roscpp</exec_depend>
|
||||
<exec_depend>rospy</exec_depend>
|
||||
<exec_depend>std_msgs</exec_depend>
|
||||
<exec_depend>actionlib</exec_depend>
|
||||
<exec_depend>joint_state_publisher</exec_depend>
|
||||
<exec_depend>joint_state_publisher_gui</exec_depend>
|
||||
<exec_depend>robot_state_publisher</exec_depend>
|
||||
<exec_depend>xacro</exec_depend>
|
||||
<exec_depend>joy</exec_depend>
|
||||
<exec_depend>rviz</exec_depend>
|
||||
<exec_depend>controller_manager</exec_depend>
|
||||
<exec_depend>python-tk</exec_depend>
|
||||
<exec_depend>mycobot_description</exec_depend>
|
||||
<exec_depend>message_runtime</exec_depend>
|
||||
<!-- <exec_depend>mypalletizer_communication</exec_depend> -->
|
||||
|
||||
<!-- The export tag contains other, unspecified, tags -->
|
||||
<export>
|
||||
<!-- Other tools can request additional information be placed here -->
|
||||
|
||||
</export>
|
||||
</package>
|
||||
148
Mira/mira_communication/scripts/mira_services.py
Normal file
148
Mira/mira_communication/scripts/mira_services.py
Normal file
|
|
@ -0,0 +1,148 @@
|
|||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
import time
|
||||
import rospy
|
||||
# from mycobot_communication.srv import *
|
||||
from mira_communication.srv import *
|
||||
|
||||
# from pymycobot.mycobot import MyCobot
|
||||
from pymycobot.mypalletizer import MyPalletizer
|
||||
|
||||
mc = None
|
||||
|
||||
|
||||
def create_handle():
|
||||
global mc
|
||||
rospy.init_node("mira_services")
|
||||
rospy.loginfo("start ...")
|
||||
port = rospy.get_param("~port")
|
||||
baud = rospy.get_param("~baud")
|
||||
rospy.loginfo("%s,%s" % (port, baud))
|
||||
mc = MyPalletizer(port, baud)
|
||||
|
||||
|
||||
def create_services():
|
||||
rospy.Service("set_joint_angles", SetAngles, set_angles)
|
||||
rospy.Service("get_joint_angles", GetAngles, get_angles)
|
||||
rospy.Service("set_joint_coords", SetCoords, set_coords)
|
||||
rospy.Service("get_joint_coords", GetCoords, get_coords)
|
||||
rospy.Service("switch_gripper_status", GripperStatus, switch_status)
|
||||
rospy.Service("switch_pump_status", PumpStatus, toggle_pump)
|
||||
rospy.loginfo("ready")
|
||||
rospy.spin()
|
||||
|
||||
|
||||
def set_angles(req):
|
||||
angles = [
|
||||
req.joint_1,
|
||||
req.joint_2,
|
||||
req.joint_3,
|
||||
# req.joint_4,
|
||||
# req.joint_5,
|
||||
# req.joint_6,
|
||||
]
|
||||
sp = req.speed
|
||||
|
||||
if mc:
|
||||
mc.send_angles(angles, sp)
|
||||
|
||||
return SetAnglesResponse(True)
|
||||
|
||||
|
||||
def get_angles(req):
|
||||
if mc:
|
||||
angles = mc.get_angles()
|
||||
return GetAnglesResponse(*angles)
|
||||
|
||||
|
||||
def set_coords(req):
|
||||
coords = [
|
||||
req.x,
|
||||
req.y,
|
||||
req.z,
|
||||
# req.rx,
|
||||
# req.ry,
|
||||
# req.rz,
|
||||
]
|
||||
sp = req.speed
|
||||
mod = req.model
|
||||
|
||||
if mc:
|
||||
mc.send_coords(coords, sp, mod)
|
||||
|
||||
return SetCoordsResponse(True)
|
||||
|
||||
|
||||
def get_coords(req):
|
||||
if mc:
|
||||
coords = mc.get_coords()
|
||||
return GetCoordsResponse(*coords)
|
||||
|
||||
|
||||
def switch_status(req):
|
||||
"""Gripper switch,夹爪开关"""
|
||||
if mc:
|
||||
if req.Status:
|
||||
mc.set_gripper_state(0, 80)
|
||||
else:
|
||||
mc.set_gripper_state(1, 80)
|
||||
|
||||
return GripperStatusResponse(True)
|
||||
|
||||
|
||||
def toggle_pump(req):
|
||||
if mc:
|
||||
if req.Status:
|
||||
mc.set_basic_output(req.Pin1, 0)
|
||||
mc.set_basic_output(req.Pin2, 0)
|
||||
else:
|
||||
mc.set_basic_output(req.Pin1, 1)
|
||||
mc.set_basic_output(req.Pin2, 1)
|
||||
|
||||
return PumpStatusResponse(True)
|
||||
|
||||
|
||||
robot_msg = """
|
||||
Mira Status
|
||||
--------------------------------
|
||||
Joint Limit:
|
||||
joint 1: -170 ~ +170
|
||||
joint 2: 0 ~ 90
|
||||
joint 3: 0 ~ 75
|
||||
|
||||
Connect Status: %s
|
||||
|
||||
Servo Infomation: %s
|
||||
|
||||
Servo Temperature: %s
|
||||
|
||||
Atom Version: %s
|
||||
"""
|
||||
|
||||
|
||||
def output_robot_message():
|
||||
connect_status = False
|
||||
servo_infomation = "unknown"
|
||||
servo_temperature = "unknown"
|
||||
atom_version = "unknown"
|
||||
|
||||
if mc:
|
||||
cn = mc.is_controller_connected()
|
||||
if cn == 1:
|
||||
connect_status = True
|
||||
time.sleep(0.1)
|
||||
si = mc.is_all_servo_enable()
|
||||
if si == 1:
|
||||
servo_infomation = "all connected"
|
||||
|
||||
print(
|
||||
robot_msg % (connect_status, servo_infomation,
|
||||
servo_temperature, atom_version)
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
# print(MyCobot.__dict__)
|
||||
create_handle()
|
||||
output_robot_message()
|
||||
create_services()
|
||||
217
Mira/mira_communication/scripts/mira_topics.py
Normal file
217
Mira/mira_communication/scripts/mira_topics.py
Normal file
|
|
@ -0,0 +1,217 @@
|
|||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
import time
|
||||
import os
|
||||
import sys
|
||||
import signal
|
||||
import threading
|
||||
|
||||
import rospy
|
||||
from pymycobot.mypalletizer import MyPalletizer
|
||||
|
||||
from mira_communication import(
|
||||
MiraAngles,
|
||||
MiraCoords,
|
||||
MiraSetAngles,
|
||||
MiraSetCoords,
|
||||
MiraGripperStatus,
|
||||
MiraPumpStatus,
|
||||
)
|
||||
|
||||
|
||||
class Watcher:
|
||||
"""this class solves two problems with multithreaded
|
||||
programs in Python, (1) a signal might be delivered
|
||||
to any thread (which is just a malfeature) and (2) if
|
||||
the thread that gets the signal is waiting, the signal
|
||||
is ignored (which is a bug).
|
||||
|
||||
The watcher is a concurrent process (not thread) that
|
||||
waits for a signal and the process that contains the
|
||||
threads. See Appendix A of The Little Book of Semaphores.
|
||||
http://greenteapress.com/semaphores/
|
||||
|
||||
I have only tested this on Linux. I would expect it to
|
||||
work on the Macintosh and not work on Windows.
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
"""Creates a child thread, which returns. The parent
|
||||
thread waits for a KeyboardInterrupt and then kills
|
||||
the child thread.
|
||||
"""
|
||||
self.child = os.fork()
|
||||
if self.child == 0:
|
||||
return
|
||||
else:
|
||||
self.watch()
|
||||
|
||||
def watch(self):
|
||||
try:
|
||||
os.wait()
|
||||
except KeyboardInterrupt:
|
||||
# I put the capital B in KeyBoardInterrupt so I can
|
||||
# tell when the Watcher gets the SIGINT
|
||||
print("KeyBoardInterrupt")
|
||||
self.kill()
|
||||
sys.exit()
|
||||
|
||||
def kill(self):
|
||||
try:
|
||||
os.kill(self.child, signal.SIGKILL)
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
|
||||
class MiraTopics(object):
|
||||
def __init__(self):
|
||||
super(MiraTopics, self).__init__()
|
||||
|
||||
rospy.init_node("Mira_topics")
|
||||
rospy.loginfo("start ...")
|
||||
port = rospy.get_param("~port", "/dev/ttyUSB0")
|
||||
baud = rospy.get_param("~baud", 115200)
|
||||
rospy.loginfo("%s,%s" % (port, baud))
|
||||
self.mc = MyPalletizer(port, baud)
|
||||
self.lock = threading.Lock()
|
||||
|
||||
def start(self):
|
||||
pa = threading.Thread(target=self.pub_real_angles)
|
||||
pb = threading.Thread(target=self.pub_real_coords)
|
||||
sa = threading.Thread(target=self.sub_set_angles)
|
||||
sb = threading.Thread(target=self.sub_set_coords)
|
||||
sg = threading.Thread(target=self.sub_gripper_status)
|
||||
sp = threading.Thread(target=self.sub_pump_status)
|
||||
|
||||
pa.setDaemon(True)
|
||||
pa.start()
|
||||
pb.setDaemon(True)
|
||||
pb.start()
|
||||
sa.setDaemon(True)
|
||||
sa.start()
|
||||
sb.setDaemon(True)
|
||||
sb.start()
|
||||
sg.setDaemon(True)
|
||||
sg.start()
|
||||
sp.setDaemon(True)
|
||||
sp.start()
|
||||
|
||||
pa.join()
|
||||
pb.join()
|
||||
sa.join()
|
||||
sb.join()
|
||||
sg.join()
|
||||
sp.join()
|
||||
|
||||
def pub_real_angles(self):
|
||||
"""Publish real angle"""
|
||||
"""发布真实角度"""
|
||||
pub = rospy.Publisher("Mypal/angles_real",
|
||||
MiraAngles, queue_size=5)
|
||||
ma = MiraAngles()
|
||||
while not rospy.is_shutdown():
|
||||
self.lock.acquire()
|
||||
angles = self.mc.get_angles()
|
||||
self.lock.release()
|
||||
if angles:
|
||||
ma.joint_1 = angles[0]
|
||||
ma.joint_2 = angles[1]
|
||||
ma.joint_3 = angles[2]
|
||||
ma.joint_4 = angles[3]
|
||||
# ma.joint_5 = angles[4]
|
||||
# ma.joint_6 = angles[5]
|
||||
pub.publish(ma)
|
||||
time.sleep(0.25)
|
||||
|
||||
def pub_real_coords(self):
|
||||
"""publish real coordinates"""
|
||||
"""发布真实坐标"""
|
||||
pub = rospy.Publisher("Mypal/coords_real",
|
||||
MiraCoords, queue_size=5)
|
||||
ma = MiraCoords()
|
||||
|
||||
while not rospy.is_shutdown():
|
||||
self.lock.acquire()
|
||||
coords = self.mc.get_coords()
|
||||
self.lock.release()
|
||||
if coords:
|
||||
ma.x = coords[0]
|
||||
ma.y = coords[1]
|
||||
ma.z = coords[2]
|
||||
ma.rx = coords[3]
|
||||
# ma.ry = coords[4]
|
||||
# ma.rz = coords[5]
|
||||
pub.publish(ma)
|
||||
time.sleep(0.25)
|
||||
|
||||
def sub_set_angles(self):
|
||||
"""subscription angles"""
|
||||
"""订阅角度"""
|
||||
def callback(data):
|
||||
angles = [
|
||||
data.joint_1,
|
||||
data.joint_2,
|
||||
data.joint_3,
|
||||
data.joint_4,
|
||||
# data.joint_5,
|
||||
# data.joint_6,
|
||||
]
|
||||
sp = int(data.speed)
|
||||
self.mc.send_angles(angles, sp)
|
||||
|
||||
sub = rospy.Subscriber(
|
||||
"Mypal/angles_goal", MiraSetAngles, callback=callback
|
||||
)
|
||||
rospy.spin()
|
||||
|
||||
def sub_set_coords(self):
|
||||
def callback(data):
|
||||
# angles = [data.x, data.y, data.z, data.rx, data.ry, data.rz]
|
||||
angles = [data.x, data.y, data.z, data.rx]
|
||||
|
||||
sp = int(data.speed)
|
||||
model = int(data.model)
|
||||
self.mc.send_coords(angles, sp, model)
|
||||
|
||||
sub = rospy.Subscriber(
|
||||
"Mypal/coords_goal", MiraSetCoords, callback=callback
|
||||
)
|
||||
rospy.spin()
|
||||
|
||||
def sub_gripper_status(self):
|
||||
"""Subscribe to Gripper Status"""
|
||||
"""订阅夹爪状态"""
|
||||
def callback(data):
|
||||
if data.Status:
|
||||
self.mc.set_gripper_state(0, 80)
|
||||
else:
|
||||
self.mc.set_gripper_state(1, 80)
|
||||
|
||||
sub = rospy.Subscriber(
|
||||
"Mypal/gripper_status", MiraGripperStatus, callback=callback
|
||||
)
|
||||
rospy.spin()
|
||||
|
||||
def sub_pump_status(self):
|
||||
def callback(data):
|
||||
if data.Status:
|
||||
self.mc.set_basic_output(data.Pin1, 0)
|
||||
self.mc.set_basic_output(data.Pin2, 0)
|
||||
else:
|
||||
self.mc.set_basic_output(data.Pin1, 1)
|
||||
self.mc.set_basic_output(data.Pin2, 1)
|
||||
|
||||
sub = rospy.Subscriber(
|
||||
"Mypal/pump_status", MiraPumpStatus, callback=callback
|
||||
)
|
||||
rospy.spin()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
Watcher()
|
||||
mc_topics = MiraTopics()
|
||||
mc_topics.start()
|
||||
# while True:
|
||||
# mc_topics.pub_real_coords()
|
||||
# mc_topics.sub_set_angles()
|
||||
pass
|
||||
213
Mira/mira_communication/scripts/mira_topics_seeed.py
Normal file
213
Mira/mira_communication/scripts/mira_topics_seeed.py
Normal file
|
|
@ -0,0 +1,213 @@
|
|||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
import time
|
||||
import os
|
||||
import sys
|
||||
import signal
|
||||
import threading
|
||||
|
||||
import rospy
|
||||
|
||||
from mira_communication import (
|
||||
MiraAngles,
|
||||
MiraCoords,
|
||||
MiraSetAngles,
|
||||
MiraSetCoords,
|
||||
MiraGripperStatus,
|
||||
MiraPumpStatus,
|
||||
)
|
||||
from pymycobot.mypalletizer import Mypalletizer
|
||||
|
||||
|
||||
class Watcher:
|
||||
"""this class solves two problems with multithreaded
|
||||
programs in Python, (1) a signal might be delivered
|
||||
to any thread (which is just a malfeature) and (2) if
|
||||
the thread that gets the signal is waiting, the signal
|
||||
is ignored (which is a bug).
|
||||
|
||||
The watcher is a concurrent process (not thread) that
|
||||
waits for a signal and the process that contains the
|
||||
threads. See Appendix A of The Little Book of Semaphores.
|
||||
http://greenteapress.com/semaphores/
|
||||
|
||||
I have only tested this on Linux. I would expect it to
|
||||
work on the Macintosh and not work on Windows.
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
"""Creates a child thread, which returns. The parent
|
||||
thread waits for a KeyboardInterrupt and then kills
|
||||
the child thread.
|
||||
"""
|
||||
self.child = os.fork()
|
||||
if self.child == 0:
|
||||
return
|
||||
else:
|
||||
self.watch()
|
||||
|
||||
def watch(self):
|
||||
try:
|
||||
os.wait()
|
||||
except KeyboardInterrupt:
|
||||
# I put the capital B in KeyBoardInterrupt so I can
|
||||
# tell when the Watcher gets the SIGINT
|
||||
print("KeyBoardInterrupt")
|
||||
self.kill()
|
||||
sys.exit()
|
||||
|
||||
def kill(self):
|
||||
try:
|
||||
os.kill(self.child, signal.SIGKILL)
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
|
||||
class MiraTopics(object):
|
||||
def __init__(self):
|
||||
super(MiraTopics, self).__init__()
|
||||
|
||||
rospy.init_node("Mira_topics")
|
||||
rospy.loginfo("start ...")
|
||||
# problem
|
||||
port = rospy.get_param("~port", "/dev/ttyUSB0")
|
||||
baud = rospy.get_param("~baud", 115200)
|
||||
rospy.loginfo("%s,%s" % (port, baud))
|
||||
self.mc = Mypalletizer(port,baud)
|
||||
self.lock = threading.Lock()
|
||||
|
||||
def start(self):
|
||||
pa = threading.Thread(target=self.pub_real_angles)
|
||||
pb = threading.Thread(target=self.pub_real_coords)
|
||||
sa = threading.Thread(target=self.sub_set_angles)
|
||||
sb = threading.Thread(target=self.sub_set_coords)
|
||||
sg = threading.Thread(target=self.sub_gripper_status)
|
||||
sp = threading.Thread(target=self.sub_pump_status)
|
||||
|
||||
pa.setDaemon(True)
|
||||
pa.start()
|
||||
pb.setDaemon(True)
|
||||
pb.start()
|
||||
sa.setDaemon(True)
|
||||
sa.start()
|
||||
sb.setDaemon(True)
|
||||
sb.start()
|
||||
sg.setDaemon(True)
|
||||
sg.start()
|
||||
sp.setDaemon(True)
|
||||
sp.start()
|
||||
|
||||
pa.join()
|
||||
pb.join()
|
||||
sa.join()
|
||||
sb.join()
|
||||
sg.join()
|
||||
sp.join()
|
||||
|
||||
def pub_real_angles(self):
|
||||
"""Publish real angle"""
|
||||
"""发布真实角度"""
|
||||
pub = rospy.Publisher("Mira/angles_real", MiraAngles, queue_size=5)
|
||||
ma = MiraAngles()
|
||||
while not rospy.is_shutdown():
|
||||
self.lock.acquire()
|
||||
angles = self.mc.get_angles()
|
||||
self.lock.release()
|
||||
if angles:
|
||||
ma.joint_1 = angles[0]
|
||||
ma.joint_2 = angles[1]
|
||||
ma.joint_3 = angles[2]
|
||||
ma.joint_4 = angles[3]
|
||||
# ma.joint_5 = angles[4]
|
||||
# ma.joint_6 = angles[5]
|
||||
pub.publish(ma)
|
||||
time.sleep(0.25)
|
||||
|
||||
def pub_real_coords(self):
|
||||
"""publish real coordinates"""
|
||||
"""发布真实坐标"""
|
||||
pub = rospy.Publisher("Mira/coords_real", MiraCoords, queue_size=5)
|
||||
ma = MiraCoords()
|
||||
|
||||
while not rospy.is_shutdown():
|
||||
self.lock.acquire()
|
||||
coords = self.mc.get_coords()
|
||||
self.lock.release()
|
||||
if coords:
|
||||
ma.x = coords[0]
|
||||
ma.y = coords[1]
|
||||
ma.z = coords[2]
|
||||
ma.rx = coords[3]
|
||||
# ma.ry = coords[4]
|
||||
# ma.rz = coords[5]
|
||||
pub.publish(ma)
|
||||
time.sleep(0.25)
|
||||
|
||||
def sub_set_angles(self):
|
||||
"""subscription angles"""
|
||||
"""订阅角度"""
|
||||
def callback(data):
|
||||
angles = [
|
||||
data.joint_1,
|
||||
data.joint_2,
|
||||
data.joint_3,
|
||||
data.joint_4,
|
||||
# data.joint_5,
|
||||
# data.joint_6,
|
||||
]
|
||||
sp = int(data.speed)
|
||||
self.mc.send_angles(angles, sp)
|
||||
|
||||
sub = rospy.Subscriber(
|
||||
"Mira/angles_goal", MiraSetAngles, callback=callback
|
||||
)
|
||||
rospy.spin()
|
||||
|
||||
def sub_set_coords(self):
|
||||
def callback(data):
|
||||
angles = [data.x, data.y, data.z, data.rx]
|
||||
sp = int(data.speed)
|
||||
model = int(data.model)
|
||||
self.mc.send_coords(angles, sp, model)
|
||||
|
||||
sub = rospy.Subscriber(
|
||||
"Mira/coords_goal", MiraSetCoords, callback=callback
|
||||
)
|
||||
rospy.spin()
|
||||
|
||||
def sub_gripper_status(self):
|
||||
"""Subscribe to Gripper Status"""
|
||||
"""订阅夹爪状态"""
|
||||
def callback(data):
|
||||
if data.Status:
|
||||
self.mc.set_gripper_state(0, 80)
|
||||
else:
|
||||
self.mc.set_gripper_state(1, 80)
|
||||
|
||||
sub = rospy.Subscriber(
|
||||
"Mira/gripper_status", MiraGripperStatus, callback=callback
|
||||
)
|
||||
rospy.spin()
|
||||
|
||||
def sub_pump_status(self):
|
||||
def callback(data):
|
||||
if data.Status:
|
||||
self.mc.set_basic_output(data.Pin1, 0)
|
||||
self.mc.set_basic_output(data.Pin2, 0)
|
||||
else:
|
||||
self.mc.set_basic_output(data.Pin1, 1)
|
||||
self.mc.set_basic_output(data.Pin2, 1)
|
||||
|
||||
sub = rospy.Subscriber(
|
||||
"Mira/pump_status", MiraPumpStatus, callback=callback
|
||||
)
|
||||
rospy.spin()
|
||||
|
||||
if __name__ == "__main__":
|
||||
Watcher()
|
||||
mc_topics = MiraTopics()
|
||||
mc_topics.start()
|
||||
# while True:
|
||||
# mc_topics.pub_real_coords()
|
||||
# mc_topics.sub_set_angles()
|
||||
pass
|
||||
7
Mira/mira_communication/scripts/test.py
Normal file
7
Mira/mira_communication/scripts/test.py
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
from pymycobot.mypalletizer import MyPalletizer
|
||||
mp = MyPalletizer("/dev/ttyUSB0", 115200)
|
||||
n = mp.get_angles()
|
||||
# while(1):
|
||||
# print(mp.get_angles())
|
||||
# print(mp.get_radians())
|
||||
mp.send_angles([100,0,0,150],30)
|
||||
11
Mira/mira_communication/srv/GetAngles.srv
Normal file
11
Mira/mira_communication/srv/GetAngles.srv
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
|
||||
---
|
||||
# float32 base
|
||||
float32 joint_1
|
||||
float32 joint_2
|
||||
float32 joint_3
|
||||
# float32 joint_4
|
||||
# float32 joint_5
|
||||
# float32 joint_6
|
||||
|
||||
|
||||
9
Mira/mira_communication/srv/GetCoords.srv
Normal file
9
Mira/mira_communication/srv/GetCoords.srv
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
|
||||
---
|
||||
|
||||
float32 x
|
||||
float32 y
|
||||
float32 z
|
||||
# float32 rx
|
||||
# float32 ry
|
||||
# float32 rz
|
||||
5
Mira/mira_communication/srv/GripperStatus.srv
Normal file
5
Mira/mira_communication/srv/GripperStatus.srv
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
bool Status
|
||||
|
||||
---
|
||||
|
||||
bool Flag
|
||||
7
Mira/mira_communication/srv/PumpStatus.srv
Normal file
7
Mira/mira_communication/srv/PumpStatus.srv
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
bool Status
|
||||
int8 Pin1
|
||||
int8 Pin2
|
||||
|
||||
---
|
||||
|
||||
bool Flag
|
||||
15
Mira/mira_communication/srv/SetAngles.srv
Normal file
15
Mira/mira_communication/srv/SetAngles.srv
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
# float32 base
|
||||
float32 joint_1
|
||||
float32 joint_2
|
||||
float32 joint_3
|
||||
# float32 joint_4
|
||||
# float32 joint_5
|
||||
# float32 joint_6
|
||||
|
||||
|
||||
|
||||
int8 speed
|
||||
|
||||
---
|
||||
|
||||
bool Flag
|
||||
13
Mira/mira_communication/srv/SetCoords.srv
Normal file
13
Mira/mira_communication/srv/SetCoords.srv
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
float32 x
|
||||
float32 y
|
||||
float32 z
|
||||
# float32 rx
|
||||
# float32 ry
|
||||
# float32 rz
|
||||
|
||||
int8 speed
|
||||
int8 model
|
||||
|
||||
---
|
||||
|
||||
bool Flag
|
||||
22
Mira/mira_moveit/CMakeLists.txt
Normal file
22
Mira/mira_moveit/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
cmake_minimum_required(VERSION 2.8.3)
|
||||
project(mira_moveit)
|
||||
|
||||
find_package(catkin REQUIRED
|
||||
rospy
|
||||
std_msgs
|
||||
moveit_msgs
|
||||
)
|
||||
|
||||
catkin_package()
|
||||
|
||||
## Mark executable scripts (Python etc.) for installation
|
||||
## in contrast to setup.py, you can choose the destination
|
||||
catkin_install_python(PROGRAMS
|
||||
scripts/sync_plan.py
|
||||
scripts/path_planning_and_obstacle_avoidance_demo.py
|
||||
DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
|
||||
)
|
||||
|
||||
install(DIRECTORY launch DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
|
||||
PATTERN "setup_assistant.launch" EXCLUDE)
|
||||
install(DIRECTORY config DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION})
|
||||
25
Mira/mira_moveit/LICENSE
Normal file
25
Mira/mira_moveit/LICENSE
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
BSD 2-Clause License
|
||||
|
||||
Copyright (c) 2020, Elephant Robotics
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
18
Mira/mira_moveit/config/chomp_planning.yaml
Normal file
18
Mira/mira_moveit/config/chomp_planning.yaml
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
planning_time_limit: 10.0
|
||||
max_iterations: 200
|
||||
max_iterations_after_collision_free: 5
|
||||
smoothness_cost_weight: 0.1
|
||||
obstacle_cost_weight: 1.0
|
||||
learning_rate: 0.01
|
||||
smoothness_cost_velocity: 0.0
|
||||
smoothness_cost_acceleration: 1.0
|
||||
smoothness_cost_jerk: 0.0
|
||||
ridge_factor: 0.01
|
||||
use_pseudo_inverse: false
|
||||
pseudo_inverse_ridge_factor: 1e-4
|
||||
joint_update_limit: 0.1
|
||||
collision_clearence: 0.2
|
||||
collision_threshold: 0.07
|
||||
use_stochastic_descent: true
|
||||
enable_failure_recovery: true
|
||||
max_recovery_attempts: 5
|
||||
10
Mira/mira_moveit/config/fake_controllers.yaml
Normal file
10
Mira/mira_moveit/config/fake_controllers.yaml
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
controller_list:
|
||||
- name: fake_arm_group_controller
|
||||
joints:
|
||||
- joint1_to_base
|
||||
- joint2_to_joint1
|
||||
- joint3_to_joint2
|
||||
# - joint4_to_joint3
|
||||
# - joint5_to_joint4
|
||||
|
||||
# - joint6output_to_joint6
|
||||
47
Mira/mira_moveit/config/firefighter.srdf
Normal file
47
Mira/mira_moveit/config/firefighter.srdf
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
<?xml version="1.0" ?>
|
||||
<!--This does not replace URDF, and is not an extension of URDF.
|
||||
This is a format for representing semantic information about the robot structure.
|
||||
A URDF file must exist for this robot as well, where the joints and the links that are referenced are defined
|
||||
-->
|
||||
<robot name="firefighter">
|
||||
<!--GROUPS: Representation of a set of joints and links. This can be useful for specifying DOF to plan for, defining arms, end effectors, etc-->
|
||||
<!--LINKS: When a link is specified, the parent joint of that link (if it exists) is automatically included-->
|
||||
<!--JOINTS: When a joint is specified, the child link of that joint (which will always exist) is automatically included-->
|
||||
<!--CHAINS: When a chain is specified, all the links along the chain (including endpoints) are included in the group. Additionally, all the joints that are parents to included links are also included. This means that joints along the chain and the parent joint of the base link are included in the group-->
|
||||
<!--SUBGROUPS: Groups can also be formed by referencing to already defined group names-->
|
||||
<group name="arm_group">
|
||||
<joint name="joint1_to_base" />
|
||||
<joint name="joint2_to_joint1" />
|
||||
<joint name="joint3_to_joint2" />
|
||||
<!-- <joint name="joint4_to_joint3" /> -->
|
||||
<!-- <joint name="joint5_to_joint4" /> -->
|
||||
|
||||
<!-- <joint name="joint6output_to_joint6" /> -->
|
||||
</group>
|
||||
<!--GROUP STATES: Purpose: Define a named state for a particular group, in terms of joint values. This is useful to define states like 'folded arms'-->
|
||||
<group_state name="init_pose" group="arm_group">
|
||||
<joint name="joint1_to_base" value="0" />
|
||||
<joint name="joint2_to_joint1" value="0" />
|
||||
<joint name="joint3_to_joint2" value="0" />
|
||||
<!-- <joint name="joint4_to_joint3" value="0" /> -->
|
||||
<!-- <joint name="joint5_to_joint4" value="0" /> -->
|
||||
<!-- <joint name="joint6_to_joint5" value="0" />
|
||||
<joint name="joint6output_to_joint6" value="0" /> -->
|
||||
</group_state>
|
||||
<!--VIRTUAL JOINT: Purpose: this element defines a virtual joint between a robot link and an external frame of reference (considered fixed with respect to the robot)-->
|
||||
<!-- <virtual_joint name="vitual_joint" type="fixed" parent_frame="basic" child_link="joint1" /> -->
|
||||
<virtual_joint name="vitual_joint" type="fixed" parent_frame="basic" child_link="base" />
|
||||
|
||||
<!--DISABLE COLLISIONS: By default it is assumed that any link of the robot could potentially come into collision with any other link in the robot. This tag disables collision checking between a specified pair of links. -->
|
||||
<disable_collisions link1="base" link2="link1" reason="Adjacent" />
|
||||
<disable_collisions link1="base" link2="link3" reason="Never" />
|
||||
<disable_collisions link1="link1" link2="link2" reason="Adjacent" />
|
||||
<disable_collisions link1="link1" link2="link3" reason="Never" />
|
||||
<disable_collisions link1="link2" link2="link3" reason="Adjacent" />
|
||||
<!-- <disable_collisions link1="link2" link2="link5" reason="Never" /> -->
|
||||
<!-- <disable_collisions link1="link3" link2="link4" reason="Adjacent" /> -->
|
||||
<!-- <disable_collisions link1="link3" link2="link5" reason="Never" /> -->
|
||||
<!-- <disable_collisions link1="link4" link2="link5" reason="Adjacent" /> -->
|
||||
|
||||
<!-- <disable_collisions link1="joint6" link2="joint6_flange" reason="Adjacent" /> -->
|
||||
</robot>
|
||||
39
Mira/mira_moveit/config/joint_limits.yaml
Normal file
39
Mira/mira_moveit/config/joint_limits.yaml
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
# joint_limits.yaml allows the dynamics properties specified in the URDF to be overwritten or augmented as needed
|
||||
# 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_to_base:
|
||||
has_velocity_limits: false
|
||||
max_velocity: 0
|
||||
has_acceleration_limits: false
|
||||
max_acceleration: 0
|
||||
joint2_to_joint1:
|
||||
has_velocity_limits: false
|
||||
max_velocity: 0
|
||||
has_acceleration_limits: false
|
||||
max_acceleration: 0
|
||||
joint3_to_joint2:
|
||||
has_velocity_limits: false
|
||||
max_velocity: 0
|
||||
has_acceleration_limits: false
|
||||
max_acceleration: 0
|
||||
# joint4_to_joint3:
|
||||
# has_velocity_limits: false
|
||||
# max_velocity: 0
|
||||
# has_acceleration_limits: false
|
||||
# max_acceleration: 0
|
||||
# joint5_to_joint4:
|
||||
# has_velocity_limits: false
|
||||
# max_velocity: 0
|
||||
# has_acceleration_limits: false
|
||||
# max_acceleration: 0
|
||||
# joint6_to_joint5:
|
||||
# has_velocity_limits: false
|
||||
# max_velocity: 0
|
||||
# has_acceleration_limits: false
|
||||
# max_acceleration: 0
|
||||
# joint6output_to_joint6:
|
||||
# has_velocity_limits: false
|
||||
# max_velocity: 0
|
||||
# has_acceleration_limits: false
|
||||
# max_acceleration: 0
|
||||
5
Mira/mira_moveit/config/kinematics.yaml
Normal file
5
Mira/mira_moveit/config/kinematics.yaml
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
arm_group:
|
||||
kinematics_solver: kdl_kinematics_plugin/KDLKinematicsPlugin
|
||||
kinematics_solver_search_resolution: 0.005
|
||||
kinematics_solver_timeout: 0.005
|
||||
kinematics_solver_attempts: 3
|
||||
150
Mira/mira_moveit/config/ompl_planning.yaml
Normal file
150
Mira/mira_moveit/config/ompl_planning.yaml
Normal file
|
|
@ -0,0 +1,150 @@
|
|||
planner_configs:
|
||||
SBL:
|
||||
type: geometric::SBL
|
||||
range: 0.0 # Max motion added to tree. ==> maxDistance_ default: 0.0, if 0.0, set on setup()
|
||||
EST:
|
||||
type: geometric::EST
|
||||
range: 0.0 # Max motion added to tree. ==> maxDistance_ default: 0.0, if 0.0 setup()
|
||||
goal_bias: 0.05 # When close to goal select goal, with this probability. default: 0.05
|
||||
LBKPIECE:
|
||||
type: geometric::LBKPIECE
|
||||
range: 0.0 # Max motion added to tree. ==> maxDistance_ default: 0.0, if 0.0, set on setup()
|
||||
border_fraction: 0.9 # Fraction of time focused on boarder default: 0.9
|
||||
min_valid_path_fraction: 0.5 # Accept partially valid moves above fraction. default: 0.5
|
||||
BKPIECE:
|
||||
type: geometric::BKPIECE
|
||||
range: 0.0 # Max motion added to tree. ==> maxDistance_ default: 0.0, if 0.0, set on setup()
|
||||
border_fraction: 0.9 # Fraction of time focused on boarder default: 0.9
|
||||
failed_expansion_score_factor: 0.5 # When extending motion fails, scale score by factor. default: 0.5
|
||||
min_valid_path_fraction: 0.5 # Accept partially valid moves above fraction. default: 0.5
|
||||
KPIECE:
|
||||
type: geometric::KPIECE
|
||||
range: 0.0 # Max motion added to tree. ==> maxDistance_ default: 0.0, if 0.0, set on setup()
|
||||
goal_bias: 0.05 # When close to goal select goal, with this probability. default: 0.05
|
||||
border_fraction: 0.9 # Fraction of time focused on boarder default: 0.9 (0.0,1.]
|
||||
failed_expansion_score_factor: 0.5 # When extending motion fails, scale score by factor. default: 0.5
|
||||
min_valid_path_fraction: 0.5 # Accept partially valid moves above fraction. default: 0.5
|
||||
RRT:
|
||||
type: geometric::RRT
|
||||
range: 0.0 # Max motion added to tree. ==> maxDistance_ default: 0.0, if 0.0, set on setup()
|
||||
goal_bias: 0.05 # When close to goal select goal, with this probability? default: 0.05
|
||||
RRTConnect:
|
||||
type: geometric::RRTConnect
|
||||
range: 0.0 # Max motion added to tree. ==> maxDistance_ default: 0.0, if 0.0, set on setup()
|
||||
RRTstar:
|
||||
type: geometric::RRTstar
|
||||
range: 0.0 # Max motion added to tree. ==> maxDistance_ default: 0.0, if 0.0, set on setup()
|
||||
goal_bias: 0.05 # When close to goal select goal, with this probability? default: 0.05
|
||||
delay_collision_checking: 1 # Stop collision checking as soon as C-free parent found. default 1
|
||||
TRRT:
|
||||
type: geometric::TRRT
|
||||
range: 0.0 # Max motion added to tree. ==> maxDistance_ default: 0.0, if 0.0, set on setup()
|
||||
goal_bias: 0.05 # When close to goal select goal, with this probability? default: 0.05
|
||||
max_states_failed: 10 # when to start increasing temp. default: 10
|
||||
temp_change_factor: 2.0 # how much to increase or decrease temp. default: 2.0
|
||||
min_temperature: 10e-10 # lower limit of temp change. default: 10e-10
|
||||
init_temperature: 10e-6 # initial temperature. default: 10e-6
|
||||
frountier_threshold: 0.0 # dist new state to nearest neighbor to disqualify as frontier. default: 0.0 set in setup()
|
||||
frountierNodeRatio: 0.1 # 1/10, or 1 nonfrontier for every 10 frontier. default: 0.1
|
||||
k_constant: 0.0 # value used to normalize expresssion. default: 0.0 set in setup()
|
||||
PRM:
|
||||
type: geometric::PRM
|
||||
max_nearest_neighbors: 10 # use k nearest neighbors. default: 10
|
||||
PRMstar:
|
||||
type: geometric::PRMstar
|
||||
FMT:
|
||||
type: geometric::FMT
|
||||
num_samples: 1000 # number of states that the planner should sample. default: 1000
|
||||
radius_multiplier: 1.1 # multiplier used for the nearest neighbors search radius. default: 1.1
|
||||
nearest_k: 1 # use Knearest strategy. default: 1
|
||||
cache_cc: 1 # use collision checking cache. default: 1
|
||||
heuristics: 0 # activate cost to go heuristics. default: 0
|
||||
extended_fmt: 1 # activate the extended FMT*: adding new samples if planner does not finish successfully. default: 1
|
||||
BFMT:
|
||||
type: geometric::BFMT
|
||||
num_samples: 1000 # number of states that the planner should sample. default: 1000
|
||||
radius_multiplier: 1.0 # multiplier used for the nearest neighbors search radius. default: 1.0
|
||||
nearest_k: 1 # use the Knearest strategy. default: 1
|
||||
balanced: 0 # exploration strategy: balanced true expands one tree every iteration. False will select the tree with lowest maximum cost to go. default: 1
|
||||
optimality: 1 # termination strategy: optimality true finishes when the best possible path is found. Otherwise, the algorithm will finish when the first feasible path is found. default: 1
|
||||
heuristics: 1 # activates cost to go heuristics. default: 1
|
||||
cache_cc: 1 # use the collision checking cache. default: 1
|
||||
extended_fmt: 1 # Activates the extended FMT*: adding new samples if planner does not finish successfully. default: 1
|
||||
PDST:
|
||||
type: geometric::PDST
|
||||
STRIDE:
|
||||
type: geometric::STRIDE
|
||||
range: 0.0 # Max motion added to tree. ==> maxDistance_ default: 0.0, if 0.0, set on setup()
|
||||
goal_bias: 0.05 # When close to goal select goal, with this probability. default: 0.05
|
||||
use_projected_distance: 0 # whether nearest neighbors are computed based on distances in a projection of the state rather distances in the state space itself. default: 0
|
||||
degree: 16 # desired degree of a node in the Geometric Near-neightbor Access Tree (GNAT). default: 16
|
||||
max_degree: 18 # max degree of a node in the GNAT. default: 12
|
||||
min_degree: 12 # min degree of a node in the GNAT. default: 12
|
||||
max_pts_per_leaf: 6 # max points per leaf in the GNAT. default: 6
|
||||
estimated_dimension: 0.0 # estimated dimension of the free space. default: 0.0
|
||||
min_valid_path_fraction: 0.2 # Accept partially valid moves above fraction. default: 0.2
|
||||
BiTRRT:
|
||||
type: geometric::BiTRRT
|
||||
range: 0.0 # Max motion added to tree. ==> maxDistance_ default: 0.0, if 0.0, set on setup()
|
||||
temp_change_factor: 0.1 # how much to increase or decrease temp. default: 0.1
|
||||
init_temperature: 100 # initial temperature. default: 100
|
||||
frountier_threshold: 0.0 # dist new state to nearest neighbor to disqualify as frontier. default: 0.0 set in setup()
|
||||
frountier_node_ratio: 0.1 # 1/10, or 1 nonfrontier for every 10 frontier. default: 0.1
|
||||
cost_threshold: 1e300 # the cost threshold. Any motion cost that is not better will not be expanded. default: inf
|
||||
LBTRRT:
|
||||
type: geometric::LBTRRT
|
||||
range: 0.0 # Max motion added to tree. ==> maxDistance_ default: 0.0, if 0.0, set on setup()
|
||||
goal_bias: 0.05 # When close to goal select goal, with this probability. default: 0.05
|
||||
epsilon: 0.4 # optimality approximation factor. default: 0.4
|
||||
BiEST:
|
||||
type: geometric::BiEST
|
||||
range: 0.0 # Max motion added to tree. ==> maxDistance_ default: 0.0, if 0.0, set on setup()
|
||||
ProjEST:
|
||||
type: geometric::ProjEST
|
||||
range: 0.0 # Max motion added to tree. ==> maxDistance_ default: 0.0, if 0.0, set on setup()
|
||||
goal_bias: 0.05 # When close to goal select goal, with this probability. default: 0.05
|
||||
LazyPRM:
|
||||
type: geometric::LazyPRM
|
||||
range: 0.0 # Max motion added to tree. ==> maxDistance_ default: 0.0, if 0.0, set on setup()
|
||||
LazyPRMstar:
|
||||
type: geometric::LazyPRMstar
|
||||
SPARS:
|
||||
type: geometric::SPARS
|
||||
stretch_factor: 3.0 # roadmap spanner stretch factor. multiplicative upper bound on path quality. It does not make sense to make this parameter more than 3. default: 3.0
|
||||
sparse_delta_fraction: 0.25 # delta fraction for connection distance. This value represents the visibility range of sparse samples. default: 0.25
|
||||
dense_delta_fraction: 0.001 # delta fraction for interface detection. default: 0.001
|
||||
max_failures: 1000 # maximum consecutive failure limit. default: 1000
|
||||
SPARStwo:
|
||||
type: geometric::SPARStwo
|
||||
stretch_factor: 3.0 # roadmap spanner stretch factor. multiplicative upper bound on path quality. It does not make sense to make this parameter more than 3. default: 3.0
|
||||
sparse_delta_fraction: 0.25 # delta fraction for connection distance. This value represents the visibility range of sparse samples. default: 0.25
|
||||
dense_delta_fraction: 0.001 # delta fraction for interface detection. default: 0.001
|
||||
max_failures: 5000 # maximum consecutive failure limit. default: 5000
|
||||
arm_group:
|
||||
default_planner_config: RRT
|
||||
planner_configs:
|
||||
- SBL
|
||||
- EST
|
||||
- LBKPIECE
|
||||
- BKPIECE
|
||||
- KPIECE
|
||||
- RRT
|
||||
- RRTConnect
|
||||
- RRTstar
|
||||
- TRRT
|
||||
- PRM
|
||||
- PRMstar
|
||||
- FMT
|
||||
- BFMT
|
||||
- PDST
|
||||
- STRIDE
|
||||
- BiTRRT
|
||||
- LBTRRT
|
||||
- BiEST
|
||||
- ProjEST
|
||||
- LazyPRM
|
||||
- LazyPRMstar
|
||||
- SPARS
|
||||
- SPARStwo
|
||||
projection_evaluator: joints(joint2_to_joint1,joint3_to_joint2)
|
||||
longest_valid_segment_fraction: 0.005
|
||||
27
Mira/mira_moveit/config/ros_controllers.yaml
Normal file
27
Mira/mira_moveit/config/ros_controllers.yaml
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
# Simulation settings for using moveit_sim_controllers
|
||||
moveit_sim_hw_interface:
|
||||
joint_model_group: arm_group
|
||||
joint_model_group_pose: init_pose
|
||||
# Settings for ros_control_boilerplate control loop
|
||||
generic_hw_control_loop:
|
||||
loop_hz: 300
|
||||
cycle_time_error_threshold: 0.01
|
||||
# Settings for ros_control hardware interface
|
||||
hardware_interface:
|
||||
joints:
|
||||
- vitual_joint
|
||||
- joint1_to_base
|
||||
- joint2_to_joint1
|
||||
- joint3_to_joint2
|
||||
# - joint4_to_joint3
|
||||
# - joint5_to_joint4
|
||||
# - joint6_to_joint5
|
||||
# - joint6output_to_joint6
|
||||
sim_control_mode: 1 # 0: position, 1: velocity
|
||||
# Publish all joint states
|
||||
# Creates the /joint_states topic necessary in ROS
|
||||
joint_state_controller:
|
||||
type: joint_state_controller/JointStateController
|
||||
publish_rate: 50
|
||||
controller_list:
|
||||
[]
|
||||
10
Mira/mira_moveit/config/sensors_3d.yaml
Normal file
10
Mira/mira_moveit/config/sensors_3d.yaml
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
# The name of this file shouldn't be changed, or else the Setup Assistant won't detect it
|
||||
sensors:
|
||||
- filtered_cloud_topic: filtered_cloud
|
||||
max_range: 5.0
|
||||
max_update_rate: 1.0
|
||||
padding_offset: 0.1
|
||||
padding_scale: 1.0
|
||||
point_cloud_topic: /head_mount_kinect/depth_registered/points
|
||||
point_subsample: 1
|
||||
sensor_plugin: occupancy_map_monitor/PointCloudOctomapUpdater
|
||||
10
Mira/mira_moveit/launch/chomp_planning_pipeline.launch.xml
Normal file
10
Mira/mira_moveit/launch/chomp_planning_pipeline.launch.xml
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<launch>
|
||||
<!-- CHOMP Plugin for MoveIt! -->
|
||||
<arg name="planning_plugin" value="chomp_interface/CHOMPPlanner" />
|
||||
<arg name="start_state_max_bounds_error" value="0.1" />
|
||||
|
||||
<param name="planning_plugin" value="$(arg planning_plugin)" />
|
||||
<param name="start_state_max_bounds_error" value="$(arg start_state_max_bounds_error)" />
|
||||
|
||||
<rosparam command="load" file="$(find mira_moveit)/config/chomp_planning.yaml" />
|
||||
</launch>
|
||||
15
Mira/mira_moveit/launch/default_warehouse_db.launch
Normal file
15
Mira/mira_moveit/launch/default_warehouse_db.launch
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
<launch>
|
||||
|
||||
<arg name="reset" default="false"/>
|
||||
<!-- If not specified, we'll use a default database location -->
|
||||
<arg name="moveit_warehouse_database_path" default="$(find mira_moveit)/default_warehouse_mongo_db" />
|
||||
|
||||
<!-- Launch the warehouse with the configured database location -->
|
||||
<include file="$(find mira_moveit)/launch/warehouse.launch">
|
||||
<arg name="moveit_warehouse_database_path" value="$(arg moveit_warehouse_database_path)" />
|
||||
</include>
|
||||
|
||||
<!-- If we want to reset the database, run this node -->
|
||||
<node if="$(arg reset)" name="$(anon moveit_default_db_reset)" type="moveit_init_demo_warehouse" pkg="moveit_ros_warehouse" respawn="false" output="screen" />
|
||||
|
||||
</launch>
|
||||
57
Mira/mira_moveit/launch/demo.launch
Normal file
57
Mira/mira_moveit/launch/demo.launch
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
<launch>
|
||||
|
||||
<!-- By default, we do not start a database (it can be large) -->
|
||||
<arg name="db" default="false" />
|
||||
<!-- Allow user to specify database location -->
|
||||
<arg name="db_path" default="$(find mira_moveit)/default_warehouse_mongo_db" />
|
||||
|
||||
<!-- By default, we are not in debug mode -->
|
||||
<arg name="debug" default="false" />
|
||||
|
||||
<!--
|
||||
By default, hide joint_state_publisher's GUI
|
||||
|
||||
MoveIt!'s "demo" mode replaces the real robot driver with the joint_state_publisher.
|
||||
The latter one maintains and publishes the current joint configuration of the simulated robot.
|
||||
It also provides a GUI to move the simulated robot around "manually".
|
||||
This corresponds to moving around the real robot without the use of MoveIt.
|
||||
-->
|
||||
<arg name="use_gui" default="false" />
|
||||
|
||||
<!-- Load the URDF, SRDF and other .yaml configuration files on the param server -->
|
||||
<include file="$(find mira_moveit)/launch/planning_context.launch">
|
||||
<arg name="load_robot_description" value="true"/>
|
||||
</include>
|
||||
|
||||
<!-- If needed, broadcast static tf for robot root -->
|
||||
|
||||
|
||||
<!-- We do not have a robot connected, so publish fake joint states -->
|
||||
<node name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher">
|
||||
<param name="use_gui" value="$(arg use_gui)"/>
|
||||
<rosparam param="source_list">[move_group/fake_controller_joint_states]</rosparam>
|
||||
</node>
|
||||
|
||||
<!-- Given the published joint states, publish tf for the robot links -->
|
||||
<node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher" respawn="true" output="screen" />
|
||||
|
||||
<!-- Run the main MoveIt! executable without trajectory execution (we do not have controllers configured by default) -->
|
||||
<include file="$(find mira_moveit)/launch/move_group.launch">
|
||||
<arg name="allow_trajectory_execution" value="true"/>
|
||||
<arg name="fake_execution" value="true"/>
|
||||
<arg name="info" value="true"/>
|
||||
<arg name="debug" value="$(arg debug)"/>
|
||||
</include>
|
||||
|
||||
<!-- Run Rviz and load the default config to see the state of the move_group node -->
|
||||
<include file="$(find mira_moveit)/launch/moveit_rviz.launch">
|
||||
<arg name="config" value="true"/>
|
||||
<arg name="debug" value="$(arg debug)"/>
|
||||
</include>
|
||||
|
||||
<!-- If database loading was enabled, start mongodb as well -->
|
||||
<include file="$(find mira_moveit)/launch/default_warehouse_db.launch" if="$(arg db)">
|
||||
<arg name="moveit_warehouse_database_path" value="$(arg db_path)"/>
|
||||
</include>
|
||||
|
||||
</launch>
|
||||
70
Mira/mira_moveit/launch/demo_gazebo.launch
Normal file
70
Mira/mira_moveit/launch/demo_gazebo.launch
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
<launch>
|
||||
|
||||
<!-- By default, we do not start a database (it can be large) -->
|
||||
<arg name="db" default="false" />
|
||||
<!-- Allow user to specify database location -->
|
||||
<arg name="db_path" default="$(find mira_moveit)/default_warehouse_mongo_db" />
|
||||
|
||||
<!-- By default, we are not in debug mode -->
|
||||
<arg name="debug" default="false" />
|
||||
|
||||
<!--
|
||||
By default, hide joint_state_publisher's GUI
|
||||
|
||||
MoveIt!'s "demo" mode replaces the real robot driver with the joint_state_publisher.
|
||||
The latter one maintains and publishes the current joint configuration of the simulated robot.
|
||||
It also provides a GUI to move the simulated robot around "manually".
|
||||
This corresponds to moving around the real robot without the use of MoveIt.
|
||||
-->
|
||||
<arg name="use_gui" default="false" />
|
||||
|
||||
<!-- Gazebo specific options -->
|
||||
<arg name="gazebo_gui" default="true"/>
|
||||
<arg name="paused" default="false"/>
|
||||
<!-- By default, use the urdf location provided from the package -->
|
||||
<arg name="urdf_path" default="$(find mycobot_description)/urdf/260_urdf/mypal_260.urdf"/>
|
||||
|
||||
<!-- launch the gazebo simulator and spawn the robot -->
|
||||
<include file="$(find mira_moveit)/launch/gazebo.launch" >
|
||||
<arg name="paused" value="$(arg paused)"/>
|
||||
<arg name="gazebo_gui" value="$(arg gazebo_gui)"/>
|
||||
<arg name="urdf_path" value="$(arg urdf_path)"/>
|
||||
</include>
|
||||
|
||||
<!-- Load the URDF, SRDF and other .yaml configuration files on the param server -->
|
||||
<include file="$(find mira_moveit)/launch/planning_context.launch">
|
||||
<arg name="load_robot_description" value="false"/>
|
||||
</include>
|
||||
|
||||
<!-- If needed, broadcast static tf for robot root -->
|
||||
|
||||
|
||||
<!-- We do not have a robot connected, so publish fake joint states -->
|
||||
<node name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher">
|
||||
<param name="use_gui" value="$(arg use_gui)"/>
|
||||
<rosparam param="source_list">[/joint_states]</rosparam>
|
||||
</node>
|
||||
|
||||
<!-- Given the published joint states, publish tf for the robot links -->
|
||||
<node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher" respawn="true" output="screen" />
|
||||
|
||||
<!-- Run the main MoveIt! executable without trajectory execution (we do not have controllers configured by default) -->
|
||||
<include file="$(find mira_moveit)/launch/move_group.launch">
|
||||
<arg name="allow_trajectory_execution" value="true"/>
|
||||
<arg name="fake_execution" value="false"/>
|
||||
<arg name="info" value="true"/>
|
||||
<arg name="debug" value="$(arg debug)"/>
|
||||
</include>
|
||||
|
||||
<!-- Run Rviz and load the default config to see the state of the move_group node -->
|
||||
<include file="$(find mira_moveit)/launch/moveit_rviz.launch">
|
||||
<arg name="config" value="true"/>
|
||||
<arg name="debug" value="$(arg debug)"/>
|
||||
</include>
|
||||
|
||||
<!-- If database loading was enabled, start mongodb as well -->
|
||||
<include file="$(find mira_moveit)/launch/default_warehouse_db.launch" if="$(arg db)">
|
||||
<arg name="moveit_warehouse_database_path" value="$(arg db_path)"/>
|
||||
</include>
|
||||
|
||||
</launch>
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
<launch>
|
||||
|
||||
<!-- Set the param that trajectory_execution_manager needs to find the controller plugin -->
|
||||
<param name="moveit_controller_manager" value="moveit_fake_controller_manager/MoveItFakeControllerManager"/>
|
||||
|
||||
<!-- The rest of the params are specific to this plugin -->
|
||||
<rosparam file="$(find mira_moveit)/config/fake_controllers.yaml"/>
|
||||
|
||||
</launch>
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
<launch>
|
||||
|
||||
<!-- loads moveit_controller_manager on the parameter server which is taken as argument
|
||||
if no argument is passed, moveit_simple_controller_manager will be set -->
|
||||
<arg name="moveit_controller_manager" default="moveit_simple_controller_manager/MoveItSimpleControllerManager" />
|
||||
<param name="moveit_controller_manager" value="$(arg moveit_controller_manager)"/>
|
||||
|
||||
<!-- loads ros_controllers to the param server -->
|
||||
<rosparam file="$(find mira_moveit)/config/ros_controllers.yaml"/>
|
||||
</launch>
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
<launch>
|
||||
|
||||
</launch>
|
||||
23
Mira/mira_moveit/launch/gazebo.launch
Normal file
23
Mira/mira_moveit/launch/gazebo.launch
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
<?xml version="1.0"?>
|
||||
<launch>
|
||||
<arg name="paused" default="false"/>
|
||||
<arg name="gazebo_gui" default="true"/>
|
||||
<arg name="urdf_path" default="$(find mycobot_description)/urdf/mira_urdf/mira.urdf"/>
|
||||
|
||||
<!-- startup simulated world -->
|
||||
<include file="$(find gazebo_ros)/launch/empty_world.launch">
|
||||
<arg name="world_name" default="worlds/empty.world"/>
|
||||
<arg name="paused" value="$(arg paused)"/>
|
||||
<arg name="gui" value="$(arg gazebo_gui)"/>
|
||||
</include>
|
||||
|
||||
<!-- send robot urdf to param server -->
|
||||
<param name="robot_description" textfile="$(arg urdf_path)" />
|
||||
|
||||
<!-- push robot_description to factory and spawn robot in gazebo at the origin, change x,y,z arguments to spawn in a different position -->
|
||||
<node name="spawn_gazebo_model" pkg="gazebo_ros" type="spawn_model" args="-urdf -param robot_description -model robot -x 0 -y 0 -z 0"
|
||||
respawn="false" output="screen" />
|
||||
|
||||
<include file="$(find mira_moveit)/launch/ros_controllers.launch"/>
|
||||
|
||||
</launch>
|
||||
17
Mira/mira_moveit/launch/joystick_control.launch
Normal file
17
Mira/mira_moveit/launch/joystick_control.launch
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
<launch>
|
||||
<!-- See moveit_ros/visualization/doc/joystick.rst for documentation -->
|
||||
|
||||
<arg name="dev" default="/dev/input/js0" />
|
||||
|
||||
<!-- Launch joy node -->
|
||||
<node pkg="joy" type="joy_node" name="joy">
|
||||
<param name="dev" value="$(arg dev)" /> <!-- Customize this to match the location your joystick is plugged in on-->
|
||||
<param name="deadzone" value="0.2" />
|
||||
<param name="autorepeat_rate" value="40" />
|
||||
<param name="coalesce_interval" value="0.025" />
|
||||
</node>
|
||||
|
||||
<!-- Launch python interface -->
|
||||
<node pkg="moveit_ros_visualization" type="moveit_joy.py" output="screen" name="moveit_joy"/>
|
||||
|
||||
</launch>
|
||||
57
Mira/mira_moveit/launch/mira_moveit.launch
Normal file
57
Mira/mira_moveit/launch/mira_moveit.launch
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
<launch>
|
||||
|
||||
<!-- By default, we do not start a database (it can be large) -->
|
||||
<arg name="db" default="false" />
|
||||
<!-- Allow user to specify database location -->
|
||||
<arg name="db_path" default="$(find mira_moveit)/default_warehouse_mongo_db" />
|
||||
|
||||
<!-- By default, we are not in debug mode -->
|
||||
<arg name="debug" default="false" />
|
||||
|
||||
<!--
|
||||
By default, hide joint_state_publisher's GUI
|
||||
|
||||
MoveIt!'s "demo" mode replaces the real robot driver with the joint_state_publisher.
|
||||
The latter one maintains and publishes the current joint configuration of the simulated robot.
|
||||
It also provides a GUI to move the simulated robot around "manually".
|
||||
This corresponds to moving around the real robot without the use of MoveIt.
|
||||
-->
|
||||
<arg name="use_gui" default="false" />
|
||||
|
||||
<!-- Load the URDF, SRDF and other .yaml configuration files on the param server -->
|
||||
<include file="$(find mira_moveit)/launch/planning_context.launch">
|
||||
<arg name="load_robot_description" value="true"/>
|
||||
</include>
|
||||
|
||||
<!-- If needed, broadcast static tf for robot root -->
|
||||
|
||||
|
||||
<!-- We do not have a robot connected, so publish fake joint states -->
|
||||
<node name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher">
|
||||
<param name="use_gui" value="$(arg use_gui)"/>
|
||||
<rosparam param="source_list">[move_group/fake_controller_joint_states]</rosparam>
|
||||
</node>
|
||||
|
||||
<!-- Given the published joint states, publish tf for the robot links -->
|
||||
<node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher" respawn="true" output="screen" />
|
||||
|
||||
<!-- Run the main MoveIt! executable without trajectory execution (we do not have controllers configured by default) -->
|
||||
<include file="$(find mira_moveit)/launch/move_group.launch">
|
||||
<arg name="allow_trajectory_execution" value="true"/>
|
||||
<arg name="fake_execution" value="true"/>
|
||||
<arg name="info" value="true"/>
|
||||
<arg name="debug" value="$(arg debug)"/>
|
||||
</include>
|
||||
|
||||
<!-- Run Rviz and load the default config to see the state of the move_group node -->
|
||||
<include file="$(find mira_moveit)/launch/moveit_rviz.launch">
|
||||
<arg name="config" value="true"/>
|
||||
<arg name="debug" value="$(arg debug)"/>
|
||||
</include>
|
||||
|
||||
<!-- If database loading was enabled, start mongodb as well -->
|
||||
<include file="$(find mira_moveit)/launch/default_warehouse_db.launch" if="$(arg db)">
|
||||
<arg name="moveit_warehouse_database_path" value="$(arg db_path)"/>
|
||||
</include>
|
||||
|
||||
</launch>
|
||||
77
Mira/mira_moveit/launch/move_group.launch
Normal file
77
Mira/mira_moveit/launch/move_group.launch
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
<launch>
|
||||
|
||||
<include file="$(find mira_moveit)/launch/planning_context.launch" />
|
||||
|
||||
<!-- GDB Debug Option -->
|
||||
<arg name="debug" default="false" />
|
||||
<arg unless="$(arg debug)" name="launch_prefix" value="" />
|
||||
<arg if="$(arg debug)" name="launch_prefix"
|
||||
value="gdb -x $(find mira_moveit)/launch/gdb_settings.gdb --ex run --args" />
|
||||
|
||||
<!-- Verbose Mode Option -->
|
||||
<arg name="info" default="$(arg debug)" />
|
||||
<arg unless="$(arg info)" name="command_args" value="" />
|
||||
<arg if="$(arg info)" name="command_args" value="--debug" />
|
||||
|
||||
<!-- move_group settings -->
|
||||
<arg name="allow_trajectory_execution" default="true"/>
|
||||
<arg name="fake_execution" default="false"/>
|
||||
<arg name="max_safe_path_cost" default="1"/>
|
||||
<arg name="jiggle_fraction" default="0.05" />
|
||||
<arg name="publish_monitored_planning_scene" default="true"/>
|
||||
|
||||
<arg name="capabilities" default=""/>
|
||||
<arg name="disable_capabilities" default=""/>
|
||||
<!-- load these non-default MoveGroup capabilities (space seperated) -->
|
||||
<!--
|
||||
<arg name="capabilities" value="
|
||||
a_package/AwsomeMotionPlanningCapability
|
||||
another_package/GraspPlanningPipeline
|
||||
" />
|
||||
-->
|
||||
|
||||
<!-- inhibit these default MoveGroup capabilities (space seperated) -->
|
||||
<!--
|
||||
<arg name="disable_capabilities" value="
|
||||
move_group/MoveGroupKinematicsService
|
||||
move_group/ClearOctomapService
|
||||
" />
|
||||
-->
|
||||
|
||||
<!-- Planning Functionality -->
|
||||
<include ns="move_group" file="$(find mira_moveit)/launch/planning_pipeline.launch.xml">
|
||||
<arg name="pipeline" value="ompl" />
|
||||
</include>
|
||||
|
||||
<!-- Trajectory Execution Functionality -->
|
||||
<include ns="move_group" file="$(find mira_moveit)/launch/trajectory_execution.launch.xml" if="$(arg allow_trajectory_execution)">
|
||||
<arg name="moveit_manage_controllers" value="true" />
|
||||
<arg name="moveit_controller_manager" value="firefighter" unless="$(arg fake_execution)"/>
|
||||
<arg name="moveit_controller_manager" value="fake" if="$(arg fake_execution)"/>
|
||||
</include>
|
||||
|
||||
<!-- Sensors Functionality -->
|
||||
<include ns="move_group" file="$(find mira_moveit)/launch/sensor_manager.launch.xml" if="$(arg allow_trajectory_execution)">
|
||||
<arg name="moveit_sensor_manager" value="firefighter" />
|
||||
</include>
|
||||
|
||||
<!-- Start the actual move_group node/action server -->
|
||||
<node name="move_group" launch-prefix="$(arg launch_prefix)" pkg="moveit_ros_move_group" type="move_group" respawn="false" output="screen" args="$(arg command_args)">
|
||||
<!-- Set the display variable, in case OpenGL code is used internally -->
|
||||
<env name="DISPLAY" value="$(optenv DISPLAY :0)" />
|
||||
|
||||
<param name="allow_trajectory_execution" value="$(arg allow_trajectory_execution)"/>
|
||||
<param name="max_safe_path_cost" value="$(arg max_safe_path_cost)"/>
|
||||
<param name="jiggle_fraction" value="$(arg jiggle_fraction)" />
|
||||
<param name="capabilities" value="$(arg capabilities)"/>
|
||||
<param name="disable_capabilities" value="$(arg disable_capabilities)"/>
|
||||
|
||||
|
||||
<!-- Publish the planning scene of the physical robot so that rviz plugin can know actual robot -->
|
||||
<param name="planning_scene_monitor/publish_planning_scene" value="$(arg publish_monitored_planning_scene)" />
|
||||
<param name="planning_scene_monitor/publish_geometry_updates" value="$(arg publish_monitored_planning_scene)" />
|
||||
<param name="planning_scene_monitor/publish_state_updates" value="$(arg publish_monitored_planning_scene)" />
|
||||
<param name="planning_scene_monitor/publish_transforms_updates" value="$(arg publish_monitored_planning_scene)" />
|
||||
</node>
|
||||
|
||||
</launch>
|
||||
223
Mira/mira_moveit/launch/moveit.rviz
Normal file
223
Mira/mira_moveit/launch/moveit.rviz
Normal file
|
|
@ -0,0 +1,223 @@
|
|||
Panels:
|
||||
- Class: rviz/Displays
|
||||
Help Height: 84
|
||||
Name: Displays
|
||||
Property Tree Widget:
|
||||
Expanded:
|
||||
- /MotionPlanning1
|
||||
- /MotionPlanning1/Scene Geometry1
|
||||
- /MotionPlanning1/Scene Robot1
|
||||
- /MotionPlanning1/Planning Request1
|
||||
- /MotionPlanning1/Planning Metrics1
|
||||
- /MotionPlanning1/Planned Path1
|
||||
- /MotionPlanning1/Planned Path1/Links1
|
||||
Splitter Ratio: 0.7425600290298462
|
||||
Tree Height: 184
|
||||
- Class: rviz/Help
|
||||
Name: Help
|
||||
- Class: rviz/Views
|
||||
Expanded:
|
||||
- /Current View1
|
||||
Name: Views
|
||||
Splitter Ratio: 0.5
|
||||
Preferences:
|
||||
PromptSaveOnExit: true
|
||||
Toolbars:
|
||||
toolButtonStyle: 2
|
||||
Visualization Manager:
|
||||
Class: ""
|
||||
Displays:
|
||||
- Alpha: 0.5
|
||||
Cell Size: 1
|
||||
Class: rviz/Grid
|
||||
Color: 160; 160; 164
|
||||
Enabled: true
|
||||
Line Style:
|
||||
Line Width: 0.029999999329447746
|
||||
Value: Lines
|
||||
Name: Grid
|
||||
Normal Cell Count: 0
|
||||
Offset:
|
||||
X: 0
|
||||
Y: 0
|
||||
Z: 0
|
||||
Plane: XY
|
||||
Plane Cell Count: 10
|
||||
Reference Frame: <Fixed Frame>
|
||||
Value: true
|
||||
- Acceleration_Scaling_Factor: 1
|
||||
Class: moveit_rviz_plugin/MotionPlanning
|
||||
Enabled: true
|
||||
Move Group Namespace: ""
|
||||
MoveIt_Allow_Approximate_IK: false
|
||||
MoveIt_Allow_External_Program: false
|
||||
MoveIt_Allow_Replanning: false
|
||||
MoveIt_Allow_Sensor_Positioning: false
|
||||
MoveIt_Planning_Attempts: 10
|
||||
MoveIt_Planning_Time: 5
|
||||
MoveIt_Use_Cartesian_Path: false
|
||||
MoveIt_Use_Constraint_Aware_IK: true
|
||||
MoveIt_Workspace:
|
||||
Center:
|
||||
X: 0
|
||||
Y: 0
|
||||
Z: 0
|
||||
Size:
|
||||
X: 2
|
||||
Y: 2
|
||||
Z: 2
|
||||
Name: MotionPlanning
|
||||
Planned Path:
|
||||
Color Enabled: false
|
||||
Interrupt Display: false
|
||||
Links:
|
||||
All Links Enabled: true
|
||||
Expand Joint Details: false
|
||||
Expand Link Details: false
|
||||
Expand Tree: false
|
||||
Link Tree Style: Links in Alphabetic Order
|
||||
base:
|
||||
Alpha: 1
|
||||
Show Axes: false
|
||||
Show Trail: false
|
||||
Value: true
|
||||
link1:
|
||||
Alpha: 1
|
||||
Show Axes: false
|
||||
Show Trail: false
|
||||
Value: true
|
||||
link2:
|
||||
Alpha: 1
|
||||
Show Axes: false
|
||||
Show Trail: false
|
||||
Value: true
|
||||
link3:
|
||||
Alpha: 1
|
||||
Show Axes: false
|
||||
Show Trail: false
|
||||
Value: true
|
||||
Loop Animation: false
|
||||
Robot Alpha: 0.5
|
||||
Robot Color: 150; 50; 150
|
||||
Show Robot Collision: false
|
||||
Show Robot Visual: true
|
||||
Show Trail: false
|
||||
State Display Time: 0.05 s
|
||||
Trail Step Size: 1
|
||||
Trajectory Topic: move_group/display_planned_path
|
||||
Use Sim Time: false
|
||||
Planning Metrics:
|
||||
Payload: 1
|
||||
Show Joint Torques: false
|
||||
Show Manipulability: false
|
||||
Show Manipulability Index: false
|
||||
Show Weight Limit: false
|
||||
TextHeight: 0.07999999821186066
|
||||
Planning Request:
|
||||
Colliding Link Color: 255; 0; 0
|
||||
Goal State Alpha: 1
|
||||
Goal State Color: 250; 128; 0
|
||||
Interactive Marker Size: 0.07999999821186066
|
||||
Joint Violation Color: 255; 0; 255
|
||||
Planning Group: arm_group
|
||||
Query Goal State: true
|
||||
Query Start State: true
|
||||
Show Workspace: false
|
||||
Start State Alpha: 1
|
||||
Start State Color: 0; 255; 0
|
||||
Planning Scene Topic: move_group/monitored_planning_scene
|
||||
Robot Description: robot_description
|
||||
Scene Geometry:
|
||||
Scene Alpha: 1
|
||||
Scene Color: 50; 230; 50
|
||||
Scene Display Time: 0.20000000298023224
|
||||
Show Scene Geometry: true
|
||||
Voxel Coloring: Z-Axis
|
||||
Voxel Rendering: Occupied Voxels
|
||||
Scene Robot:
|
||||
Attached Body Color: 150; 50; 150
|
||||
Links:
|
||||
All Links Enabled: true
|
||||
Expand Joint Details: false
|
||||
Expand Link Details: false
|
||||
Expand Tree: false
|
||||
Link Tree Style: Links in Alphabetic Order
|
||||
base:
|
||||
Alpha: 1
|
||||
Show Axes: false
|
||||
Show Trail: false
|
||||
Value: true
|
||||
link1:
|
||||
Alpha: 1
|
||||
Show Axes: false
|
||||
Show Trail: false
|
||||
Value: true
|
||||
link2:
|
||||
Alpha: 1
|
||||
Show Axes: false
|
||||
Show Trail: false
|
||||
Value: true
|
||||
link3:
|
||||
Alpha: 1
|
||||
Show Axes: false
|
||||
Show Trail: false
|
||||
Value: true
|
||||
Robot Alpha: 0.5
|
||||
Show Robot Collision: false
|
||||
Show Robot Visual: false
|
||||
Value: true
|
||||
Velocity_Scaling_Factor: 1
|
||||
Enabled: true
|
||||
Global Options:
|
||||
Background Color: 48; 48; 48
|
||||
Default Light: true
|
||||
Fixed Frame: base
|
||||
Frame Rate: 30
|
||||
Name: root
|
||||
Tools:
|
||||
- Class: rviz/Interact
|
||||
Hide Inactive Objects: true
|
||||
- Class: rviz/MoveCamera
|
||||
- Class: rviz/Select
|
||||
Value: true
|
||||
Views:
|
||||
Current:
|
||||
Class: rviz/XYOrbit
|
||||
Distance: 1.3915867805480957
|
||||
Enable Stereo Rendering:
|
||||
Stereo Eye Separation: 0.05999999865889549
|
||||
Stereo Focal Distance: 1
|
||||
Swap Stereo Eyes: false
|
||||
Value: false
|
||||
Field of View: 0.7853981852531433
|
||||
Focal Point:
|
||||
X: 0.11356700211763382
|
||||
Y: 0.10592000186443329
|
||||
Z: 2.2351800055275817e-07
|
||||
Focal Shape Fixed Size: true
|
||||
Focal Shape Size: 0.05000000074505806
|
||||
Invert Z Axis: false
|
||||
Name: Current View
|
||||
Near Clip Distance: 0.009999999776482582
|
||||
Pitch: -0.14020325243473053
|
||||
Target Frame: link1
|
||||
Yaw: 2.3235831260681152
|
||||
Saved: ~
|
||||
Window Geometry:
|
||||
Displays:
|
||||
collapsed: false
|
||||
Height: 888
|
||||
Help:
|
||||
collapsed: false
|
||||
Hide Left Dock: false
|
||||
Hide Right Dock: false
|
||||
MotionPlanning:
|
||||
collapsed: false
|
||||
MotionPlanning - Trajectory Slider:
|
||||
collapsed: false
|
||||
QMainWindow State: 000000ff00000000fd0000000100000000000001f30000031efc0200000007fb000000100044006900730070006c006100790073010000003d00000149000000c900fffffffb0000000800480065006c00700000000342000000bb0000006e00fffffffb0000000a0056006900650077007300000003b0000000b0000000a400fffffffb0000000c00430061006d00650072006100000002ff000001610000000000000000fb0000001e004d006f00740069006f006e00200050006c0061006e006e0069006e00670100000374000001890000000000000000fb00000044004d006f00740069006f006e0050006c0061006e006e0069006e00670020002d0020005400720061006a006500630074006f0072007900200053006c0069006400650072010000018c000000410000004100fffffffb0000001c004d006f00740069006f006e0050006c0061006e006e0069006e006701000001d3000001880000017d00ffffff0000053f0000031e00000001000000020000000100000002fc0000000100000002000000010000000a0054006f006f006c00730100000000ffffffff0000000000000000
|
||||
Views:
|
||||
collapsed: false
|
||||
Width: 1848
|
||||
X: 72
|
||||
Y: 27
|
||||
16
Mira/mira_moveit/launch/moveit_rviz.launch
Normal file
16
Mira/mira_moveit/launch/moveit_rviz.launch
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
<launch>
|
||||
|
||||
<arg name="debug" default="false" />
|
||||
<arg unless="$(arg debug)" name="launch_prefix" value="" />
|
||||
<arg if="$(arg debug)" name="launch_prefix" value="gdb --ex run --args" />
|
||||
|
||||
<arg name="config" default="false" />
|
||||
<arg unless="$(arg config)" name="command_args" value="" />
|
||||
<arg if="$(arg config)" name="command_args" value="-d $(find mira_moveit)/launch/moveit.rviz" />
|
||||
|
||||
<node name="$(anon rviz)" launch-prefix="$(arg launch_prefix)" pkg="rviz" type="rviz" respawn="false"
|
||||
args="$(arg command_args)" output="screen">
|
||||
<rosparam command="load" file="$(find mira_moveit)/config/kinematics.yaml"/>
|
||||
</node>
|
||||
|
||||
</launch>
|
||||
22
Mira/mira_moveit/launch/ompl_planning_pipeline.launch.xml
Normal file
22
Mira/mira_moveit/launch/ompl_planning_pipeline.launch.xml
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
<launch>
|
||||
|
||||
<!-- OMPL Plugin for MoveIt! -->
|
||||
<arg name="planning_plugin" value="ompl_interface/OMPLPlanner" />
|
||||
|
||||
<!-- The request adapters (plugins) used when planning with OMPL.
|
||||
ORDER MATTERS -->
|
||||
<arg name="planning_adapters" value="default_planner_request_adapters/AddTimeParameterization
|
||||
default_planner_request_adapters/FixWorkspaceBounds
|
||||
default_planner_request_adapters/FixStartStateBounds
|
||||
default_planner_request_adapters/FixStartStateCollision
|
||||
default_planner_request_adapters/FixStartStatePathConstraints" />
|
||||
|
||||
<arg name="start_state_max_bounds_error" value="0.1" />
|
||||
|
||||
<param name="planning_plugin" value="$(arg planning_plugin)" />
|
||||
<param name="request_adapters" value="$(arg planning_adapters)" />
|
||||
<param name="start_state_max_bounds_error" value="$(arg start_state_max_bounds_error)" />
|
||||
|
||||
<rosparam command="load" file="$(find mira_moveit)/config/ompl_planning.yaml"/>
|
||||
|
||||
</launch>
|
||||
24
Mira/mira_moveit/launch/planning_context.launch
Normal file
24
Mira/mira_moveit/launch/planning_context.launch
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
<launch>
|
||||
<!-- By default we do not overwrite the URDF. Change the following to true to change the default behavior -->
|
||||
<arg name="load_robot_description" default="false"/>
|
||||
|
||||
<!-- The name of the parameter under which the URDF is loaded -->
|
||||
<arg name="robot_description" default="robot_description"/>
|
||||
|
||||
<!-- Load universal robot description format (URDF) -->
|
||||
<param if="$(arg load_robot_description)" name="$(arg robot_description)" textfile="$(find mycobot_description)/urdf/mira_urdf/mira.urdf"/>
|
||||
|
||||
<!-- The semantic description that corresponds to the URDF -->
|
||||
<param name="$(arg robot_description)_semantic" textfile="$(find mira_moveit)/config/firefighter.srdf" />
|
||||
|
||||
<!-- Load updated joint limits (override information from URDF) -->
|
||||
<group ns="$(arg robot_description)_planning">
|
||||
<rosparam command="load" file="$(find mira_moveit)/config/joint_limits.yaml"/>
|
||||
</group>
|
||||
|
||||
<!-- Load default settings for kinematics; these settings are overridden by settings in a node's namespace -->
|
||||
<group ns="$(arg robot_description)_kinematics">
|
||||
<rosparam command="load" file="$(find mira_moveit)/config/kinematics.yaml"/>
|
||||
</group>
|
||||
|
||||
</launch>
|
||||
10
Mira/mira_moveit/launch/planning_pipeline.launch.xml
Normal file
10
Mira/mira_moveit/launch/planning_pipeline.launch.xml
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<launch>
|
||||
|
||||
<!-- This file makes it easy to include different planning pipelines;
|
||||
It is assumed that all planning pipelines are named XXX_planning_pipeline.launch -->
|
||||
|
||||
<arg name="pipeline" default="ompl" />
|
||||
|
||||
<include file="$(find mira_moveit)/launch/$(arg pipeline)_planning_pipeline.launch.xml" />
|
||||
|
||||
</launch>
|
||||
11
Mira/mira_moveit/launch/ros_controllers.launch
Normal file
11
Mira/mira_moveit/launch/ros_controllers.launch
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0"?>
|
||||
<launch>
|
||||
|
||||
<!-- Load joint controller configurations from YAML file to parameter server -->
|
||||
<rosparam file="$(find mira_moveit)/config/ros_controllers.yaml" command="load"/>
|
||||
|
||||
<!-- Load the controllers -->
|
||||
<node name="controller_spawner" pkg="controller_manager" type="spawner" respawn="false"
|
||||
output="screen" args=""/>
|
||||
|
||||
</launch>
|
||||
22
Mira/mira_moveit/launch/run_benchmark_ompl.launch
Normal file
22
Mira/mira_moveit/launch/run_benchmark_ompl.launch
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
<launch>
|
||||
|
||||
<!-- This argument must specify the list of .cfg files to process for benchmarking -->
|
||||
<arg name="cfg" />
|
||||
|
||||
<!-- Load URDF -->
|
||||
<include file="$(find mira_moveit)/launch/planning_context.launch">
|
||||
<arg name="load_robot_description" value="true"/>
|
||||
</include>
|
||||
|
||||
<!-- Start the database -->
|
||||
<include file="$(find mira_moveit)/launch/warehouse.launch">
|
||||
<arg name="moveit_warehouse_database_path" value="moveit_ompl_benchmark_warehouse"/>
|
||||
</include>
|
||||
|
||||
<!-- Start Benchmark Executable -->
|
||||
<node name="$(anon moveit_benchmark)" pkg="moveit_ros_benchmarks" type="moveit_run_benchmark" args="$(arg cfg) --benchmark-planners" respawn="false" output="screen">
|
||||
<rosparam command="load" file="$(find mira_moveit)/config/kinematics.yaml"/>
|
||||
<rosparam command="load" file="$(find mira_moveit)/config/ompl_planning.yaml"/>
|
||||
</node>
|
||||
|
||||
</launch>
|
||||
17
Mira/mira_moveit/launch/sensor_manager.launch.xml
Normal file
17
Mira/mira_moveit/launch/sensor_manager.launch.xml
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
<launch>
|
||||
|
||||
<!-- This file makes it easy to include the settings for sensor managers -->
|
||||
|
||||
<!-- Params for 3D sensors config -->
|
||||
<rosparam command="load" file="$(find mira_moveit)/config/sensors_3d.yaml" />
|
||||
|
||||
<!-- Params for the octomap monitor -->
|
||||
<!-- <param name="octomap_frame" type="string" value="some frame in which the robot moves" /> -->
|
||||
<param name="octomap_resolution" type="double" value="0.025" />
|
||||
<param name="max_range" type="double" value="5.0" />
|
||||
|
||||
<!-- Load the robot specific sensor manager; this sets the moveit_sensor_manager ROS parameter -->
|
||||
<arg name="moveit_sensor_manager" default="firefighter" />
|
||||
<include file="$(find mira_moveit)/launch/$(arg moveit_sensor_manager)_moveit_sensor_manager.launch.xml" />
|
||||
|
||||
</launch>
|
||||
15
Mira/mira_moveit/launch/setup_assistant.launch
Normal file
15
Mira/mira_moveit/launch/setup_assistant.launch
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
<!-- Re-launch the MoveIt! Setup Assistant with this configuration package already loaded -->
|
||||
<launch>
|
||||
|
||||
<!-- Debug Info -->
|
||||
<arg name="debug" default="false" />
|
||||
<arg unless="$(arg debug)" name="launch_prefix" value="" />
|
||||
<arg if="$(arg debug)" name="launch_prefix" value="gdb --ex run --args" />
|
||||
|
||||
<!-- Run -->
|
||||
<node pkg="moveit_setup_assistant" type="moveit_setup_assistant" name="moveit_setup_assistant"
|
||||
args="--config_pkg=mira_moveit"
|
||||
launch-prefix="$(arg launch_prefix)"
|
||||
output="screen" />
|
||||
|
||||
</launch>
|
||||
20
Mira/mira_moveit/launch/trajectory_execution.launch.xml
Normal file
20
Mira/mira_moveit/launch/trajectory_execution.launch.xml
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
<launch>
|
||||
|
||||
<!-- This file makes it easy to include the settings for trajectory execution -->
|
||||
|
||||
<!-- Flag indicating whether MoveIt! is allowed to load/unload or switch controllers -->
|
||||
<arg name="moveit_manage_controllers" default="true"/>
|
||||
<param name="moveit_manage_controllers" value="$(arg moveit_manage_controllers)"/>
|
||||
|
||||
<!-- When determining the expected duration of a trajectory, this multiplicative factor is applied to get the allowed duration of execution -->
|
||||
<param name="trajectory_execution/allowed_execution_duration_scaling" value="1.2"/> <!-- default 1.2 -->
|
||||
<!-- Allow more than the expected execution time before triggering a trajectory cancel (applied after scaling) -->
|
||||
<param name="trajectory_execution/allowed_goal_duration_margin" value="0.5"/> <!-- default 0.5 -->
|
||||
<!-- Allowed joint-value tolerance for validation that trajectory's first point matches current robot state -->
|
||||
<param name="trajectory_execution/allowed_start_tolerance" value="0.01"/> <!-- default 0.01 -->
|
||||
|
||||
<!-- Load the robot specific controller manager; this sets the moveit_controller_manager ROS parameter -->
|
||||
<arg name="moveit_controller_manager" default="firefighter" />
|
||||
<include file="$(find mira_moveit)/launch/$(arg moveit_controller_manager)_moveit_controller_manager.launch.xml" />
|
||||
|
||||
</launch>
|
||||
15
Mira/mira_moveit/launch/warehouse.launch
Normal file
15
Mira/mira_moveit/launch/warehouse.launch
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
<launch>
|
||||
|
||||
<!-- The path to the database must be specified -->
|
||||
<arg name="moveit_warehouse_database_path" />
|
||||
|
||||
<!-- Load warehouse parameters -->
|
||||
<include file="$(find mira_moveit)/launch/warehouse_settings.launch.xml" />
|
||||
|
||||
<!-- Run the DB server -->
|
||||
<node name="$(anon mongo_wrapper_ros)" cwd="ROS_HOME" type="mongo_wrapper_ros.py" pkg="warehouse_ros_mongo">
|
||||
<param name="overwrite" value="false"/>
|
||||
<param name="database_path" value="$(arg moveit_warehouse_database_path)" />
|
||||
</node>
|
||||
|
||||
</launch>
|
||||
16
Mira/mira_moveit/launch/warehouse_settings.launch.xml
Normal file
16
Mira/mira_moveit/launch/warehouse_settings.launch.xml
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
<launch>
|
||||
<!-- Set the parameters for the warehouse and run the mongodb server. -->
|
||||
|
||||
<!-- The default DB port for moveit (not default MongoDB port to avoid potential conflicts) -->
|
||||
<arg name="moveit_warehouse_port" default="33829" />
|
||||
|
||||
<!-- The default DB host for moveit -->
|
||||
<arg name="moveit_warehouse_host" default="localhost" />
|
||||
|
||||
<!-- Set parameters for the warehouse -->
|
||||
<param name="warehouse_port" value="$(arg moveit_warehouse_port)"/>
|
||||
<param name="warehouse_host" value="$(arg moveit_warehouse_host)"/>
|
||||
<param name="warehouse_exec" value="mongod" />
|
||||
<param name="warehouse_plugin" value="warehouse_ros_mongo::MongoDatabaseConnection" />
|
||||
|
||||
</launch>
|
||||
40
Mira/mira_moveit/package.xml
Normal file
40
Mira/mira_moveit/package.xml
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
<package>
|
||||
|
||||
<name>mira_moveit</name>
|
||||
<version>0.3.0</version>
|
||||
<description>
|
||||
An automatically generated package with all the configuration and launch files for using the firefighter with the MoveIt! Motion Planning Framework
|
||||
</description>
|
||||
<author email="lijun.zhang@elephantrobotics.com">zachary</author>
|
||||
<maintainer email="lijun.zhang@elephantrobotics.com">zachary</maintainer>
|
||||
|
||||
<license>BSD</license>
|
||||
|
||||
<url type="website">http://moveit.ros.org/</url>
|
||||
<url type="bugtracker">https://github.com/ros-planning/moveit/issues</url>
|
||||
<url type="repository">https://github.com/ros-planning/moveit</url>
|
||||
|
||||
<buildtool_depend>catkin</buildtool_depend>
|
||||
|
||||
<run_depend>moveit_ros_move_group</run_depend>
|
||||
<run_depend>moveit_fake_controller_manager</run_depend>
|
||||
<run_depend>moveit_kinematics</run_depend>
|
||||
<run_depend>moveit_planners_ompl</run_depend>
|
||||
<run_depend>moveit_ros_visualization</run_depend>
|
||||
<run_depend>moveit_setup_assistant</run_depend>
|
||||
<run_depend>joint_state_publisher</run_depend>
|
||||
<run_depend>robot_state_publisher</run_depend>
|
||||
<run_depend>xacro</run_depend>
|
||||
<!-- This package is referenced in the warehouse launch files, but does not build out of the box at the moment. Commented the dependency until this works. -->
|
||||
<!-- <run_depend>warehouse_ros_mongo</run_depend> -->
|
||||
<build_depend>roscpp</build_depend>
|
||||
<build_depend>rospy</build_depend>
|
||||
<build_depend>std_msgs</build_depend>
|
||||
<build_depend>actionlib</build_depend>
|
||||
<build_depend>moveit_msgs</build_depend>
|
||||
<build_depend>mycobot_description</build_depend>
|
||||
|
||||
<run_depend>mycobot_description</run_depend>
|
||||
|
||||
|
||||
</package>
|
||||
|
|
@ -0,0 +1,132 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import rospy, roslib, sys
|
||||
import moveit_commander
|
||||
from moveit_msgs.msg import RobotTrajectory
|
||||
from trajectory_msgs.msg import JointTrajectoryPoint
|
||||
|
||||
from geometry_msgs.msg import PoseStamped, Pose
|
||||
from tf.transformations import euler_from_quaternion, quaternion_from_euler
|
||||
|
||||
|
||||
class MoveItPlanningDemo:
|
||||
def __init__(self):
|
||||
# API to initialize move_group. 初始化move_group的API
|
||||
moveit_commander.roscpp_initialize(sys.argv)
|
||||
|
||||
# Initialize the ROS node,初始化ROS节点
|
||||
rospy.init_node("moveit_ik_demo")
|
||||
|
||||
# Initialize the scene object to listen for changes in the external environment
|
||||
# 初始化场景对象,用来监听外部环境的变化
|
||||
self.scene = moveit_commander.PlanningSceneInterface()
|
||||
rospy.sleep(1)
|
||||
|
||||
# Initialize self.arm group in the robotic arm that needs to be controlled by move group
|
||||
# 初始化需要使用move group控制的机械臂中的self.arm group
|
||||
self.arm = moveit_commander.MoveGroupCommander("arm_group")
|
||||
|
||||
# Get the name of the terminal link. 获取终端link的名称
|
||||
self.end_effector_link = self.arm.get_end_effector_link()
|
||||
|
||||
# Set the reference coordinate system used for the target position.
|
||||
# 设置目标位置所使用的参考坐标系
|
||||
self.reference_frame = "joint1"
|
||||
self.arm.set_pose_reference_frame(self.reference_frame)
|
||||
|
||||
# Allow replanning when motion planning fails.
|
||||
# 当运动规划失败后,允许重新规划
|
||||
self.arm.allow_replanning(True)
|
||||
|
||||
# Set the allowable error of position (unit: meter) and attitude (unit: radian).
|
||||
# 设置位置(单位:米)和姿态(单位:弧度)的允许误差
|
||||
self.arm.set_goal_position_tolerance(0.01)
|
||||
self.arm.set_goal_orientation_tolerance(0.05)
|
||||
|
||||
def moving(self):
|
||||
# Control the robotic arm to return to the initialization position first. 控制机械臂先回到初始化位置
|
||||
self.arm.set_named_target("init_pose")
|
||||
self.arm.go()
|
||||
rospy.sleep(2)
|
||||
|
||||
# Set the target pose in the robotic arm workspace, the position is described by x, y, z coordinates,
|
||||
# 设置机械臂工作空间中的目标位姿,位置使用x、y、z坐标描述,
|
||||
# Pose is described by quaternion, based on base_link coordinate system
|
||||
# 姿态使用四元数描述,基于base_link坐标系
|
||||
target_pose = PoseStamped()
|
||||
target_pose.header.frame_id = self.reference_frame
|
||||
target_pose.header.stamp = rospy.Time.now()
|
||||
target_pose.pose.position.x = 0.132
|
||||
target_pose.pose.position.y = -0.150
|
||||
target_pose.pose.position.z = 0.075
|
||||
target_pose.pose.orientation.x = 0.026
|
||||
target_pose.pose.orientation.y = 1.0
|
||||
target_pose.pose.orientation.z = 0.0
|
||||
target_pose.pose.orientation.w = 0.014
|
||||
|
||||
# Set the current state of the robot arm as the initial state of motion. 设置机器臂当前的状态作为运动初始状态
|
||||
self.arm.set_start_state_to_current_state()
|
||||
|
||||
# Set the target pose of the terminal motion of the robotic arm. 设置机械臂终端运动的目标位姿
|
||||
self.arm.set_pose_target(target_pose, self.end_effector_link)
|
||||
|
||||
traj = self.arm.plan()
|
||||
|
||||
# Control the motion of the robotic arm according to the planned motion path. 按照规划的运动路径控制机械臂运动
|
||||
self.arm.execute(traj)
|
||||
rospy.sleep(1)
|
||||
|
||||
# Control the terminal of the robotic arm to move 5cm to the right. Parameter 1 represents y, 0,1,2,3,4,5 represents xyzrpy
|
||||
# 控制机械臂终端向右移动5cm 參数1是代表y, 0,1,2,3,4,5 代表xyzrpy
|
||||
self.arm.shift_pose_target(1, 0.12, self.end_effector_link)
|
||||
self.arm.go()
|
||||
rospy.sleep(1)
|
||||
|
||||
self.arm.shift_pose_target(1, 0.1, self.end_effector_link)
|
||||
self.arm.go()
|
||||
rospy.sleep(1)
|
||||
|
||||
# Control the end of the robotic arm to rotate 90 degrees in reverse, 0,1,2,3,4,5 represents xyzrpy
|
||||
# 控制机械臂终端反向旋转90度, 0,1,2,3,4,5 代表xyzrpy
|
||||
# self.arm.shift_pose_target(3, -1.57, end_effector_link)
|
||||
# self.arm.go()
|
||||
# rospy.sleep(1)
|
||||
|
||||
def run(self):
|
||||
self.scene.remove_world_object("suit")
|
||||
|
||||
self.moving()
|
||||
|
||||
# Add the environment. 添加环境
|
||||
quat = quaternion_from_euler(3.1415, 0, -1.57)
|
||||
|
||||
suit_post = PoseStamped()
|
||||
suit_post.header.frame_id = self.reference_frame
|
||||
suit_post.pose.position.x = 0.0
|
||||
suit_post.pose.position.y = 0.0
|
||||
suit_post.pose.position.z = -0.02
|
||||
suit_post.pose.orientation.x = quat[0]
|
||||
suit_post.pose.orientation.y = quat[1]
|
||||
suit_post.pose.orientation.z = quat[2]
|
||||
suit_post.pose.orientation.w = quat[3]
|
||||
|
||||
suit_path = (
|
||||
roslib.packages.get_pkg_dir("mycobot_description")
|
||||
+ "/urdf/mycobot/suit_env.dae"
|
||||
)
|
||||
# need `pyassimp==3.3`
|
||||
self.scene.add_mesh("suit", suit_post, suit_path)
|
||||
rospy.sleep(2)
|
||||
|
||||
# Run again if there is environmental impact. 有环境影响后再运行一次
|
||||
self.moving()
|
||||
|
||||
# Close and exit moveit. 关闭并退出moveit
|
||||
moveit_commander.roscpp_shutdown()
|
||||
moveit_commander.os._exit(0)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
o = MoveItPlanningDemo()
|
||||
o.run()
|
||||
41
Mira/mira_moveit/scripts/sync_plan.py
Normal file
41
Mira/mira_moveit/scripts/sync_plan.py
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
#!/usr/bin/env python3
|
||||
import time
|
||||
import rospy
|
||||
from sensor_msgs.msg import JointState
|
||||
|
||||
# from pymycobot.mycobot import MyCobot
|
||||
from pymycobot.mypalletizer import MyPalletizer
|
||||
|
||||
|
||||
mc = None
|
||||
|
||||
|
||||
def callback(data):
|
||||
rospy.loginfo(rospy.get_caller_id() + "%s", data)
|
||||
data_list = []
|
||||
for index, value in enumerate(data.position):
|
||||
# if index != 2:
|
||||
# value *= -1
|
||||
data_list.append(value)
|
||||
# print("data_list:",data_list)
|
||||
mc.send_radians(data_list, 80)
|
||||
|
||||
|
||||
def listener():
|
||||
global mc
|
||||
rospy.init_node("mypal_reciver", anonymous=True)
|
||||
|
||||
port = rospy.get_param("~port", "/dev/ttyUSB0")
|
||||
baud = rospy.get_param("~baud", 115200)
|
||||
print(port, baud)
|
||||
mc = MyPalletizer(port, baud)
|
||||
|
||||
rospy.Subscriber("joint_states", JointState, callback)
|
||||
|
||||
# spin() simply keeps python from exiting until this node is stopped
|
||||
# spin()只是阻止python退出,直到该节点停止
|
||||
rospy.spin()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
listener()
|
||||
256
mycobot_description/urdf/mira_urdf/Mira-1.dae
Normal file
256
mycobot_description/urdf/mira_urdf/Mira-1.dae
Normal file
File diff suppressed because one or more lines are too long
303
mycobot_description/urdf/mira_urdf/Mira-2.dae
Normal file
303
mycobot_description/urdf/mira_urdf/Mira-2.dae
Normal file
File diff suppressed because one or more lines are too long
366
mycobot_description/urdf/mira_urdf/Mira-3.dae
Normal file
366
mycobot_description/urdf/mira_urdf/Mira-3.dae
Normal file
File diff suppressed because one or more lines are too long
195
mycobot_description/urdf/mira_urdf/Mira-base.dae
Normal file
195
mycobot_description/urdf/mira_urdf/Mira-base.dae
Normal file
File diff suppressed because one or more lines are too long
100
mycobot_description/urdf/mira_urdf/mira.urdf
Normal file
100
mycobot_description/urdf/mira_urdf/mira.urdf
Normal file
|
|
@ -0,0 +1,100 @@
|
|||
<?xml version="1.0"?>
|
||||
<robot xmlns:xacro="http://www.ros.org/wiki/xacro" name="firefighter" >
|
||||
|
||||
<xacro:property name="width" value=".2" />
|
||||
|
||||
|
||||
<link name="base">
|
||||
<visual>
|
||||
<geometry>
|
||||
<!--- 0.0 0 -0.04 1.5708 3.14159-->
|
||||
<mesh filename="package://mycobot_description/urdf/mira_urdf/Mira-base.dae"/>
|
||||
</geometry>
|
||||
<origin xyz = " 0 0 0.0 " rpy = " 0 0 0"/>
|
||||
</visual>
|
||||
<collision>
|
||||
<geometry>
|
||||
<!--- 0.0 0 -0.04 1.5708 3.14159-->
|
||||
<mesh filename="package://mycobot_description/urdf/mira_urdf/Mira-base.dae"/>
|
||||
</geometry>
|
||||
<origin xyz = " 0 0 0.0 " rpy = " 0 0 0"/>
|
||||
</collision>
|
||||
|
||||
</link>
|
||||
|
||||
<link name="link1">
|
||||
<visual>
|
||||
<geometry>
|
||||
<mesh filename="package://mycobot_description/urdf/mira_urdf/Mira-1.dae"/>
|
||||
</geometry>
|
||||
<origin xyz = "0 0 -0.122 " rpy = " 0 0 0"/>
|
||||
</visual>
|
||||
<collision>
|
||||
<geometry>
|
||||
<mesh filename="package://mycobot_description/urdf/mira_urdf/Mira-1.dae"/>
|
||||
</geometry>
|
||||
<origin xyz = "0 0 -0.122 " rpy = " 0 0 0"/>
|
||||
</collision>
|
||||
</link>
|
||||
|
||||
<link name="link2">
|
||||
<visual>
|
||||
<geometry>
|
||||
<mesh filename="package://mycobot_description/urdf/mira_urdf/Mira-2.dae"/>
|
||||
</geometry>
|
||||
<origin xyz = "0.001 0.11 0.0 " rpy = " 1.5708 0 -0.2617"/>
|
||||
</visual>
|
||||
<collision>
|
||||
<geometry>
|
||||
<mesh filename="package://mycobot_description/urdf/mira_urdf/Mira-2.dae"/>
|
||||
</geometry>
|
||||
<origin xyz = "0.001 0.11 0.0 " rpy = " 1.5708 0 -0.2617"/>
|
||||
</collision>
|
||||
|
||||
</link>
|
||||
|
||||
<link name="link3">
|
||||
<visual>
|
||||
<geometry>
|
||||
<!--- 0.0 0 -0.04 -->
|
||||
<mesh filename="package://mycobot_description/urdf/mira_urdf/Mira-3.dae"/>
|
||||
</geometry>
|
||||
<origin xyz = "0.112 0.206 -0.0 " rpy = "1.5708 0 -0.7853"/>
|
||||
</visual>
|
||||
<collision>
|
||||
<geometry>
|
||||
<!--- 0.0 0 -0.04 -->
|
||||
<mesh filename="package://mycobot_description/urdf/mira_urdf/Mira-3.dae"/>
|
||||
</geometry>
|
||||
<origin xyz = "0.112 0.206 -0.0 " rpy = "1.5708 0 -0.7853"/>
|
||||
</collision>
|
||||
</link>
|
||||
|
||||
|
||||
<joint name="joint1_to_base" type="revolute">
|
||||
<axis xyz="0 0 1"/>
|
||||
<limit effort = "1000.0" lower = "-2.967" upper = "2.967" velocity = "0"/>
|
||||
<parent link="base"/>
|
||||
<child link="link1"/>
|
||||
<origin xyz= "0 0 0.12" rpy = "0 0 0"/>
|
||||
</joint>
|
||||
|
||||
|
||||
<joint name="joint2_to_joint1" type="revolute">
|
||||
<axis xyz="0 0 1"/>
|
||||
<limit effort = "1000.0" lower = "0" upper = "1.5708" velocity = "0"/>
|
||||
<parent link="link1"/>
|
||||
<child link="link2"/>
|
||||
<origin xyz= "0.03 0 -0.01" rpy = " -1.5707963 0 0 "/>
|
||||
</joint>
|
||||
|
||||
|
||||
<joint name="joint3_to_joint2" type="revolute">
|
||||
<axis xyz=" 0 0 1"/>
|
||||
<limit effort = "1000.0" lower = "0" upper = "1.309" velocity = "0"/>
|
||||
<parent link="link2"/>
|
||||
<child link="link3"/>
|
||||
<origin xyz= "0.004 -0.126 0 " rpy = "0 0 0 "/>
|
||||
</joint>
|
||||
|
||||
</robot>
|
||||
Loading…
Add table
Reference in a new issue