diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..843a5da --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,9 @@ +# 2021 + +## 05.13 + +- Specification package name. +- Specification file nmae. +- Added teleop keyboard control. +- Intergrated MoveIt. +- Update sync moveit plan script. \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 31beb6b..dccec72 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,6 +45,7 @@ catkin_install_python(PROGRAMS scripts/mycobot_services.py scripts/listen_real.py scripts/teleop_keyboard.py + scripts/sync_plan.py scripts/client.py scripts/camera.py DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} diff --git a/README.md b/README.md index c6e585d..d355721 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,11 @@ # mycobot_ros -[![jaywcjlove/sb](https://jaywcjlove.github.io/sb/lang/chinese.svg)](READMEcn.md) +[![jaywcjlove/sb](https://jaywcjlove.github.io/sb/lang/chinese.svg)]() +[![jaywcjlove/sb](https://jaywcjlove.github.io/sb/lang/english.svg)]() + +[中文文档](https://www.elephantrobotics.com/docs/myCobot/3-development/4-ros&moveit/) | [English Document not finish]() -[English](README.md) | [中文](READMEcn.md) -![Demo](./Screenshot-1.png) **Notes**: @@ -14,12 +15,11 @@ > ubuntu: 16.04LTS
> ros version: 1.12.17 -**If your `Atom` is 2.3 or before, or `pymycobot` is 1.\*, Please check branch [before](https://github.com/elephantrobotics/myCobotRos/tree/before)** - -Download ROS [http://wiki.ros.org/ROS/Installation](http://wiki.ros.org/ROS/Installation) + -## 1. Installation + +## Installation ### Option 1: Docker There are two ways to run this project. The first is by running the project in a container, and this requires [installing docker](https://docs.docker.com/engine/install/ubuntu/) and @@ -77,123 +77,15 @@ cd ~/catkin_ws/src/mycobot_ros python scripts/test.py ``` -## 2. Package Modules +## Screenshot -### 2.1 Nodes +![Demo](./Screenshot-1.png) -- `display` is a display node. When the node is running, the model of ROS will show the movement of mycobot synchronously. -- `control_slider` is the node which slider bar control. -- `control_marker` is the node which use interactive marker control. +![Demo](./Screenshot-2.png) -### 2.2 Topics - -- `joint_states` - control mycobot status. - - ``` - Message_type: std_msgs/JointState - Data: position[float, float, float, float, float, float] - ``` - -## 3. Visualization in RViz - -### 3.1 Functions - -- Visualization -- display.launch: This function will display robot arm movement in realtime when you manually move mycobot. - -- Control -- control.launch: This function will allow you use slider bar to control movement of the robot arm. - -### 3.2 Lanuch and Run - -- **Use slide bar to control** - - - launch ros and rviz - - ``` - roslaunch mycobot_ros mycobot_slider.launch - ``` - - - run python script - - ``` - rosrun mycobot_ros slider_control.py - ``` - -- **The model moves with the real manipulator** - - - launch ros and rviz - - ``` - roslanuch mycobot_ros mycobot_follow.launch - ``` - - - run python script - - ``` - rosrun mycobot_ros follow_display.py - ``` - -- **Open the keyboard controller** - - - launch - - ``` - roslaunch mycobot_ros mycobot_teleop_keyboard.launch PORT:=/dev/ttyUSB0 - ``` - - - open another terminal run script - - ``` - rosrun mycobot_ros teleop_keyboard.py _speed:=60 _change_size:=10 - ``` - - Then you will see this: - - ``` - Mycobot Teleop Keyboard Controller - --------------------------- - Movimg options(control coord [x,y,z,rx,ry,rz]): - w(x+) - - a(y-) s(x-) d(y+) - - z(z-) x(z+) - - u(rx+) i(ry+) o(rz+) - j(rx-) k(ry-) l(rz-) - - Gripper control: - g - open - h - close - - Other: - 1 - Go to init pose - 2 - - 3 - - q - Quit - - currently: speed 50 change size 10 - ``` - -## MoveIT - -### Execute plan with actual robot. - -``` -roslaunch mycobot_ros demo.launch -``` - -Open a new terminal and run: - -``` -rosrun mycobot_ros sync_signal.py -``` - - +![Demo](./Screenshot-3.png) +![Demo](./Screenshot-4.png) ## Q & A **Q: error[101]** diff --git a/Screenshot-2.png b/Screenshot-2.png new file mode 100644 index 0000000..355339e Binary files /dev/null and b/Screenshot-2.png differ diff --git a/Screenshot-3.png b/Screenshot-3.png new file mode 100644 index 0000000..045fca4 Binary files /dev/null and b/Screenshot-3.png differ diff --git a/Screenshot-4.png b/Screenshot-4.png new file mode 100644 index 0000000..ab5cf92 Binary files /dev/null and b/Screenshot-4.png differ diff --git a/launch/communication_service.launch b/launch/communication_service.launch index 363568f..f645767 100644 --- a/launch/communication_service.launch +++ b/launch/communication_service.launch @@ -1,10 +1,10 @@ - - + + - - + + diff --git a/launch/mycobot_moveit.launch b/launch/mycobot_moveit.launch new file mode 100644 index 0000000..6e9e240 --- /dev/null +++ b/launch/mycobot_moveit.launch @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + + + + + + + + + + + + [move_group/fake_controller_joint_states] + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/launch/mycobot_teleop_keyboard.launch b/launch/mycobot_teleop_keyboard.launch index 6762ad6..090c2bf 100644 --- a/launch/mycobot_teleop_keyboard.launch +++ b/launch/mycobot_teleop_keyboard.launch @@ -1,6 +1,6 @@ - - + + @@ -14,8 +14,8 @@ - - + + diff --git a/scripts/camera.py b/scripts/camera.py index 7d3a33a..a1ccb4c 100755 --- a/scripts/camera.py +++ b/scripts/camera.py @@ -73,25 +73,25 @@ class image_converter: cv.imshow("Image", cv_image) - # marker = Marker() - # marker.header.frame_id = '/joint1' - # 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 = Marker() + marker.header.frame_id = '/joint1' + 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.pose.position.x = center_x / 100 - # marker.pose.position.y = center_y / 100 - # marker.pose.position.z = 0 + marker.pose.position.x = 0 + marker.pose.position.y = 0 + marker.pose.position.z = 0 - # marker.color.a = 1.0 - # marker.color.g = 1.0 + marker.color.a = 1.0 + marker.color.g = 1.0 cv.waitKey(3) try: - # self.mark_pub.publish(marker) + self.mark_pub.publish(marker) pass except CvBridgeError as e: print e diff --git a/scripts/sync_signal.py b/scripts/sync_plan.py similarity index 77% rename from scripts/sync_signal.py rename to scripts/sync_plan.py index 74f8b7f..913a642 100755 --- a/scripts/sync_signal.py +++ b/scripts/sync_plan.py @@ -1,11 +1,14 @@ #!/usr/bin/env python2 -import time, subprocess +import time import rospy from sensor_msgs.msg import JointState from pymycobot.mycobot import MyCobot +mc = None + + def callback(data): rospy.loginfo(rospy.get_caller_id() + "%s", data) data_list = [] @@ -17,15 +20,18 @@ def callback(data): mc.send_radians(data_list, 80) def listener(): + global mc rospy.init_node('mycobot_reciver', anonymous=True) + port = rospy.get_param('~port', '/dev/ttyUSB0') + baud = rospy.get_param('~baud', 115200) + print(port, baud) + mc = MyCobot(port, baud) + rospy.Subscriber("joint_states", JointState, callback) # spin() simply keeps python from exiting until this node is stopped rospy.spin() if __name__ == '__main__': - port = subprocess.check_output(['echo -n /dev/ttyUSB*'], - shell=True) - mc = MyCobot(port) listener() \ No newline at end of file diff --git a/scripts/teleop_keyboard.py b/scripts/teleop_keyboard.py index c52b336..219d3c6 100755 --- a/scripts/teleop_keyboard.py +++ b/scripts/teleop_keyboard.py @@ -40,7 +40,7 @@ Other: def vels(speed, turn): - return "currently:\tspeed %s\tchange size %s " % (speed, turn) + return "currently:\tspeed: %s\tchange percent: %s " % (speed, turn) class Raw(object): @@ -57,17 +57,14 @@ class Raw(object): def teleop_keyboard(): - global settings - settings = termios.tcgetattr(sys.stdin) - rospy.init_node('teleop_keyboard') model = 0 speed = rospy.get_param("~speed", 50) - change_size = rospy.get_param("~change_size", 10) - key_timeout = rospy.get_param("~key_timeout", 0.0) - if key_timeout == 0.0: - key_timeout = None + 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') @@ -103,49 +100,49 @@ def teleop_keyboard(): try: print(msg) - print(vels(speed, change_size)) + print(vels(speed, change_percent)) while(1): try: - print("\r current coords: %s" % record_coords, end="") + # 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_size + record_coords[0] += change_len set_coords(*record_coords) elif key in ['s', 'S']: - record_coords[0] -= change_size + record_coords[0] -= change_len set_coords(*record_coords) elif key in ['a', 'A']: - record_coords[1] -= change_size + record_coords[1] -= change_len set_coords(*record_coords) elif key in ['d', 'D']: - record_coords[1] += change_size + record_coords[1] += change_len set_coords(*record_coords) elif key in ['z', 'Z']: - record_coords[2] -= change_size + record_coords[2] -= change_len set_coords(*record_coords) elif key in ['x', 'X']: - record_coords[2] += change_size + record_coords[2] += change_len set_coords(*record_coords) elif key in ['u', 'U']: - record_coords[3] += change_size + record_coords[3] += change_angle set_coords(*record_coords) elif key in ['j', 'J']: - record_coords[3] -= change_size + record_coords[3] -= change_angle set_coords(*record_coords) elif key in ['i', 'I']: - record_coords[4] += change_size + record_coords[4] += change_angle set_coords(*record_coords) elif key in ['k', 'K']: - record_coords[4] -= change_size + record_coords[4] -= change_angle set_coords(*record_coords) elif key in ['o', 'O']: - record_coords[5] += change_size + record_coords[5] += change_angle set_coords(*record_coords) elif key in ['l', 'L']: - record_coords[5] -= change_size + record_coords[5] -= change_angle set_coords(*record_coords) elif key in ['g', 'G']: switch_gripper(True)