I ran ros2 show interface sensor_msgs/msg/JointState
to see how to publish using the command line AND python code. THis is the result:
^Cbwuk@robots:~/my_robot/my_robot_description$ rosinterface show sensor_msgs/msg/JointState
# This is a message that holds data to describe the state of a set of torque controlled joints.
#
# The state of each joint (revolute or prismatic) is defined by:
# * the position of the joint (rad or m),
# * the velocity of the joint (rad/s or m/s) and
# * the effort that is applied in the joint (Nm or N).
#
# Each joint is uniquely identified by its name
# The header specifies the time at which the joint states were recorded. All the joint states
# in one message have to be recorded at the same time.
#
# This message consists of a multiple arrays, one for each part of the joint state.
# The goal is to make each of the fields optional. When e.g. your joints have no
# effort associated with them, you can leave the effort array empty.
#
# All arrays in this message should have the same size, or be empty.
# This is the only way to uniquely associate the joint name with the correct
# states.
std_msgs/Header header
string[] name
float64[] position
float64[] velocity
float64[] effort
As you can see it's using the array input.
I have no idea how to start that in python code or command line.
I tried to run like this;
ros2 topic pub --once /joint_states sensor_msgs/msg/JointState '{name, "front_right_wheel", position: [0.0], velocity: [1.0], effort: [0.0]}' --once
Obviously, it didn't work. I tried others as wel. No luck.
I couldn't find the ros2 document for it. I found a lot of documents on ROS1 however, I joined ROS2 so I have almost no knowledge on ROS1.
Originally posted by kak13 on ROS Answers with karma: 113 on 2021-08-25
Post score: 0