From e6fcc676c5c077db06fbba5d5a5016569cc1ee23 Mon Sep 17 00:00:00 2001 From: Zachary Date: Tue, 29 Dec 2020 17:39:40 +0800 Subject: [PATCH 1/7] Update README.md --- README.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 26041ff..9cb61a4 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,7 @@ **Notes**: + > Make sure that `Atom2.1alpha` is flashed into the top Atom and `Transponder` is flashed into the base Basic .The tool download address: [https://github.com/elephantrobotics/myCobot/tree/main/Software](https://github.com/elephantrobotics/myCobot/tree/main/Software)
> ubuntu: 16.04LTS
> ros version: 1.12.17 @@ -13,7 +14,8 @@ For using this package, the [api]() library should be installed first.(demo comes with) -If you want to use api alone, you can look here [https://github.com/elephantrobotics/myCobotROS/mian/script/pythonAPI/README.md](https://github.com/elephantrobotics/myCobotROS/mian/script/pythonAPI/README.md) +If you want to use api alone, you can look here [https://github.com/elephantrobotics/myCobotROS/blob/main/scripts/pythonAPI/README.md](https://github.com/elephantrobotics/myCobotROS/blob/main/scripts/pythonAPI/README.md) + ### 1.2 Package Download and Install Install ros package in your src folder of your Catkin workspace. @@ -57,7 +59,7 @@ If the myCobot color change to red, it's mean the API is working normally. - 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. +- Control -- control.launch: This function will allow you use slider bar to control movement of the robot arm. ### 3.2 Lanuch and Run @@ -107,5 +109,8 @@ c) For marker control rosrun myCobots control_marker.py ``` +## Q & A +**Q: error[101]** +**A:** Make sure that the serial port is not occupied, and that the correct firmware is burned in for atom and basic From cc9c7151b60709c445e1d2bdf500b9fbad91f841 Mon Sep 17 00:00:00 2001 From: Zachary Zhang Date: Wed, 30 Dec 2020 18:55:26 +0800 Subject: [PATCH 2/7] fix: Add complement zero of speed in send_angle function. --- scripts/pythonAPI/mycobot.py | 5 +++-- scripts/pythonAPI/mycobot3.py | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/scripts/pythonAPI/mycobot.py b/scripts/pythonAPI/mycobot.py index 7360dda..06fba8d 100644 --- a/scripts/pythonAPI/mycobot.py +++ b/scripts/pythonAPI/mycobot.py @@ -94,7 +94,8 @@ class MyCobot(): ''' _hex = self._angle_to_hex(degree) - command = 'fefe0621{}{}{}fa'.format(id, _hex, hex(speed)[2:]) + speed = self._complement_zero(hex(speed)[2:], digit=2) + command = 'fefe0621{}{}{}fa'.format(id, _hex, speed) # print(command) self._write(command) @@ -353,4 +354,4 @@ class MyCobot(): def _read(self, size=1024): data = self.serial_port.read(size) - return data \ No newline at end of file + return data diff --git a/scripts/pythonAPI/mycobot3.py b/scripts/pythonAPI/mycobot3.py index f6f8009..263386d 100644 --- a/scripts/pythonAPI/mycobot3.py +++ b/scripts/pythonAPI/mycobot3.py @@ -95,7 +95,8 @@ class MyCobot(): ''' _hex = self._angle_to_hex(degree) - command = 'fefe0621{}{}{}fa'.format(id, _hex, hex(speed)[2:]) + speed = self._complement_zero(hex(speed)[2:], digit=2) + command = 'fefe0621{}{}{}fa'.format(id, _hex, speed) # print(command) self._write(command) @@ -354,4 +355,4 @@ class MyCobot(): def _read(self, size: int=1024): data = self.serial_port.read(size) - return data \ No newline at end of file + return data From e49c3d1da33a181e824f92798de2edbe80b5b97a Mon Sep 17 00:00:00 2001 From: nisshan-x Date: Thu, 31 Dec 2020 00:15:10 +0900 Subject: [PATCH 3/7] Fix some typos in commands --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 9cb61a4..08b5110 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ $ catkin_make ### 1.3 Test API ```bash -cd ~/catkin_ws/src/myCobotRos +cd ~/catkin_ws/src/myCobotROS python3 scripts/test.py ``` @@ -66,7 +66,7 @@ If the myCobot color change to red, it's mean the API is working normally. -**Step 1**: In one terminal, open the core. ```bash -rocore #open another tab +roscore #open another tab ``` -**Step 2**: Launch @@ -94,19 +94,19 @@ rosrun rviz rviz a) For display ```bash -rosrun myCobotRos display.py +rosrun myCobotROS display.py ``` b) For slider bar. ```bash -rosrun myCobotRos control_slider.py +rosrun myCobotROS control_slider.py ``` c) For marker control ```bash -rosrun myCobots control_marker.py +rosrun myCobotROS control_marker.py ``` ## Q & A From 19f53f0b481ec7d079410a8217f4361e85cd5f72 Mon Sep 17 00:00:00 2001 From: nisshan-x Date: Thu, 31 Dec 2020 00:52:07 +0900 Subject: [PATCH 4/7] I created a rviz config file. It's useful to show myCobot model quickly. Option 1 : Open and choose it in rviz. Option 2 : Run in terminal like this: rosrun rviz rviz -d `rospack find myCobotROS`/config/mycobot.rviz Option 3 : add in launch file like this: --- config/mycobot.rviz | 171 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 171 insertions(+) create mode 100644 config/mycobot.rviz diff --git a/config/mycobot.rviz b/config/mycobot.rviz new file mode 100644 index 0000000..c2f6a68 --- /dev/null +++ b/config/mycobot.rviz @@ -0,0 +1,171 @@ +Panels: + - Class: rviz/Displays + Help Height: 78 + Name: Displays + Property Tree Widget: + Expanded: + - /Global Options1 + - /Status1 + 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: + 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 + joint1: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + joint2: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + joint3: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + joint4: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + joint5: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + joint6: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + joint6_flange: + 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 + Enabled: true + Global Options: + Background Color: 48; 48; 48 + Default Light: true + Fixed Frame: joint1 + 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: 1.2028908729553223 + Enable Stereo Rendering: + Stereo Eye Separation: 0.05999999865889549 + Stereo Focal Distance: 1 + Swap Stereo Eyes: false + Value: false + Focal Point: + X: -0.07064759731292725 + Y: -0.0814988762140274 + Z: 0.10758385062217712 + Focal Shape Fixed Size: true + Focal Shape Size: 0.05000000074505806 + Invert Z Axis: false + Name: Current View + Near Clip Distance: 0.009999999776482582 + Pitch: 0.35539841651916504 + Target Frame: + Value: Orbit (rviz) + Yaw: 0.7703980207443237 + Saved: ~ +Window Geometry: + Displays: + collapsed: false + Height: 885 + Hide Left Dock: false + Hide Right Dock: false + QMainWindow State: 000000ff00000000fd000000040000000000000156000002d9fc0200000008fb0000001200530065006c0065006300740069006f006e00000001e10000009b0000005c00fffffffb0000001e0054006f006f006c002000500072006f007000650072007400690065007302000001ed000001df00000185000000a3fb000000120056006900650077007300200054006f006f02000001df000002110000018500000122fb000000200054006f006f006c002000500072006f0070006500720074006900650073003203000002880000011d000002210000017afb000000100044006900730070006c006100790073010000003c000002d9000000c800fffffffb0000002000730065006c0065006300740069006f006e00200062007500660066006500720200000138000000aa0000023a00000294fb00000014005700690064006500530074006500720065006f02000000e6000000d2000003ee0000030bfb0000000c004b0069006e0065006300740200000186000001060000030c00000261000000010000010f000002d9fc0200000003fb0000001e0054006f006f006c002000500072006f00700065007200740069006500730100000041000000780000000000000000fb0000000a00560069006500770073010000003c000002d9000000a200fffffffb0000001200530065006c0065006300740069006f006e010000025a000000b200000000000000000000000200000490000000a9fc0100000001fb0000000a00560069006500770073030000004e00000080000002e10000019700000003000005240000003efc0100000002fb0000000800540069006d00650100000000000005240000029800fffffffb0000000800540069006d00650100000000000004500000000000000000000002b3000002d900000004000000040000000800000008fc0000000100000002000000010000000a0054006f006f006c00730100000000ffffffff0000000000000000 + Selection: + collapsed: false + Time: + collapsed: false + Tool Properties: + collapsed: false + Views: + collapsed: false + Width: 1316 + X: 349 + Y: 42 From 3d9d8cc6075b6284d15ae0ad15fdbf462adba368 Mon Sep 17 00:00:00 2001 From: nisshan-x Date: Thu, 31 Dec 2020 01:06:49 +0900 Subject: [PATCH 5/7] fix: change mode of python files to run. --- scripts/control_marker.py | 0 scripts/pythonAPI/__init__.py | 0 scripts/pythonAPI/common.py | 0 scripts/pythonAPI/mycobot.py | 0 scripts/pythonAPI/mycobot3.py | 0 5 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 scripts/control_marker.py mode change 100644 => 100755 scripts/pythonAPI/__init__.py mode change 100644 => 100755 scripts/pythonAPI/common.py mode change 100644 => 100755 scripts/pythonAPI/mycobot.py mode change 100644 => 100755 scripts/pythonAPI/mycobot3.py diff --git a/scripts/control_marker.py b/scripts/control_marker.py old mode 100644 new mode 100755 diff --git a/scripts/pythonAPI/__init__.py b/scripts/pythonAPI/__init__.py old mode 100644 new mode 100755 diff --git a/scripts/pythonAPI/common.py b/scripts/pythonAPI/common.py old mode 100644 new mode 100755 diff --git a/scripts/pythonAPI/mycobot.py b/scripts/pythonAPI/mycobot.py old mode 100644 new mode 100755 diff --git a/scripts/pythonAPI/mycobot3.py b/scripts/pythonAPI/mycobot3.py old mode 100644 new mode 100755 From 5f78342b73a50a8f12a497364c6fac1b801e05a0 Mon Sep 17 00:00:00 2001 From: Zachary Zhang Date: Sun, 3 Jan 2021 18:55:06 +0800 Subject: [PATCH 6/7] docs(readme): add rviz mode usage --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 08b5110..0c9a84a 100644 --- a/README.md +++ b/README.md @@ -89,6 +89,12 @@ roslaunch myCobotROS control.launch rosrun rviz rviz ``` +If you use the above command, then you may need to manually add some model components. If you don't want to be so troublesome, you can use the following command to load a saved **myCobot** model. + +```bash +rosrun rviz rviz -d rospack find myCobotROS/config/mycobot.rviz +``` + -**Step 4**: Run python script a) For display From f2ee5426dee334425337ccd1930397a19545f628 Mon Sep 17 00:00:00 2001 From: Zachary Zhang Date: Mon, 4 Jan 2021 15:06:25 +0800 Subject: [PATCH 7/7] refactor(api): modify common.py --- scripts/pythonAPI/common.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/scripts/pythonAPI/common.py b/scripts/pythonAPI/common.py index 441f1c1..f9e7329 100755 --- a/scripts/pythonAPI/common.py +++ b/scripts/pythonAPI/common.py @@ -1,18 +1,18 @@ import enum class Angle(enum.Enum): - J1 = '00' - J2 = '01' - J3 = '02' - J4 = '03' - J5 = '04' - J6 = '05' + J1 = '01' + J2 = '02' + J3 = '03' + J4 = '04' + J5 = '05' + J6 = '06' class Coord(enum.Enum): - X = '00' - Y = '01' - Z = '02' - Rx = '03' - Ry = '04' - Rz = '05' \ No newline at end of file + X = '01' + Y = '02' + Z = '03' + Rx = '04' + Ry = '05' + Rz = '06'