ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Problems importing ROS messages (ROS Noetic)

asked 2022-05-04 19:43:32 -0500

LuisEFA1998 gravatar image

updated 2022-05-05 08:18:46 -0500

aarsh_t gravatar image

I am writing a code in Python to create a node to subscribe to a topic, however, I am having a little problem with the libraries, when I write the messages that I need to import, it appears in VSCode that I do not have access to them. On the screen it tells me that I cannot access the String of std_msgs.msg nor Joy of sensor_msgs.msg. Does anyone know how I can fix that error?

ROS Answers still won't let me upload photos because I'm new but what I wrote at the top of my code is:

#!/usr/bin/env python3
# encoding: utf-8

import rospy

#It won't let me import these two messages:
from std_msgs.msg import String 
from sensor_msgs.msg import Joy

from control_msgs.msg import FollowJointTrajectoryActionGoal
import math

If I click on String or Joy I get a message that says: "String" is not accessed Pylance

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2022-05-05 03:55:53 -0500

aarsh_t gravatar image

updated 2022-05-05 14:09:08 -0500

In general this is not an issue. Because your vscode workspace does not know from where the std_msgs or any ros includes are coming from. But still you will be able to run your code without any error.

To get rid of the warning underline, you can add following thing to your .vscode/settings.json

"python.autoComplete.extraPaths": [ "/opt/ros/noetic/lib/python3/dist-packages/ ], "

For an example of a good vscode configuration you can visit here. The only thing is it is for ros2.

edit flag offensive delete link more

Comments

Your repo might be set to private. I'm getting a 404

Joe28965 gravatar image Joe28965  ( 2022-05-05 08:43:39 -0500 )edit
1

@Joe28965 I have updated the link to the original repo from where I forked it. Thanks for informing.

aarsh_t gravatar image aarsh_t  ( 2022-05-05 14:11:03 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2022-05-04 19:43:32 -0500

Seen: 745 times

Last updated: May 05 '22