Hello everyone, is there anyone who has experience with the ros_tcp_endpoint repository version 0.7.0? I want to use it to create Digital Twin for a UR10e arm with ROS2 Humble in Unity to use for my bachelor project. I am new to ROS and could really need some guidance.
So far I have created a URDFfile, setup Unity following the pick and place tutorial in the Unity Robotics Hub using the ros2update branch. I did not clone the project just added some separate components of the project to my workspace (adjusted messages/services, SourceDestinationpublisher).
I am currently stuck at part 2 of the tutorial where I have to launch the server_endpoint.py script. I rewrote the core components of the part_2 launcher as follows
the launch description:
from launch import LaunchDescription
from launch_ros.actions import Node
[code=Python]def generate_launch_description():
ld = LaunchDescription()
server_endpoint = Node(
package="ur10e_moveit",
executable="server_endpoint.py",
name='server_endpoint',
arguments="--wait",
output="screen",
respawn=True
)
trajectory_subscriber = Node(
package="ur10e_moveit",
executable="trajectory_subscriber.py",
name='trajectory_subscriber',
arguments="--wait",
output="screen",
)
ld.add_action(server_endpoint)
ld.add_action(trajectory_subscriber)
return ld
My server_endpoint script:
#!/usr/bin/env python3
import rclpy
from rclpy.node import Node
from ros_tcp_endpoint import TcpServer
from ur10e_interfaces.msg import UR10eMoveitJoints, UR10eTrajectory
from ur10e_interfaces.srv import MoverService
from moveit_msgs.msg import RobotState
class ParamNode(Node):
def __init__(self):
super().__init__('TCPServer')
self.declare_parameter("/TCP_NODE_NAME",'TCPServer')
def main(args=None):
rclpy.init(args=args)
node = ParamNode()
# Create a TcpServer instance
tcp_server = TcpServer(node.get_parameter('/TCP_NODE_NAME').get_parameter_value().string_value)
# Start the Server Endpoint with a ROS communication objects dictionary for routing messages
tcp_server.start({
'SourceDestination_input': tcp_server.create_publisher(UR10eMoveitJoints,'SourceDestination_input',10),
'UR10eTrajectory': tcp_server.create_subscription(UR10eTrajectory,'UR10eTrajectory',tcp_server,10),
'ur10e_moveit': tcp_server.create_service(MoverService,'ur10e_moveit', tcp_server),
'RobotState': tcp_server.create_subscription(RobotState,'RobotState', tcp_server, 10)
})
try:
rclpy.spin(node)
except KeyboardInterrupt:
print(f'{node} stopped cleanly')
finally:
node.destroy_node()
rclpy.shutdown()
if __name__ == "__main__":
main()
and trajectory_subscriber script:
#!/usr/bin/env python3
"""
Subscribes to SourceDestination topic.
Uses MoveIt to compute a trajectory from the target to the destination.
Trajectory is then published to PickAndPlaceTrajectory topic.
"""
import rclpy
from rclpy.node import Node
from std_msgs.msg import String
from ur10e_interfaces.msg import UR10eMoveitJoints, UR10eTrajectory
from moveit_msgs.msg import RobotTrajectory
class Trajectory_Subscriber(Node):
def __init__(self):
super().__init__("trajectory_subscriber")
self.subscription = self.create_subscription(
String,
'SourceDestination_input',
UR10eMoveitJoints,
self.callback,
10
)
self.subscription # prevent unused variable warning
def callback(self, data):
self.get_logger().info("I heard:\n%s", data)
def main(args=None):
rclpy.init(args=args)
node = Trajectory_Subscriber()
subscription = node
# spin() simply keeps python from exiting until this node is stopped
rclpy.spin(node)
rclpy.shutdown()
if __name__ == '__main__':
main()
I would appreciate it if anyone could help me!