Forums Niryo One Programming Niryo One Programming with ROS

Viewing 15 posts - 1 through 15 (of 17 total)
  • Author
    Posts
  • Anthony
    Participant
    Post count: 10

    Hi! I’m an engineering student! I just got my Niryo One and want to program it with ROS.

    Now I have some basic questions to start programming my Niryo.
    I wanted to make some simple movements with the robotic arm directly by ROS programming (without Nyrio Studio).

    From the developer tutorial, I got this : “The commander package exposes an action server named “niryo_one/commander/robot_action”, with a “RobotMoveCommand” message. This is probably what you’re looking for if you want to send direct command to the robot using ROS.”

    I want exactly send direct command in order to move the robotic arm, so this information was perfect! But I still don’t understand how to begin with this complex architecture.

    Set up environment :
    Question 1 : I was doing the courses on Ubuntu (virtual box) and implement some tests on a Raspberry Pi (screen, mouse, keyboard). But How to program Niryo with out screen? Via SSH? But ssh don’t provide multiple terminals (roscore, server, client, publisher, subscriber…).

    Simple move with the robot:
    Question 2: In order to make the robot move, should I create a node “robot_action_client” that send goals through “RobotMoveCommand”?

    I analysed the “action” definition :
    ————————————————————————————————–
    # goal
    niryo_one_msgs/RobotMoveCommand cmd

    # result
    int32 status
    string message

    # feedback
    niryo_one_msgs/RobotState state
    ————————————————————————————————–

    Indeed there is a RobotMoveCommand message (goal), but this message is composed by many messages as well :
    ————————————————————————————————–
    int32 cmd_type

    float64[] joints
    geometry_msgs/Point position
    niryo_one_msgs/RPY rpy
    niryo_one_msgs/ShiftPose shift
    niryo_one_msgs/TrajectoryPlan Trajectory
    geometry_msgs/Pose pose_quat
    string saved_position_name
    int32 saved_trajectory_id

    niryo_one_msgs/ToolCommand tool_cmd
    ————————————————————————————————–

    In the case I want to send a goal, how to define properly a goal with so many crossed message :
    ————————————————————————————————–
    import rospy
    import actionlib

    from my_robot_msgs.msg import RobotMoveAction
    from my_robot_msgs.msg import RobotMoveGoal

    Class Send_Command :
    def __init__(self) :
    self._ac = actionlib.ActionClient(‘/robot_action’, RobotMoveAction)
    self._ac.wait_for_server()
    rospy.loginfo (“Action server up, we can send goals.”)

    def send_goal (self, cmd_type, joints, #? How to manage messages of messages?
    goal = RobotMoveGoal()
    goal.cmd_type = #? how to find documentation on cmd types?
    goal.joints
    … #Lost

    Thanks for responding! I can’t wait to learn more and make it move!

    Edouard Renard
    Keymaster
    Post count: 234

    Hi Anthony,

    For your question1: you can have multiple terminals with ssh. What you have to do is to open multiple terminals on your own computer, and from each, start an ssh connection.

    Question2: Yes exactly.

    To start with this Goal message, I recommend you do the following in this order:

    1. Use the Niryo One Python API, especially the “move” commands.

    2. Once you know how to use it, check out the code inside the Python API, to understand how the move_joint command works with the Action client

    3. And now you can start your own node.

    There is an alternative method. If you want to directly control the arm movement, instead of going through the ROS Action, you can bypass that and use the Moveit! MoveGroup functionality. Check out this part of the code where we use the MoveGroup, and also check this MoveGroupCommander tutorial to know more about it.

    Anthony
    Participant
    Post count: 10

    Thanks! I will follow those steps.

    Once I created my python file “test_python_api.py” using the Python API (located in niryo_one_python_api/examples/) with rpi_example_python_api.py.
    touch test_python_api.py
    chmod +x test_python_api.py
    vim test_python_api.py

    Create my code using Python API

    Can I use it by typing : “python test_python_api.py” in my ssh terminal to make the robot move? or should I do other setting or launch other nodes as well?

    Edouard Renard
    Keymaster
    Post count: 234

    Provided that you follow the code template given in the Python API documentation, you can just run “python your_script.py”, on the Raspberry Pi, to execute it.

    Note that you can also remotely start your script, following this tutorial.

    Anthony
    Participant
    Post count: 10

    Hi!

    Thanks for the advice, I programmed sequences with the Python API and indeed it’s really fast to learn and use the classes.
    I would like to interact with Niryo. When using the API classes, it is possible to stop the running movement in the middle of the run? or I should go through action programming?

    Which software are you using to program Niryo by coding?
    I’m using Putty right now for the ssh connection, but the interface is limited. I think personally Putty’s interface is very bad for coding nodes, and so on.

    Edouard Renard
    Keymaster
    Post count: 234

    Yes you can stop the current move command:

    – either you used the Moveit interface directly and you can use the arm.stop() function

    – or you used an Action Client and you can use the cancel functionality of actions

    – or simply call the “niryo_one/commander/stop_command” service

    To program on Niryo One I mainly use Vim (on the robot) and Visual Studio Code (on desktop with simulation mode, for non-hardware related parts)

    Putty is nice to do basic stuff, but I really recommend you install Ubuntu (18.04 as for now) if you want to get serious with programming with ROS. Also on Ubuntu you have a real ssh not like on Windows

    carlos_niryo
    Participant
    Post count: 11

    Hi , I am trying to launch ROS server with :
    # roslaunch niryo_one_bringup rpi_setup.launch

    but I have received this msg:
    [WARN] [1518033467.095868]: Unable to start server: [Errno 98] Address already in use Retrying in 5s.
    [WARN] [1518033472.104209]: Unable to start server: [Errno 98] Address already in use Retrying in 5s.

    Some can help me ?? thanks in advance

    Edouard Renard
    Keymaster
    Post count: 234

    Did you launch that on the Raspberry Pi board ? (via ssh) And did you make sure you first killed the previously running ROS stack ? (sudo systemctl stop niryo_one_ros.service)

    carlos_niryo
    Participant
    Post count: 11

    Thanks Edouard Renard, it is working now.

    carlos_niryo
    Participant
    Post count: 11

    I am working on printing the niryo_one stl files and buying the electrônis I could find here in Brazil.
    I need to buy from you the raspberry shield, cables and the stppers nema 17 control board.
    How can place this order?

    Edouard Renard
    Keymaster
    Post count: 234

    Unfortunately we don’t offer to pick and buy some electronics parts. The main reason is for production/inventory/suppliers management.

    However, we can provide you with a Maker Kit, including all Niryo-custom parts at once, and you can buy the other stuff + 3D print the robot by yourself.

    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()

    Anthony
    Participant
    Post count: 10

    After I simplified to the minimum my code by deleting all about “server”, the robot made few loops and became crazy.

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

    niryo@niryo-pc:~/catkin_ws/src/niryo_one_python_api/src$ python test_robot_move.py
    [INFO] [1560496637.415949]: Node has been lauched
    [INFO] [1560496645.428404]: ——————Loop
    [INFO] [1560496687.400143]: ——————Loop
    [INFO] [1560496729.343841]: ——————Loop
    [INFO] [1560496771.394603]: ——————Loop
    [INFO] [1560496813.320727]: ——————Loop
    [INFO] [1560496855.763754]: ——————Loop
    [INFO] [1560496898.003868]: ——————Loop
    [INFO] [1560496940.173920]: ——————Loop
    [INFO] [1560496982.338973]: ——————Loop
    [INFO] [1560497024.424586]: ——————Loop
    [INFO] [1560497066.754919]: ——————Loop
    [INFO] [1560497108.746656]: ——————Loop
    [INFO] [1560497150.824193]: ——————Loop
    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 : Command has been aborted

    Betegustaf
    Participant
    Post count: 16

    Hi Anthony I’m not sure about this but the problem may not come from the server you are coding..
    Check this topic wich describes well the errors that can appear : https://niryo.com/forums/topic/sequence-autorun-arbitrarily-stops-no-trajectory-defined-at-current-time/
    I had a lot of problems too with running sequences of move pose/joints but Niryo team said they are working on it so we might have a solution soon !

    Edouard Renard
    Keymaster
    Post count: 234

    Yes that’s a known issue (great observation @betegustaf), which we will fixed soon. I can’t really be more precise because this fix requires a lot of work, which is hard to estimate exactly.

Viewing 15 posts - 1 through 15 (of 17 total)

You must be logged in to reply to this topic.