ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Continuous robot arm movement

asked 2018-06-04 16:14:03 -0500

Kashyap.m94 gravatar image

Unlike edge triggered here ,I am now trying to move the arm continuously till the buttons are continuously pressed and must stop moving once the user stops pressing it, but as soon as I launch the code I wrote, the messages 0.0 start publishing and the commands that I give takes a while to be executed as they are stored in the buffer. The code is

def callback(data, group1):
    global j1, a

    if ((data.buttons[0]==1) and (data.axes[6]==1)):
         a += 1
    print 'a = %s' %a
    j1 = (int(a/5))*0.1
    print j1
    if (j1 >= 3.1): 
        group1_variable_values[0] = 3.1
        print "Limit reached joint 1"
    else:
        print "changing joint 1"
        group1_variable_values[0] = j1
        group1.set_joint_value_target(group1_variable_values)
        plan2 = group1.plan()
        execute2= group1.execute(plan2)
        print "plan complete"

Screenshot of the code: Screenshot

edit retag flag offensive close merge delete

Comments

@PeteBlackerThe3rd hey, as suggested by you, I have created a new question here

Kashyap.m94 gravatar image Kashyap.m94  ( 2018-06-04 16:15:00 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted
0

answered 2018-06-12 16:59:27 -0500

Kashyap.m94 gravatar image

updated 2018-06-13 04:40:29 -0500

Well, the continuous movement I wanted, was achieved. There were some changes to be done in the code and it was accomplished

The Code that worked

if ((data.buttons[0]==1) and (data.axes[6]==1)):
        a += 1
        print 'a = %s' %a
        if (a%30 == 0):
            if ((data.buttons[0]==1) and (data.axes[6]==1)):
                j1 = j1+0.1
                if (j1 >= 3.1): 
                    group1_variable_values[0] = 3.1
                    print "Limit reached joint 1"
                    print "Value of Joint 1 is: 3.1"
                else:
                    print "changing joint 1"
                    print "Value of Joint 1 is: %s " %j1
                    print "plan complete"
                    group1_variable_values[0] = j1
                    group1.set_joint_value_target(group1_variable_values)
                    plan2 = group1.plan()
                    execute2= group1.execute(plan2)
edit flag offensive delete link more

Comments

What changes in the code?

jayess gravatar image jayess  ( 2018-06-12 19:46:29 -0500 )edit

@jayess I have posted the new code

Kashyap.m94 gravatar image Kashyap.m94  ( 2018-06-13 04:41:01 -0500 )edit
0

answered 2018-06-05 06:20:12 -0500

You'll need to completely change the way you're commanding the robot arm to create smooth motion. At the moment you're planing then executing discrete paths to move from one step at the time, so the arm movement will be rough and jerky. You want to directly control the velocity of the joints of the robot instead.

The moveit interface that can control this as far as I know is only available in the C++ API, so I don't know if you'll be able to do this in python. Someone more knowledgeable about moveit may correct me here. If you're familiar with C++ then this will be an option for you.

You control the velocity of the arms joints using the moveit::core::RobotState object. The setJointVelocies method to can be used to set the velocity of a particular joint as shown below:

JointModel *joint = myRobotState.getJointModel("<joint name>");
double jointVelocity = 0.1; // velocity in radians per second
myRobotState.setJointVelocities(joint, &jointVelocity);

Using these methods you'd set a positive velocity if butons[0] and axes[6] are 1 and a zero velocity if they're not, this will produce the behaviour you want. I appreciate this will involve a large reworking of your code though.

edit flag offensive delete link more

Comments

1

The jog_arm package that I've recommended in an earlier question by the OP implements exactly this (ie: smooth jogging using inverse jacobians if I'm not mistaken).

@PeteBlackerThe3rd: what you show will not result in any motion, and the output of MoveIt is typically a JointTrajectory. Those ..

gvdhoorn gravatar image gvdhoorn  ( 2018-06-05 06:27:52 -0500 )edit

.. are position based. Afaik, there is no velocity control interface available here.

gvdhoorn gravatar image gvdhoorn  ( 2018-06-05 06:28:17 -0500 )edit

I stand corrected! The jog_arm package looks very useful, can it be used to directly control joint angles instead of controlling end effector velocities?

PeteBlackerThe3rd gravatar image PeteBlackerThe3rd  ( 2018-06-05 06:48:24 -0500 )edit
1

@gvdhoorn is correct, as usual. jog_arm can't control joint angles right now, but that's been requested, so I should probably add it.

AndyZe gravatar image AndyZe  ( 2018-06-05 08:43:21 -0500 )edit

@gvdhoorn correct me if I am wrong, for applying `jog_arm, I need the drivers of the arm I am controlling? If yes, are the drivers also needed just for simulation purpose?

Kashyap.m94 gravatar image Kashyap.m94  ( 2018-06-09 04:22:55 -0500 )edit

If you don't have drivers, how would you control the (real) robot at all?

re: simulation: no, there I would probably use gazebo_ros_control.

gvdhoorn gravatar image gvdhoorn  ( 2018-06-09 07:15:35 -0500 )edit

@gvdhoorn right now my focus is just the simulation of the bot. That's why I wanted to be sure. I shall look up gazebo_ros_control. Thanks

Kashyap.m94 gravatar image Kashyap.m94  ( 2018-06-09 07:32:46 -0500 )edit

Yep. If you want to do jog_arm in simulation, get Gazebo working. Here's a Gazebo simulation pkg that works on Kinetic, in case you just want to try it now: https://github.com/UTNuclearRobotics/...

AndyZe gravatar image AndyZe  ( 2018-06-09 08:49:10 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2018-06-04 16:14:03 -0500

Seen: 903 times

Last updated: Jun 13 '18