-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #125 from elephantrobotics/280-ros-pump-camera
280 ros pump camera
- Loading branch information
Showing
42 changed files
with
3,776 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<launch> | ||
<!-- Select connecting device and serial port ,选择连接设备及串口--> | ||
<arg name="port" default="/dev/ttyUSB0" /> | ||
<arg name="baud" default="115200" /> | ||
|
||
<arg name="model" default="$(find mycobot_description)/urdf/mycobot/mycobot_with_pump.urdf"/> | ||
<arg name="rvizconfig" default="$(find mycobot_280)/config/mycobot.rviz" /> | ||
<arg name="gui" default="false" /> | ||
|
||
<param name="robot_description" command="$(find xacro)/xacro --inorder $(arg model)" /> | ||
|
||
<!-- Combinejoin values to TF ,将值合并到TF--> | ||
<node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher" /> | ||
<!-- Show in Rviz ,显示在Rviz--> | ||
<node name="rviz" pkg="rviz" type="rviz" args="-d $(arg rvizconfig)" required="true" /> | ||
|
||
<include file="$(find mycobot_communication)/launch/communication_service.launch"> | ||
<arg name="port" value="$(arg port)" /> | ||
<arg name="baud" value="$(arg baud)" /> | ||
</include> | ||
<node name="real_listener" pkg="mycobot_280" type="listen_real.py" /> | ||
<node name="simple_gui" pkg="mycobot_280" type="simple_gui.py" /> | ||
</launch> |
25 changes: 25 additions & 0 deletions
25
mycobot_280/mycobot_280/launch/slider_control_camera_flange.launch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<launch> | ||
<!-- <arg name="port" default="/dev/ttyUSB0" /> | ||
<arg name="baud" default="115200" /> --> | ||
<!-- Load file model ,加载文件模型--> | ||
<arg name="model" default="$(find mycobot_description)/urdf/mycobot/mycobot_with_camera_flange.urdf"/> | ||
|
||
<arg name="rvizconfig" default="$(find mycobot_280)/config/mycobot.rviz" /> | ||
<arg name="gui" default="true" /> | ||
|
||
<param name="robot_description" command="$(find xacro)/xacro --inorder $(arg model)" /> | ||
|
||
<!-- Combinejoin values to TF,将值合并到TF --> | ||
<node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher" /> | ||
<node name="joint_state_publisher_gui" pkg="joint_state_publisher_gui" type="joint_state_publisher_gui"> | ||
<!-- <param name="use_gui" value="$(arg gui)" /> --> | ||
<!-- <rosparam param="source_list" subst_value="true">["joint_states"]</rosparam> --> | ||
</node> | ||
<!-- Open control script --> | ||
<!-- <node name="control_slider" pkg="mycobot_280" type="slider_control.py"> | ||
<param name="port" type="string" value="$(arg port)" /> | ||
<param name="baud" type="int" value="$(arg baud)" /> | ||
</node> --> | ||
<!-- Show in Rviz ,显示在Rviz--> | ||
<node name="rviz" pkg="rviz" type="rviz" args="-d $(arg rvizconfig)" required="true" /> | ||
</launch> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<launch> | ||
<!-- <arg name="port" default="/dev/ttyUSB0" /> | ||
<arg name="baud" default="115200" /> --> | ||
<!-- Load file model ,加载文件模型--> | ||
<arg name="model" default="$(find mycobot_description)/urdf/mycobot/mycobot_with_pump.urdf"/> | ||
<arg name="rvizconfig" default="$(find mycobot_280)/config/mycobot.rviz" /> | ||
<arg name="gui" default="true" /> | ||
|
||
<param name="robot_description" command="$(find xacro)/xacro --inorder $(arg model)" /> | ||
|
||
<!-- Combinejoin values to TF,将值合并到TF --> | ||
<node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher" /> | ||
<node name="joint_state_publisher_gui" pkg="joint_state_publisher_gui" type="joint_state_publisher_gui"> | ||
<!-- <param name="use_gui" value="$(arg gui)" /> --> | ||
<!-- <rosparam param="source_list" subst_value="true">["joint_states"]</rosparam> --> | ||
</node> | ||
<!-- Open control script --> | ||
<!-- <node name="control_slider" pkg="mycobot_280" type="slider_control.py"> | ||
<param name="port" type="string" value="$(arg port)" /> | ||
<param name="baud" type="int" value="$(arg baud)" /> | ||
</node> --> | ||
<!-- Show in Rviz ,显示在Rviz--> | ||
<node name="rviz" pkg="rviz" type="rviz" args="-d $(arg rvizconfig)" required="true" /> | ||
</launch> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
mycobot_280/mycobot_280/launch/teleop_keyboard_pump.launch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<launch> | ||
<!-- Select connecting device and serial port ,选择连接设备及串口--> | ||
<arg name="port" default="/dev/ttyUSB0" /> | ||
<arg name="baud" default="115200" /> | ||
|
||
<arg name="model" default="$(find mycobot_description)/urdf/mycobot/mycobot_with_pump.urdf"/> | ||
<arg name="rvizconfig" default="$(find mycobot_280)/config/mycobot.rviz" /> | ||
<arg name="gui" default="false" /> | ||
|
||
<param name="robot_description" command="$(find xacro)/xacro --inorder $(arg model)" /> | ||
|
||
<!-- Combinejoin values to TF ,将值合并到TF--> | ||
<node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher" /> | ||
<!-- Show in Rviz ,显示在Rviz--> | ||
<node name="rviz" pkg="rviz" type="rviz" args="-d $(arg rvizconfig)" required="true" /> | ||
|
||
<include file="$(find mycobot_communication)/launch/communication_service.launch"> | ||
<arg name="port" value="$(arg port)" /> | ||
<arg name="baud" value="$(arg baud)" /> | ||
</include> | ||
<!-- listen and pub the real angles ,监听并发布真实角度--> | ||
<node name="real_listener" pkg="mycobot_280" type="listen_real.py" /> | ||
</launch> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<launch> | ||
<!-- <arg name="port" default="/dev/ttyUSB0" /> | ||
<arg name="baud" default="115200" /> --> | ||
<!-- Load file model ,加载文件模型--> | ||
<arg name="model" default="$(find mycobot_description)/urdf/mycobot/mycobot_with_camera_flange.urdf"/> | ||
|
||
<arg name="rvizconfig" default="$(find mycobot_280)/config/mycobot.rviz" /> | ||
<arg name="gui" default="true" /> | ||
|
||
<param name="robot_description" command="$(find xacro)/xacro --inorder $(arg model)" /> | ||
|
||
<!-- Combinejoin values to TF,将值合并到TF --> | ||
<node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher" /> | ||
<node name="joint_state_publisher_gui" pkg="joint_state_publisher_gui" type="joint_state_publisher_gui"> | ||
<!-- <param name="use_gui" value="$(arg gui)" /> --> | ||
<!-- <rosparam param="source_list" subst_value="true">["joint_states"]</rosparam> --> | ||
</node> | ||
<!-- Open control script --> | ||
<!-- <node name="control_slider" pkg="mycobot_280" type="slider_control.py"> | ||
<param name="port" type="string" value="$(arg port)" /> | ||
<param name="baud" type="int" value="$(arg baud)" /> | ||
</node> --> | ||
<!-- Show in Rviz ,显示在Rviz--> | ||
<node name="rviz" pkg="rviz" type="rviz" args="-d $(arg rvizconfig)" required="true" /> | ||
</launch> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<launch> | ||
<arg name="model" default="$(find mycobot_description)/urdf/mycobot/mycobot_with_gripper_parallel.urdf"/> | ||
<arg name="rvizconfig" default="$(find mycobot_280)/config/mycobot.rviz" /> | ||
<arg name="gui" default="true" /> | ||
|
||
<param name="robot_description" command="$(find xacro)/xacro --inorder $(arg model)" /> | ||
|
||
<!-- Combinejoin values to TF --> | ||
<node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher" /> | ||
<node name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher"> | ||
<param name="use_gui" value="$(arg gui)" /> | ||
<!-- <rosparam param="source_list" subst_value="true">["joint_states"]</rosparam> --> | ||
</node> | ||
<!-- Show in Rviz ,显示在Rviz--> | ||
<node name="rviz" pkg="rviz" type="rviz" args="-d $(arg rvizconfig)" required="true" /> | ||
</launch> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<launch> | ||
<!-- <arg name="port" default="/dev/ttyUSB0" /> | ||
<arg name="baud" default="115200" /> --> | ||
<!-- Load file model ,加载文件模型--> | ||
<arg name="model" default="$(find mycobot_description)/urdf/mycobot/mycobot_with_pump.urdf"/> | ||
|
||
<arg name="rvizconfig" default="$(find mycobot_280)/config/mycobot.rviz" /> | ||
<arg name="gui" default="true" /> | ||
|
||
<param name="robot_description" command="$(find xacro)/xacro --inorder $(arg model)" /> | ||
|
||
<!-- Combinejoin values to TF,将值合并到TF --> | ||
<node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher" /> | ||
<node name="joint_state_publisher_gui" pkg="joint_state_publisher_gui" type="joint_state_publisher_gui"> | ||
<!-- <param name="use_gui" value="$(arg gui)" /> --> | ||
<!-- <rosparam param="source_list" subst_value="true">["joint_states"]</rosparam> --> | ||
</node> | ||
<!-- Open control script --> | ||
<!-- <node name="control_slider" pkg="mycobot_280" type="slider_control.py"> | ||
<param name="port" type="string" value="$(arg port)" /> | ||
<param name="baud" type="int" value="$(arg baud)" /> | ||
</node> --> | ||
<!-- Show in Rviz ,显示在Rviz--> | ||
<node name="rviz" pkg="rviz" type="rviz" args="-d $(arg rvizconfig)" required="true" /> | ||
</launch> |
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
#!/usr/bin/env python3 | ||
# encoding:utf-8 | ||
# license removed for brevity | ||
from distutils.log import error | ||
import time | ||
import math | ||
import os | ||
import fcntl | ||
|
||
import rospy | ||
from sensor_msgs.msg import JointState | ||
from std_msgs.msg import Header | ||
from mycobot_communication.srv import GetAngles | ||
from pymycobot.mycobot import MyCobot | ||
from rospy import ServiceException | ||
|
||
mc = None | ||
|
||
# Avoid serial port conflicts and need to be locked | ||
def acquire(lock_file): | ||
open_mode = os.O_RDWR | os.O_CREAT | os.O_TRUNC | ||
fd = os.open(lock_file, open_mode) | ||
|
||
pid = os.getpid() | ||
lock_file_fd = None | ||
|
||
timeout = 50.0 | ||
start_time = current_time = time.time() | ||
while current_time < start_time + timeout: | ||
try: | ||
# The LOCK_EX means that only one process can hold the lock | ||
# The LOCK_NB means that the fcntl.flock() is not blocking | ||
# and we are able to implement termination of while loop, | ||
# when timeout is reached. | ||
fcntl.flock(fd, fcntl.LOCK_EX | fcntl.LOCK_NB) | ||
except (IOError, OSError): | ||
pass | ||
else: | ||
lock_file_fd = fd | ||
break | ||
|
||
# print('pid waiting for lock:%d'% pid) | ||
|
||
|
||
time.sleep(1.0) | ||
current_time = time.time() | ||
if lock_file_fd is None: | ||
os.close(fd) | ||
return lock_file_fd | ||
|
||
|
||
def release(lock_file_fd): | ||
# Do not remove the lockfile: | ||
fcntl.flock(lock_file_fd, fcntl.LOCK_UN) | ||
os.close(lock_file_fd) | ||
return None | ||
|
||
def talker(): | ||
rospy.loginfo("start ...") | ||
|
||
rospy.init_node("real_listener_gripper", anonymous=True) | ||
pub = rospy.Publisher("joint_states", JointState, queue_size=10) | ||
port = rospy.get_param("~port", "/dev/ttyUSB0") | ||
baud = rospy.get_param("~baud", 115200) | ||
mc = MyCobot(port, baud) | ||
rate = rospy.Rate(30) # 30hz | ||
|
||
# pub joint state,发布关节状态 | ||
joint_state_send = JointState() | ||
joint_state_send.header = Header() | ||
|
||
joint_state_send.name = [ | ||
"joint2_to_joint1", | ||
"joint3_to_joint2", | ||
"joint4_to_joint3", | ||
"joint5_to_joint4", | ||
"joint6_to_joint5", | ||
"joint6output_to_joint6", | ||
"gripper_controller", | ||
] | ||
joint_state_send.velocity = [0] | ||
joint_state_send.effort = [] | ||
|
||
# waiting util server `get_joint_angles` enable.等待'get_joint_angles'服务启用 | ||
rospy.loginfo("wait service") | ||
rospy.wait_for_service("get_joint_angles") | ||
|
||
while True: | ||
try: | ||
func = rospy.ServiceProxy("get_joint_angles", GetAngles) | ||
break | ||
except ServiceException as e: | ||
# pass | ||
# print(f'error:{e}') | ||
print("--------------error",e) | ||
|
||
# rospy.loginfo("start loop ...") | ||
while not rospy.is_shutdown(): | ||
# get real angles from server.从服务器获得真实的角度。 | ||
res = func() | ||
if res.joint_1 == res.joint_2 == res.joint_3 == 0.0: | ||
continue | ||
if mc: | ||
lock = acquire("/tmp/mycobot_lock") | ||
gripper_value = mc.get_gripper_value() | ||
release(lock) | ||
if gripper_value != -1: | ||
gripper_value = -0.78 + round(gripper_value / 117.0, 2) | ||
# print(gripper_value) | ||
radians_list = [ | ||
res.joint_1 * (math.pi / 180), | ||
res.joint_2 * (math.pi / 180), | ||
res.joint_3 * (math.pi / 180), | ||
res.joint_4 * (math.pi / 180), | ||
res.joint_5 * (math.pi / 180), | ||
res.joint_6 * (math.pi / 180), | ||
] | ||
radians_list.append(gripper_value) | ||
# rospy.loginfo("res: {}".format(radians_list)) | ||
|
||
# publish angles.发布角度 | ||
joint_state_send.header.stamp = rospy.Time.now() | ||
joint_state_send.position = radians_list | ||
pub.publish(joint_state_send) | ||
rate.sleep() | ||
|
||
|
||
if __name__ == "__main__": | ||
try: | ||
talker() | ||
except rospy.ROSInterruptException: | ||
pass |
Oops, something went wrong.