mirror of
https://github.com/elephantrobotics/mycobot_ros.git
synced 2026-07-05 19:47:04 +00:00
add encoding=utf-8
This commit is contained in:
parent
e434301c17
commit
eaa2e0592f
8 changed files with 16 additions and 11 deletions
|
|
@ -1,4 +1,5 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
# -*- coding:utf-8 -*-
|
||||||
import rospy
|
import rospy
|
||||||
import cv2 as cv
|
import cv2 as cv
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python2
|
||||||
# coding:utf-8
|
# -*- coding:utf-8 -*-
|
||||||
import rospy
|
import rospy
|
||||||
from visualization_msgs.msg import Marker
|
from visualization_msgs.msg import Marker
|
||||||
import time
|
import time
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python2
|
||||||
|
# -*- coding:utf-8 -*-
|
||||||
from cgi import print_environ
|
from cgi import print_environ
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
|
@ -14,7 +15,7 @@ def talker():
|
||||||
rospy.init_node("display", anonymous=True)
|
rospy.init_node("display", anonymous=True)
|
||||||
|
|
||||||
print("Try connect real mycobot...")
|
print("Try connect real mycobot...")
|
||||||
port = rospy.get_param("~port", "/dev/ttyUSB0")
|
port = rospy.get_param("~port", "/dev/ttyACM0")
|
||||||
baud = rospy.get_param("~baud", 115200)
|
baud = rospy.get_param("~baud", 115200)
|
||||||
print("port: {}, baud: {}\n".format(port, baud))
|
print("port: {}, baud: {}\n".format(port, baud))
|
||||||
try:
|
try:
|
||||||
|
|
@ -61,18 +62,17 @@ def talker():
|
||||||
joint_state_send.header.stamp = rospy.Time.now()
|
joint_state_send.header.stamp = rospy.Time.now()
|
||||||
|
|
||||||
angles = mycobot.get_radians()
|
angles = mycobot.get_radians()
|
||||||
print('angels=====================>',angles)
|
|
||||||
data_list = []
|
data_list = []
|
||||||
for index, value in enumerate(angles):
|
for index, value in enumerate(angles):
|
||||||
data_list.append(value)
|
data_list.append(value)
|
||||||
print('data_list=======================>',data_list)
|
# print('data_list=======================>',data_list)
|
||||||
# rospy.loginfo('{}'.format(data_list))
|
# rospy.loginfo('{}'.format(data_list))
|
||||||
joint_state_send.position = data_list
|
joint_state_send.position = data_list
|
||||||
|
|
||||||
pub.publish(joint_state_send)
|
pub.publish(joint_state_send)
|
||||||
|
|
||||||
coords = mycobot.get_coords()
|
coords = mycobot.get_coords()
|
||||||
print('coords=========================>',coords)
|
# print('coords=========================>',coords)
|
||||||
# marker
|
# marker
|
||||||
marker_.header.stamp = rospy.Time.now()
|
marker_.header.stamp = rospy.Time.now()
|
||||||
marker_.type = marker_.SPHERE
|
marker_.type = marker_.SPHERE
|
||||||
|
|
@ -85,7 +85,7 @@ def talker():
|
||||||
print('coordscoords------------->',coords)
|
print('coordscoords------------->',coords)
|
||||||
if not coords:
|
if not coords:
|
||||||
coords = [0, 0, 0, 0, 0, 0]
|
coords = [0, 0, 0, 0, 0, 0]
|
||||||
print('coordscoordscoords====----==========>',coords)
|
# print('coordscoordscoords====----==========>',coords)
|
||||||
rospy.loginfo("error [101]: can not get coord values")
|
rospy.loginfo("error [101]: can not get coord values")
|
||||||
|
|
||||||
marker_.pose.position.x = coords[1] / 1000 * -1
|
marker_.pose.position.x = coords[1] / 1000 * -1
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python2
|
||||||
|
# -*- coding:utf-8 -*-
|
||||||
import time
|
import time
|
||||||
|
|
||||||
import rospy
|
import rospy
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python2
|
||||||
|
# -*- coding:utf-8 -*-
|
||||||
# license removed for brevity
|
# license removed for brevity
|
||||||
import time
|
import time
|
||||||
import math
|
import math
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python2
|
||||||
|
# -*- coding:utf-8 -*-
|
||||||
import math
|
import math
|
||||||
|
|
||||||
import rospy
|
import rospy
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python2
|
||||||
|
# -*- coding:utf-8 -*-
|
||||||
"""[summary]
|
"""[summary]
|
||||||
This file obtains the joint angle of the manipulator in ROS,
|
This file obtains the joint angle of the manipulator in ROS,
|
||||||
and then sends it directly to the real manipulator using `pymycobot` API.
|
and then sends it directly to the real manipulator using `pymycobot` API.
|
||||||
|
|
@ -20,13 +20,13 @@ mc = None
|
||||||
|
|
||||||
def callback(data):
|
def callback(data):
|
||||||
# rospy.loginfo(rospy.get_caller_id() + "%s", data.position)
|
# rospy.loginfo(rospy.get_caller_id() + "%s", data.position)
|
||||||
print('data_position======================>',data.position)
|
# print('data_position======================>',data.position)
|
||||||
data_list = []
|
data_list = []
|
||||||
for index, value in enumerate(data.position):
|
for index, value in enumerate(data.position):
|
||||||
data_list.append(value)
|
data_list.append(value)
|
||||||
|
|
||||||
mc.send_radians(data_list, 80)
|
mc.send_radians(data_list, 80)
|
||||||
print('data_list=====================>',data_list)
|
# print('data_list=====================>',data_list)
|
||||||
# time.sleep(0.5)
|
# time.sleep(0.5)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -35,7 +35,7 @@ def listener():
|
||||||
rospy.init_node("control_slider", anonymous=True)
|
rospy.init_node("control_slider", anonymous=True)
|
||||||
|
|
||||||
rospy.Subscriber("joint_states", JointState, callback)
|
rospy.Subscriber("joint_states", JointState, callback)
|
||||||
port = rospy.get_param("~port", "/dev/ttyUSB0")
|
port = rospy.get_param("~port", "/dev/ttyACM0")
|
||||||
baud = rospy.get_param("~baud", 115200)
|
baud = rospy.get_param("~baud", 115200)
|
||||||
print(port, baud)
|
print(port, baud)
|
||||||
mc = MyCobot(port, baud)
|
mc = MyCobot(port, baud)
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
# -*- coding:utf-8 -*-
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
from mycobot_communication.srv import GetCoords, SetCoords, GetAngles, SetAngles, GripperStatus
|
from mycobot_communication.srv import GetCoords, SetCoords, GetAngles, SetAngles, GripperStatus
|
||||||
import rospy
|
import rospy
|
||||||
|
|
@ -63,7 +64,7 @@ def teleop_keyboard():
|
||||||
change_angle = 180 * change_percent / 100
|
change_angle = 180 * change_percent / 100
|
||||||
change_len = 250 * change_percent / 100
|
change_len = 250 * change_percent / 100
|
||||||
|
|
||||||
rospy.wait_for_service("get_joint_angles")
|
rospy.wait_for_service("get_joint_ang cles")
|
||||||
rospy.wait_for_service("set_joint_angles")
|
rospy.wait_for_service("set_joint_angles")
|
||||||
rospy.wait_for_service("get_joint_coords")
|
rospy.wait_for_service("get_joint_coords")
|
||||||
rospy.wait_for_service("set_joint_coords")
|
rospy.wait_for_service("set_joint_coords")
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue