add communicate pic

This commit is contained in:
13510421536
2022-07-26 18:01:02 +08:00
parent 4ecfcd4855
commit d113c04624
4 changed files with 18 additions and 9 deletions

9
.vscode/sftp.json vendored Normal file
View File

@@ -0,0 +1,9 @@
{
"name": "My Server",
"host": "localhost",
"protocol": "sftp",
"port": 22,
"username": "username",
"remotePath": "/",
"uploadOnSave": true
}

View File

@@ -137,9 +137,5 @@ rosrun moveit_tutorials state_note.py
**步骤3** 在move_group_python_interface_tutorial.py的端口按提示改变机械臂的状态并且实时地检测并且写入串口设备 **步骤3** 在move_group_python_interface_tutorial.py的端口按提示改变机械臂的状态并且实时地检测并且写入串口设备
```
chmod +x state_note.py
rosrun moveit_tutorials state_note.py
```
![](../figures/moveit.jpg) ![](../figures/joint_state.jpg)

View File

@@ -52,7 +52,7 @@ if __name__ == '__main__':
group_name = "panda_arm" group_name = "panda_arm"
move_group = moveit_commander.MoveGroupCommander(group_name) move_group = moveit_commander.MoveGroupCommander(group_name)
ser = serial.Serial('/dev/ttyAMA0', 3000000, 8, 'N', 1) # 'COM7', 3000000, bytesize=8, parity='N', stopbits=1 ser = serial.Serial('/dev/ttyAMA0', 3000000, 8, 'N', 1)
flag = ser.is_open flag = ser.is_open
if flag: if flag:
@@ -63,7 +63,7 @@ if __name__ == '__main__':
time_step = 0 time_step = 0
begin_time = datetime.datetime.now() begin_time = datetime.datetime.now()
one_step = 2 one_step = 2
while True: while True:
cur_time = (datetime.datetime.now() - begin_time).total_seconds() cur_time = (datetime.datetime.now() - begin_time).total_seconds()
if cur_time >= (time_step + one_step): if cur_time >= (time_step + one_step):
@@ -71,8 +71,12 @@ if __name__ == '__main__':
joint_goal = move_group.get_current_joint_values() joint_goal = move_group.get_current_joint_values()
print("joint:", joint_goal[0], joint_goal[1], joint_goal[2], joint_goal[3], joint_goal[4], joint_goal[5], joint_goal[6]) print("joint:", joint_goal[0], joint_goal[1], joint_goal[2], joint_goal[3], joint_goal[4], joint_goal[5], joint_goal[6])
ser.write("help".encode('utf-8')) # ser.write("help".encode('utf-8'))
print("ok?") joint_len = len(joint_goal)
for i in range(joint_len):
tmp_val = joint_goal[i]
str = '%.3f'%tmp_val
ser.write(str.encode('utf-8'))
if ISSIGINTUP: if ISSIGINTUP:
ser.close() ser.close()
print("Exit") print("Exit")

BIN
figures/joint_state.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 89 KiB