Publish a single joint_state ROS topic for a set of selected joints

Typically: "How do I... ", "How can I... " questions
Post Reply
DavBuss
Posts: 5
Joined: 07 Dec 2018, 13:57

Publish a single joint_state ROS topic for a set of selected joints

Post by DavBuss » 19 Feb 2019, 10:57

Hi everyone!

I would like to publish a single joint_state ROS topic for a set of selected joints, i.e. have vrep publish a single topic which accounts for the joint states of all the joints which are part of a selected set of joints within the scene (not all the joints of the scene).

I manage :
1) to publish one joint_state per joint taken individually,
2) to publish the joint_state of all the joints in the scene

Here are my code samples (within the initialization part of a non-threaded child script):
1)

Code: Select all

local UR5_joint1 = simGetObjectHandle('UR5_joint1')
local UR5_joint2 = simGetObjectHandle('UR5_joint2')

simExtROS_enablePublisher("/vrep/out/state/actual/armJoint1", 1, simros_strmcmd_get_joint_state, UR5_joint1, -1, "")
simExtROS_enablePublisher("/vrep/out/state/actual/armJoint2", 1, simros_strmcmd_get_joint_state, UR5_joint2, -1, "")
2)

Code: Select all

simExtROS_enablePublisher("/vrep/out/state/actual/allJoints", 1, simros_strmcmd_get_joint_state, sim_handle_all, -1, "")
I've tried to use simGetObjectsInTree, hoping it would create a single handle to a set of joints (analog to sim_handle_all), but it seems to create a table which is not an acceptable argument of simExtROS_enablePublisher.

Code: Select all

local UR5_joint1 = simGetObjectHandle('UR5_joint1')
local UR5_joints = simGetObjectsInTree(UR5_joint1, sim_object_joint_type)

-- line below creates an error
simExtROS_enablePublisher("/vrep/out/state/actual/armJoints", 1, simros_strmcmd_get_joint_state, UR5_joints, -1, "")
In analogy to sim_handle_all, I wonder if it is possible in vrep to generate, within a script, a handle which refers to all the handles contained in a table of handles.

I'd be really grateful if you could help me on this :)!

Cheers,
David

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

Re: Publish a single joint_state ROS topic for a set of selected joints

Post by fferri » 20 Feb 2019, 09:47

The ROS plugin is deprecated.

It is now recommended to use the new RosInterface plugin, which is more flexible.

Post Reply