joint state publisher

Hello everyone,

my question is how can i create a joint state subscriber or publisher like ros# script ? ı want to control a robot arm via rviz with moviet.

ı upload a photo of ros# script for subs to joints.


Hi, sorry for the late reply. It sounds like you want to do something similar to our Pick and Place demo:

Specifically, here's a script that makes the robot perform the trajectory sent by MoveIt:

Hope that helps!

Hi, I am also working with the same robot.
I have created this. It works perfectly.

using UnityEngine;
using Unity.Robotics.ROSTCPConnector;
using SensorUnity = RosMessageTypes.Sensor.JointStateMsg;
using System.Collections;

public class JointStateSub : MonoBehaviour
    [SerializeField] private string rosTopic = "joint_states";
    [SerializeField] private ROSConnection ROS;
    [SerializeField] private ArticulationBody[] robotJoints = new ArticulationBody[9];
    // Start is called before the first frame update
    void Start()
        ROS = ROSConnection.GetOrCreateInstance();
        ROS.Subscribe<SensorUnity>(rosTopic, GetJointPositions);

    private void GetJointPositions(SensorUnity sensorMsg)
    IEnumerator SetJointValues(SensorUnity message)
        for (int i = 0; i <; i++)
            var joint1XDrive = robotJoints[i].xDrive;
   = (float)(message.position[i]) * Mathf.Rad2Deg;
            robotJoints[i].xDrive = joint1XDrive;

        yield return new WaitForSeconds(0.5f);

    public void UnSub()
1 Like

@medinafb01 Do you know how to use joint velocity controller?

At present, I have seen unity only has position controller.
If anyone knows how to setup joint velocity controller than please let me know.

@vermahrithik10 Hello,
No, I have not used it.

But I know it is possible to build it.
Here are some links that may help you:

How to create your own controller - Unity Robotics.

How a velocity controller works

One question, are you still using ROS# with the panda robot?

@medinafb01 @vermahrithik10 Hello, you two. You basically did the same work i'm doing now and maybe one of you can help me.
First of all, @medinafb01 thanks for your script, it works really well and i haven't found anyone who did the same thing besides you. I just have one question. Do you know any way to specify how often the joint states position gets updated in unity or something like that?
For better context: i'm simulating the panda robot on the hololens 2 and i try to use the robotics hub. Since there is really no good documentation, i searched ages for a way to subscribe to the jointstates topic. Then i found your script. I have to say i don't understand it completly, for example: does the Subscribe function you call in Start reguarly call the GetJointPositions function or just once? Before i found your script i thought, that i probably have to update the joint position reguarly in the update function or something like that.
But back to my main problem. Your Script works fine, but on the hololens, the robots movement looks like it is only moving with 15-20 fps, like really jittery. I don't know how to fix that, in Ros i already specified a 60 fps rate for sending the joint states. Do you have any idea how to fix that? Thanks in advance and if you need any more information, do not hesitate to ask!