Report crashes, strange behaviour, or apparent bugs
slgrajeshwar36172
Posts: 4
Joined: 06 Nov 2019, 04:34
Location: iit patna
Contact:

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.
Thank you

coppelia
Posts: 7584
Joined: 14 Dec 2012, 00:25

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

slgrajeshwar36172
Posts: 4
Joined: 06 Nov 2019, 04:34
Location: iit patna
Contact:

coppelia wrote:
11 Nov 2019, 07:08
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
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.

coppelia
Posts: 7584
Joined: 14 Dec 2012, 00:25

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

fferri
Posts: 464
Joined: 09 Sep 2013, 19:28

I tested sim.setJointPosition and it works fine also in a ROS callback.