From 0545d04876e738571f77108d3e36ccb5ea0025ad Mon Sep 17 00:00:00 2001 From: 2929ss <1814754095@qq.com> Date: Wed, 13 Jul 2022 10:58:24 +0800 Subject: [PATCH 1/2] update --- .../launch/communication_topic_pi.launch | 2 +- mecharm/mecharm_communication/scripts/mecharm_topics.py | 2 +- mecharm/mecharm_communication/scripts/mecharm_topics_pi.py | 2 +- mycobot_ai/myCobot_280/launch/vision_pi.launch | 4 ++-- mycobot_ai/myCobot_280/scripts/combine_detect_obj_color .py | 2 +- mycobot_communication/scripts/mycobot_topics.py | 4 +++- mycobot_communication/scripts/mycobot_topics_pi.py | 2 +- .../mypalletizer_communication/scripts/mypal_topics_pi.py | 2 +- 8 files changed, 11 insertions(+), 9 deletions(-) diff --git a/mecharm/mecharm_communication/launch/communication_topic_pi.launch b/mecharm/mecharm_communication/launch/communication_topic_pi.launch index 959557e..d3d255e 100644 --- a/mecharm/mecharm_communication/launch/communication_topic_pi.launch +++ b/mecharm/mecharm_communication/launch/communication_topic_pi.launch @@ -1,4 +1,4 @@ - +3 diff --git a/mecharm/mecharm_communication/scripts/mecharm_topics.py b/mecharm/mecharm_communication/scripts/mecharm_topics.py index 799fe4b..02c3934 100755 --- a/mecharm/mecharm_communication/scripts/mecharm_topics.py +++ b/mecharm/mecharm_communication/scripts/mecharm_topics.py @@ -70,7 +70,7 @@ class MycobotTopics(object): rospy.init_node("mycobot_topics") rospy.loginfo("start ...") - port = rospy.get_param("~port", "/dev/ttyUSB0") + port = rospy.get_param("~port", os.popen("ls /dev/ttyUSB*").readline()[:-1]) baud = rospy.get_param("~baud", 115200) rospy.loginfo("%s,%s" % (port, baud)) self.mc = MyCobot(port, baud) diff --git a/mecharm/mecharm_communication/scripts/mecharm_topics_pi.py b/mecharm/mecharm_communication/scripts/mecharm_topics_pi.py index 39be565..857650c 100755 --- a/mecharm/mecharm_communication/scripts/mecharm_topics_pi.py +++ b/mecharm/mecharm_communication/scripts/mecharm_topics_pi.py @@ -74,7 +74,7 @@ class MycobotTopics(object): rospy.init_node("mycobot_topics_pi") rospy.loginfo("start ...") # problem - port = rospy.get_param("~port", "/dev/ttyAMA0") + port = rospy.get_param("~port", os.popen("ls /dev/ttyAMA*").readline()[:-1]) baud = rospy.get_param("~baud", 1000000) rospy.loginfo("%s,%s" % (port, baud)) # self.mc = MyCobotSocket(port, baud) # port diff --git a/mycobot_ai/myCobot_280/launch/vision_pi.launch b/mycobot_ai/myCobot_280/launch/vision_pi.launch index a01ed45..5187d9e 100644 --- a/mycobot_ai/myCobot_280/launch/vision_pi.launch +++ b/mycobot_ai/myCobot_280/launch/vision_pi.launch @@ -14,13 +14,13 @@ - + - + diff --git a/mycobot_ai/myCobot_280/scripts/combine_detect_obj_color .py b/mycobot_ai/myCobot_280/scripts/combine_detect_obj_color .py index a2f624c..da902ee 100755 --- a/mycobot_ai/myCobot_280/scripts/combine_detect_obj_color .py +++ b/mycobot_ai/myCobot_280/scripts/combine_detect_obj_color .py @@ -77,7 +77,7 @@ class Object_detect(Movement): "yellow": [np.array([11, 115, 70]), np.array([40, 255, 245])], "red": [np.array([0, 43, 46]), np.array([8, 255, 255])], "green": [np.array([35, 43, 46]), np.array([77, 255, 255])], - "blue": [np.array([100, 43, 46]), np.array([124, 255, 255])], + # "blue": [np.array([100, 43, 46]), np.array([124, 255, 255])], "cyan": [np.array([78, 43, 46]), np.array([99, 255, 255])], } # use to calculate coord between cube and mycobot diff --git a/mycobot_communication/scripts/mycobot_topics.py b/mycobot_communication/scripts/mycobot_topics.py index 799fe4b..5039b0d 100755 --- a/mycobot_communication/scripts/mycobot_topics.py +++ b/mycobot_communication/scripts/mycobot_topics.py @@ -70,7 +70,9 @@ class MycobotTopics(object): rospy.init_node("mycobot_topics") rospy.loginfo("start ...") - port = rospy.get_param("~port", "/dev/ttyUSB0") + port = rospy.get_param("~port", os.popen("ls /dev/ttyUSB*").readline()[:-1]) + if not port: + port = rospy.get_param("~port", os.popen("ls /dev/ttyACM*").readline()[:-1]) baud = rospy.get_param("~baud", 115200) rospy.loginfo("%s,%s" % (port, baud)) self.mc = MyCobot(port, baud) diff --git a/mycobot_communication/scripts/mycobot_topics_pi.py b/mycobot_communication/scripts/mycobot_topics_pi.py index 1ccf23c..ae09c88 100755 --- a/mycobot_communication/scripts/mycobot_topics_pi.py +++ b/mycobot_communication/scripts/mycobot_topics_pi.py @@ -74,7 +74,7 @@ class MycobotTopics(object): rospy.init_node("mycobot_topics_pi") rospy.loginfo("start ...") # problem - port = rospy.get_param("~port", "/dev/ttyAMA0") + port = rospy.get_param("~port", os.popen("ls /dev/ttyAMA*").readline()[:-1]") baud = rospy.get_param("~baud", 1000000) rospy.loginfo("%s,%s" % (port, baud)) self.mc = MyCobotSocket(port, baud) # port diff --git a/mypalletizer_260/mypalletizer_communication/scripts/mypal_topics_pi.py b/mypalletizer_260/mypalletizer_communication/scripts/mypal_topics_pi.py index 4af28ee..b0f2ea9 100755 --- a/mypalletizer_260/mypalletizer_communication/scripts/mypal_topics_pi.py +++ b/mypalletizer_260/mypalletizer_communication/scripts/mypal_topics_pi.py @@ -69,7 +69,7 @@ class MypalTopics(object): rospy.init_node("mypal_topics_pi") rospy.loginfo("start ...") # problem - port = rospy.get_param("~port", "/dev/ttyAMA0") + port = rospy.get_param("~port", os.popen("ls /dev/ttyAMA*").readline()[:-1]) baud = rospy.get_param("~baud", 1000000) rospy.loginfo("%s,%s" % (port, baud)) # self.mc = MyCobotSocket(port, baud) # port From c370f430981416bde7b5849cac34742276dcc32e Mon Sep 17 00:00:00 2001 From: 2929ss <1814754095@qq.com> Date: Thu, 14 Jul 2022 11:31:43 +0800 Subject: [PATCH 2/2] update --- .../scripts/combine_detect_obj_color.py | 2 +- mycobot_ai/mechArm_270/scripts/test.py | 14 ++++++++------ .../scripts/combine_detect_obj_img_folder_opt.py | 2 +- mycobot_ai/myCobot_280/scripts/test.py | 12 +++++++----- 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/mycobot_ai/mechArm_270/scripts/combine_detect_obj_color.py b/mycobot_ai/mechArm_270/scripts/combine_detect_obj_color.py index 338b625..d164f82 100644 --- a/mycobot_ai/mechArm_270/scripts/combine_detect_obj_color.py +++ b/mycobot_ai/mechArm_270/scripts/combine_detect_obj_color.py @@ -162,7 +162,7 @@ class Object_detect(Movement): self.mc.send_coords([x, y, 140, 179.12, -0.18, 179.46], 30, 0) time.sleep(3) - self.mc.send_coords([x, y, 92, 179.12, -0.18, 179.46], 30, 0) # -178.77, -2.69, 40.15 + self.mc.send_coords([x, y, 110, 179.12, -0.18, 179.46], 30, 0) # -178.77, -2.69, 40.15 time.sleep(3) # open pump diff --git a/mycobot_ai/mechArm_270/scripts/test.py b/mycobot_ai/mechArm_270/scripts/test.py index 167e662..a8e2a3f 100755 --- a/mycobot_ai/mechArm_270/scripts/test.py +++ b/mycobot_ai/mechArm_270/scripts/test.py @@ -6,13 +6,12 @@ from pymycobot.genre import Angle from pymycobot import PI_PORT, PI_BAUD # 当使用树莓派版本的mycobot时,可以引用这两个变量进行MyCobot初始化 import time,os -# mc = MyPalletizer(os.popen("ls /dev/ttyUSB*").readline()[:-1], 115200) -mc = MyCobot("/dev/ttyAMA0", 1000000) -# mc = MyPalletizer("/dev/ttyAMA0", 1000000) +mc = MyCobot(os.popen("ls /dev/ttyUSB*").readline()[:-1], 115200) +# mc = MyCobot("/dev/ttyAMA0", 1000000) -mc.send_angles([0,0,0,0,90,0],30) # coords:[95.6, 0.5, 166.4, 179.12, -0.18, 179.46] -# mc.send_angles([-3.25, 17.22, -32.51, 2.37, 92.54, -36.21],30) +mc.send_angles([0,0,0,0,90,0],20) # coords:[95.6, 0.5, 166.4, 179.12, -0.18, 179.46] +# # mc.send_angles([-3.25, 17.22, -32.51, 2.37, 92.54, -36.21],30) time.sleep(4) @@ -41,7 +40,10 @@ time.sleep(4) # print("\n") # mc.release_all_servos() +# mc.release_servo(3) # mc.set_servo_calibration(1) # mc.set_servo_calibration(2) # mc.set_servo_calibration(3) -# mc.set_servo_calibration(4) \ No newline at end of file +# mc.set_servo_calibration(4) +# mc.set_servo_calibration(5) +# mc.set_servo_calibration(6) diff --git a/mycobot_ai/myCobot_280/scripts/combine_detect_obj_img_folder_opt.py b/mycobot_ai/myCobot_280/scripts/combine_detect_obj_img_folder_opt.py index 72184b7..05dd2a1 100644 --- a/mycobot_ai/myCobot_280/scripts/combine_detect_obj_img_folder_opt.py +++ b/mycobot_ai/myCobot_280/scripts/combine_detect_obj_img_folder_opt.py @@ -60,7 +60,7 @@ class Object_detect(Movement): if "dev" in self.robot_m5: self.Pin = [2, 5] elif "dev" in self.robot_wio: - self.Pin = [20, 21] + self.Pin = [2, 5] for i in self.move_coords: i[2] -= 20 elif "dev" in self.robot_raspi or "dev" in self.robot_jes: diff --git a/mycobot_ai/myCobot_280/scripts/test.py b/mycobot_ai/myCobot_280/scripts/test.py index 94d95bc..79e8a70 100755 --- a/mycobot_ai/myCobot_280/scripts/test.py +++ b/mycobot_ai/myCobot_280/scripts/test.py @@ -4,13 +4,15 @@ from pymycobot.genre import Angle from pymycobot import PI_PORT, PI_BAUD # 当使用树莓派版本的mycobot时,可以引用这两个变量进行MyCobot初始化 import time -mc = MyCobot("/dev/ttyACM0", 115200) -# mc = MyCobot("/dev/ttyUSB0", 115200) +# mc = MyCobot("/dev/ttyACM0", 115200) +mc = MyCobot("/dev/ttyUSB0", 115200) # mc = MyCobot("/dev/ttyAMA0", 1000000) -# mc.send_angles([0,0,0,0,90,0], 20) +# mc.send_angles([0,0,0,0,0,0], 25) +# print(mc.get_angles()) mc.send_angles([-7.11, -6.94, -55.01, -24.16, 0.0, -15], 30) time.sleep(4) +# print(mc.get_angles()) # mc.send_coords([120.8, -134.4, 258.0, -172.72, -5.31, -109.09], 30, 1) # red bucket # time.sleep(4) @@ -28,8 +30,8 @@ time.sleep(4) # mc.send_angles([1.4, 0, -53.61, -33.39, -3.51, -20.3],20) # time.sleep(3) -mc.send_coords([145.3, -11.2, 126.6, 179.87, -3.78, -62.75], 30, 1) -time.sleep(6) +# mc.send_coords([145.3, -11.2, 126.6, 179.87, -3.78, -62.75], 30, 1) +# time.sleep(6) # mc.release_all_servos()