mirror of
https://github.com/elephantrobotics/mycobot_ros.git
synced 2026-07-05 19:47:04 +00:00
fix bug
This commit is contained in:
parent
881aae584a
commit
2a3ecb24fd
3 changed files with 9 additions and 9 deletions
|
|
@ -15,7 +15,7 @@ def talker():
|
|||
rospy.init_node("display", anonymous=True)
|
||||
|
||||
print("Try connect real mycobot...")
|
||||
port = rospy.get_param("~port", "/dev/ttyACM0")
|
||||
port = rospy.get_param("~port", "/dev/ttyUSB0")
|
||||
baud = rospy.get_param("~baud", 115200)
|
||||
print("port: {}, baud: {}\n".format(port, baud))
|
||||
try:
|
||||
|
|
@ -65,14 +65,14 @@ def talker():
|
|||
data_list = []
|
||||
for index, value in enumerate(angles):
|
||||
data_list.append(value)
|
||||
# print('data_list=======================>',data_list)
|
||||
|
||||
# rospy.loginfo('{}'.format(data_list))
|
||||
joint_state_send.position = data_list
|
||||
|
||||
pub.publish(joint_state_send)
|
||||
|
||||
coords = mycobot.get_coords()
|
||||
# print('coords=========================>',coords)
|
||||
|
||||
# marker
|
||||
marker_.header.stamp = rospy.Time.now()
|
||||
marker_.type = marker_.SPHERE
|
||||
|
|
@ -82,10 +82,9 @@ def talker():
|
|||
marker_.scale.z = 0.04
|
||||
|
||||
# marker position initial
|
||||
print('coordscoords------------->',coords)
|
||||
if not coords:
|
||||
coords = [0, 0, 0, 0, 0, 0]
|
||||
# print('coordscoordscoords====----==========>',coords)
|
||||
|
||||
rospy.loginfo("error [101]: can not get coord values")
|
||||
|
||||
marker_.pose.position.x = coords[1] / 1000 * -1
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ def listener():
|
|||
rospy.init_node("control_slider", anonymous=True)
|
||||
|
||||
rospy.Subscriber("joint_states", JointState, callback)
|
||||
port = rospy.get_param("~port", "/dev/ttyACM0")
|
||||
port = rospy.get_param("~port", "/dev/ttyUSB0")
|
||||
baud = rospy.get_param("~baud", 115200)
|
||||
print(port, baud)
|
||||
mc = MyCobot(port, baud)
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import time
|
|||
|
||||
import roslib
|
||||
|
||||
|
||||
# Terminal output prompt information. 终端输出提示信息
|
||||
msg = """\
|
||||
Mycobot Teleop Keyboard Controller
|
||||
---------------------------
|
||||
|
|
@ -64,7 +64,7 @@ def teleop_keyboard():
|
|||
change_angle = 180 * change_percent / 100
|
||||
change_len = 250 * change_percent / 100
|
||||
|
||||
rospy.wait_for_service("get_joint_ang cles")
|
||||
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")
|
||||
|
|
@ -88,8 +88,8 @@ def teleop_keyboard():
|
|||
|
||||
while True:
|
||||
res = get_coords()
|
||||
# print(res)
|
||||
if res.x > 1:
|
||||
print("joint1's angle : "+str(res.x)+"is not > 1,please calibrate the joint1's angle")
|
||||
break
|
||||
time.sleep(0.1)
|
||||
|
||||
|
|
@ -99,6 +99,7 @@ def teleop_keyboard():
|
|||
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="")
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue