Search code examples
pythonpycharmros

unable to detect custom message sub-directory( i.e package.msg) in ROS


I am new to ROS. I tried to make a custom message that has the attributes of an IoT sensor. I followed every step in the tutorials (i.e, making a msg sub-directory, creating and editing the file and updating dependencies) when I run the following command, $ rosmsg show iot_sensor [ros_essentials_cpp/iot_sensor]: int32 id string name float32 temp float32 hum which means that the message has been registered. however, I can't seem to import the custom message in pyhcarm. enter image description here

any help is appreciated! :D


Solution

  • Your python editor will only be able to find the ROS modules for the messages that you created if they are added to your PYTHONPATH environment variable. Sourcing your ROS workspace will correctly set up the environment variables for you, including the PYTHONPATH.

    The easiest way to solve your problem would be to open a terminal, source the workspace with your iot_sensor message and then start pycharm from that terminal. I'm not a pycharm user myself, but here seem to be some suggestions on starting pycharm from the terminal, if you don't know yet how to do that.