How to write my own joint state
Hello all i have a real robot. using ROS. i have a problem with (Joint State Publisher)
i understand that i should write my own (joint state publisher node). i read the related tutorials but i do not get how to convert encoders' messages to joint state message. i need steps or tutorial for doing that.
thanks in advance.
edit
i test the code in
my code becomes as follows
#!/usr/bin/env python
# Lucas Walter
# make a joint exactly what the command wants it to be- this only works
# for position control.
import rospy
from sensor_msgs.msg import JointState
from std_msgs.msg import Int64
class CommandToJointState:
def __init__(self):
self.joint_name = rospy.get_param("lwheel",True)
self.joint_state = JointState()
self.joint_state.name.append(self.joint_name)
self.joint_state.position.append(0.0)
self.joint_state.velocity.append(0.0)
self.joint_pub = rospy.Publisher("joint_states", JointState, queue_size=1)
self.command_sub = rospy.Subscriber("lwheel", Int64,
self.command_callback, queue_size=1)
def command_callback(self, msg):
self.joint_state.position[0] = msg.data
self.joint_state.header.stamp = rospy.Time.now()
self.joint_pub.publish(self.joint_state)
if __name__ == '__main__':
rospy.init_node('diffdrive_controller')
diffdrive_controller = CommandToJointState()
rospy.spin()
but i get error as in the image attached
i am not familiar with python. all my codes are in C++
In
get_param
the first argument is the name of the parameter, not the value of it- the second value is the value, you probably want get_param("joint_name", "lwheel")@marawy_alsakaf: can you please post a copy and paste of the error instead of a screen shot? Text is searchable while images are not.