Forums Niryo One Programming Niryo One Programming with ROS Reply To: Programming with ROS

Anthony
Participant
Post count: 10

Hi Edouard! I’m still working on my code using Python API.
I implemented a simple move in a loop and a server in order to receive few request.
I think my code is very simple, but after few loop, action is aborted and the robot stops.

I can not figure out what is wrong in my code or why this error appears.

*******************************************************************************************************
Errors received :

Traceback (most recent call last):
File “test_robot_move.py”, line 80, in <module>
process_1()
File “test_robot_move.py”, line 54, in process_1
n.move_joints([-0.62, -0.48, -0.19, -0.86, 0.85, 0.61])
File “/home/niryo/catkin_ws/src/niryo_one_python_api/src/niryo_one_python_api/niryo_one_api.py”, line 281, in move_joints
return self.execute_action(‘niryo_one/commander/robot_action’, RobotMoveAction, goal)
File “/home/niryo/catkin_ws/src/niryo_one_python_api/src/niryo_one_python_api/niryo_one_api.py”, line 191, in execute_action
raise NiryoOneException(‘Goal has been aborted : ‘ + str(response.message))
niryo_one_python_api.niryo_one_api.NiryoOneException: Goal has been aborted : Trajectory timeout – Try to restart the robot

Traceback (most recent call last):
File “test_robot_move.py”, line 80, in <module>
process_1()
File “test_robot_move.py”, line 46, in process_1
n.move_pose( 0.24, 0, 0.42, 0, 0, 0)
File “/home/niryo/catkin_ws/src/niryo_one_python_api/src/niryo_one_python_api/niryo_one_api.py”, line 275, in move_pose
return self.execute_action(‘niryo_one/commander/robot_action’, RobotMoveAction, goal)
File “/home/niryo/catkin_ws/src/niryo_one_python_api/src/niryo_one_python_api/niryo_one_api.py”, line 191, in execute_action
raise NiryoOneException(‘Goal has been aborted : ‘ + str(response.message))
niryo_one_python_api.niryo_one_api.NiryoOneException: Goal has been aborted : Trajectory timeout – Try to restart the robot

********************************************************************************************************
Code :

from niryo_one_python_api.niryo_one_api import *
import rospy
from niryo_one_msgs.srv import SendCommand
#bool data
#—
#bool success
#string message

request0 = False
request1 = False
t = 2
arm_velocity = 25

def callback_niryo_control(req):
process_nb = req.process
#Variable
####################################
global request0
global request1
rospy.loginfo (‘>>>>Resquest received’)
rospy.loginfo (process_nb)
######################################
if process_nb == 0:
request0 = True
request1 = False
return True,”Request0 is launched”
#######################################
if process_nb == 1:
request0 = False
request1 = True
return True,”Request1 is launched”
########################################
else:
return False, “Command failed”

def calibrate():
n.calibrate_auto()
n.change_tool(TOOL_GRIPPER_2_ID)
n.set_arm_max_velocity(arm_velocity)
n.move_pose( 0.24, 0, 0.42, 0, 0, 0)
n.open_gripper(TOOL_GRIPPER_2_ID, 100)

def process_1():
n.move_pose( 0.24, 0, 0.42, 0, 0, 0)
n.wait(t)
n.move_joints([0, -0.88, -0.48, 0, 1.35, -0.06])
n.wait(t)
n.close_gripper(TOOL_GRIPPER_2_ID,1000)
n.wait(t)
n.move_joints([0, -0.26, -0.49, 0, 0.73, -0.04])
n.wait(t)
n.move_joints([-0.62, -0.48, -0.19, -0.86, 0.85, 0.61])
n.wait(t)
n.move_joints([-0.62, -0.55, -0.22, -0.81, 0.93, 0.52])
n.wait(t)
n.open_gripper(TOOL_GRIPPER_2_ID,100)
n.wait(t)
n.move_joints([-0.89, -0.27, -0.64, -1, 1.13, 0.52])
n.wait(t)
n.move_pose( 0.24, 0, 0.42, 0, 0, 0)

if __name__ == ‘__main__’:
rospy.init_node(‘niryo_one_run_python_api_code’)
rospy.loginfo (‘Node has been lauched’)
service = rospy.Service(“/Send_command”,SendCommand,callback_niryo_control )
rospy.loginfo (‘Service has been lauched’)
n = NiryoOne()
rate = rospy.Rate(10)

calibrate()

while not rospy.is_shutdown():
rospy.loginfo (‘——————Loop’)
rospy.loginfo (‘request0 =’)
rospy.loginfo (str(request0))
rospy.loginfo (‘request1 =’)
rospy.loginfo (str(request1))
process_1()

if (request0 == True and request1 ==False):
rospy.loginfo (‘>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Request 0 activated’)
request0 = False

if (request0 == False and request1 ==True):
rospy.loginfo (‘>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Request 1 activated’)
request1 = False

n.wait(5)

rospy.spin()