ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
Your snippets are not sufficient to determine where your error is caused. However Assertion
px != 0' failed.` of the shared pointer means that you have created a shared pointer instance and tried to access it with -> operator without having assigned it before (i.e., it is not yet pointing anywhere).
For the workaround without the shared pointer this will clearly not cause an error, because you are accessing the instance directly. However, your code (if that's everything you changed) won't do senseful operations if you have not assigned the message with contents before accessing it. Note that, by default in ROS messages all fields will be filled with zeros as they are created (bools with false).