#! /usr/bin/env python
import rospkg
import rospy
# Import the service message used by the service /gazebo/delete_model
from iri_wam_reproduce_trajectory.srv import ExecTraj, ExecTrajRequest
# Initialise a ROS node with the name service_client
rospy.init_node('service_execute_trajectory_client')
# Wait for the service client /gazebo/delete_model to be running
rospy.wait_for_service('/execute_trajectory')
# Create the connection to the service
traj_request_client= rospy.ServiceProxy('/execute_trajectory', ExecTraj)
# Create an object of type DeleteModelRequest
rospack = rospkg.RosPack()
# This rospack.get_path() works in the same way as $(find name_of_package) in the launch files.
traj = rospack.get_path('iri_wam_reproduce_trajectory') + "/config/get_food.txt"
traj_request_obj = ExecTrajRequest()
traj_request_obj.file = traj_file_path
# Send through the connection the name of the object to be deleted by the service
result = execute_trajectory_service_client(traj_request_obj)
# Print the result given by the service called
print result
Hi @jimohafeezco,
when I open the content you pasted here with vi, I see that the third line is <200b>import rospkg
Could you copy the content I’m pasting here in your file and try executing it again? Or you could just remove the line import rospkg and type it again.
Here is the content without that special char:
#! /usr/bin/env python
import rospkg
import rospy
# Import the service message used by the service /gazebo/delete_model
from iri_wam_reproduce_trajectory.srv import ExecTraj, ExecTrajRequest
# Initialise a ROS node with the name service_client
rospy.init_node('service_execute_trajectory_client')
# Wait for the service client /gazebo/delete_model to be running
rospy.wait_for_service('/execute_trajectory')
# Create the connection to the service
traj_request_client= rospy.ServiceProxy('/execute_trajectory', ExecTraj)
# Create an object of type DeleteModelRequest
rospack = rospkg.RosPack()
# This rospack.get_path() works in the same way as $(find name_of_package) in the launch files.
traj = rospack.get_path('iri_wam_reproduce_trajectory') + "/config/get_food.txt"
traj_request_obj = ExecTrajRequest()
traj_request_obj.file = traj_file_path
# Send through the connection the name of the object to be deleted by the service
result = execute_trajectory_service_client(traj_request_obj)
# Print the result given by the service called
print result