Page 1 of 1
sim.setJointPosition is not working inside the callback function of subscriber in ROS.Please help me
Posted: 11 Nov 2019, 06:14
by slgrajeshwar36172
Code: Select all
function sysCall_init()
-- Get some handles:
joint=sim.getObjectHandle('Joint')
-- Enable an image publisher and subscriber:
sub=simROS.subscribe('/joint_topic', 'std_msgs/Float64', 'joint_callback')
simROS.subscriberTreatUInt8ArrayAsString(sub) -- treat uint8 arrays as strings (much faster, tables/arrays are kind of slow in Lua)
end
function joint_callback(msg)
-- Apply the received image to the passive vision sensor that acts as an image container
print(msg.data)
--sim.setJointTargetVelocity(joint,msg.data)
sim.setJointPosition(joint,(math.pi/180) *msg.data)
end
function sysCall_cleanup()
simROS.shutdownSubscriber(sub)
end
sim.setJointPosition is not working inside the call back function but interesting thing is that sim.setJointTargetVelocity is working properly.
please help me
Thank you
Re: sim.setJointPosition is not working inside the callback function of subscriber in ROS.Please help me
Posted: 11 Nov 2019, 07:08
by coppelia
Hello,
first, you do not need
simROS.subscriberTreatUInt8ArrayAsString
for that subscriber.
second, what do you mean with
it is not working? Is there a message error? What is the behaviour? Of course, if your joint is in force/torque mode with position control enabled, then you can't use
sim.setJointPosition
. You'll have to use
sim.setJointTargetPosition
.
Cheers
Re: sim.setJointPosition is not working inside the callback function of subscriber in ROS.Please help me
Posted: 11 Nov 2019, 10:14
by slgrajeshwar36172
it is not working means
whenever i publish 60 to the topic it joint should move to 60 degree due to the command sim.setJointPosition but joint is not moving at all. Same problem is facing while using the sim.setJointTargetPosition and my joint is in force/torque mode with position control enabled. there is no error msg during the execution.
how can i use sim.setJointPosition in callback function???
sir i have used sim.setJointPosition in sysCall_actuation and it is working means it is going to desired position in force/torque mode with position control enabled.
Re: sim.setJointPosition is not working inside the callback function of subscriber in ROS.Please help me
Posted: 12 Nov 2019, 14:23
by coppelia
Not sure what is going on. Are you using a non-threaded child script? Is the message arriving in the callback? (simply insert a print to check that)
Cheers
Re: sim.setJointPosition is not working inside the callback function of subscriber in ROS.Please help me
Posted: 12 Nov 2019, 18:25
by fferri
I tested
sim.setJointPosition
and it works fine also in a ROS callback.
If your joint doesn't move, you have research the cause in the joint mode and the resulting behaviour. Make sure to read and understand
Joint types and operation.