Hi,

I had a question about the variables in the Twist message type. I’m going to try to get straight to the point here.

move = Twist()

move.linear.x = 0.5 #Move the robot with a linear velocity in the x axis

move.angular.z = 0.5 #Move the with an angular velocity in the z axis

My confusion was in determining move.linear.x and move.angular.z

*specifically .linear.x and .angular.z*

I used rostopic info /cmd_vel to determine the type geometry/msgs/Twist

Then roscd geometry/msgs/msg to enter the directory where the Twist.msg was

cat Twist.msg shows Vector3 linear and Vector3 angular

I’m new to python as in just began learning everything from this course within the last week. From my understanding Twist is a class. I figured Twist.linear and Twist.angular were variables of this class, but I’m not sure where the .x or .z are coming from. I’m also not sure where to look to find whatever file this is all declared in.

The essence of what I’m trying to ask is how could I have determined without looking at the solution that it was move.linear.x = 0.5 instead of move.linear = 0.5?

For anyone reading, I’ve made some progress on this question:

part of what I was missing was rosmsg show geometry_msgs/Twist

this indicates linear x,y,z float 64 and angular x,y,z float64

Additionally rosmsg show geometry_msgs/Twist indicates there is a geometry_msgs/Vector3 : what is this, and how can I access it? When I attempt to go there the terminal tells me the directory does not exist.

Any clarification on the syntax meaning of Twist().linear.x would be appreciated: in terms of python what is linear? Once again my understanding is Twist is a class, x is a variable, is linear a data structure or something?