ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A answers.ros.org
Ask Your Question
0

Problems importing ROS messages (ROS Noetic)

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

LuisEFA1998 gravatar image

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

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 -0600

aarsh_t gravatar image

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

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 -0600 )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 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

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

Seen: 202 times

Last updated: May 05 '22