Problem with Rosject Part III

I have encountered a problem while doing the third and last part of the rosject.
I had the idea to use a box area centered in the start position to know if the robot does a lap on the circuit, so my server starts listening and listing the odom reads on the result variable, but when I end the experiment (for that I need to get out of the area, to prompt the second part of the project, and then come back again) I encounter an issue with the result of the action.

I attach pictures of the terminals:
<Terminal 2>: The Server Node

user:~/catkin_ws/src/action_pkg/scripts$ rosrun action_pkg
[INFO] [1681299902.707323, 489.203000]: x_min = -0.10796711479883608, x_max = 0.29203288520116394
[INFO] [1681299902.710768, 489.205000]: y_min = 0.10634606622543119, y_max = 0.5063460662254312
[INFO] [1681299902.845626, 489.288000]: Odom Readed
[INFO] [1681299902.851840, 489.291000]: Position Added to the List
[INFO] [1681299902.854861, 489.293000]: Feedback Updated
[INFO] [1681299902.864026, 489.300000]: x = 0.09202386138625213, y = 0.3063460662254312
[INFO] [1681299904.431879, 490.317000]: Odom Readed
# The robot gets out of the box area
[INFO] [1681299941.921831, 512.215000]: El robot ha salido del cuadro de control
[INFO] [1681299942.116995, 512.323000]: Odom Readed
[INFO] [1681299942.121676, 512.324000]: Position Added to the List
[INFO] [1681299942.136707, 512.338000]: Feedback Updated
# The robot enters again to the area
[INFO] [1681299943.534329, 513.158000]: El robot ha dado una vuelta, enviando resultado
# I added a line to see what was inside the variable self._result (which is the one that I use to call the
# set_succeeded
[INFO] [1681299943.539749, 513.165000]: list_of_odoms:
  - [0.09202386138625213, 0.3063460662254312, 0.3605375825121338]
  - ... (There are a bunch more)

<Terminal 4>: rostopic echo /record_odom/Result

user:~$ rostopic echo /record_odom/result
WARNING: no messages received and simulated time is active.
Is /clock being published?
  seq: 1
    secs: 3848
    nsecs: 550000000
  frame_id: ''
      secs: 3848
      nsecs: 346000000
    id: "/actions_quiz-1-3848.346000000"
  status: 4
  text: "Exception in execute callback: 'list' object has no attribute 'x'"
  list_of_odoms: []

So I don’t know if I did something wrong, I have tried to append the elements in list_of_odoms as _result.list_of_odoms.x.append() but didn’t work, so I added them as each element of list_of_odoms is a list composed by (x,y,theta).

In any case, if you need some of my code to check it just ask me, I would love to solve this issue asap
(I’m not posting anything at the moment in case it breaks any rules according to Rosjects)

I managed to solve the issue, I attach how I did it so if anyone encounters this problem here is how to solve it.

So the problem was with the type message Point32 and the format of the result message.
When I tried to do:

rosmsg show geometry_msgs/Point32[ ]

it didn’t exist, but if you only use the Point32 (when you define the Action.action) you won’t be able to use methods such as append, in order to keep adding numbers to the array.

So, as I said on the first post, I came up with the solution of making an array of three elements, and appending them to result.list_of_odom.

For the Action Server, it worked fine, and as shown, you could see the list of the odometry saved. But in reality, the result message couldn’t be sent because it was trying to assign the correct values for each variable in the msg format:


geometry_msgs/Point32[] list_of_odoms
float32 current_total


float32 x
float32 y
float32 z

So that is the attribute x that it was looking for and didn’t see it (according to the error prompted in <Terminal 4>).
The solution was simple, but I didn’t see it for a while. Just create a Point32 object, insert the positions inside and then append the object to list_of_odom as done here:

odom = Point32(x = self._pos_x, y=self._pos_y,z=self._theta)

And that solved the issue! The result popped fine and the action ended as it should!

I tried to explain as brief as possible, and easy so everyone could understand the solution.
You can also ask me if you require a better explanation hehe and happy coding everyone!

Have a great day,
Ángel López