Autocomplete in code editor question

Hi
I am going thru the courses, And i am trying to use the neat feature of Autocomplete in python / vs code.
I have a big problem as my English is not that good, and i am constantly making misstakes when typing.
(i know learn how to spell correctly is the obvious solution)
How can i make the code editor when dooing the courses or rosjects work better.
For instance when i type:

from services_quiz_srv.srv import Tu 
#it should normaly give you an option of the services that are alreaddy in the services_quiz_srv.srv

#another example that works (almost great is):
from geometry_msgs.msg import Twist
test1 = Twist()
test1.ang #here it gives you an option of angular
#but when you continue
test1.angular #after pressing . it will not give you the aditional options of x or y or z ....

#an exemple that does not work at all

from services_quiz_srv.srv import Turn
test2 = Twist()
test2. #gives you 0 options whatsover

i know it is not a make it or break it, but what it does is, it causes me to look for spelling errors in the code instead of focusing on learning the actual system. i had a case where i lost quite a lot of time craking my head against the wall until i noticed it was a simple spell error

When i try similar thing on my ubuntu on VS code that i have installed it works great even with custom messages.
So then i end up copy pasteing the code that i type in my VS code editor on my computer and then pasting it back wich is not the most optimal specially when you want to test code and so on…

Can someone please help me with this?

Thanks Ziga

Hi @ziga.rupret ,

I can give you some suggestions to get this working, but, unfortunately I don’t think there is a correct solution for this problem.

When you are importing a custom message, always make sure that you have compiled your custom message package.
So, if you previously compiled services_quiz_srv package, you will not have any issues while importing the custom srv message and the auto fill will work. If you have not compiled your custom message (msg / srv / action), then the autocomplete will mostly not work. I have experienced this myself.

You will notice the same issue when you use Empty requests and responses.
When you do :
from std_srvs.srv import Empty, EmptyRe and wait for autocomplete to give you EmptyResponse or EmptyRequest - you will only end up waiting forever. It will not complete. This is also something that I have observed.

When it comes to test1.angular and pressing . later, it mostly does not work for assignment, but works for assigning.
So when you do:
test1.angular. to do something like test1.angular.x = 0.05 - it will not work.
But when you do something like:
testtest1.data = test1.angular.x this it it will give you the x, y, and z options.

And lastly,

from services_quiz_srv.srv import Turn
test2 = Twist()
test2. #gives you 0 options whatsover

This one will NEVER work, WHEN you have any errors in the above line or any of the imports directly above is unrecognized.
Let me explain this clearly,
[If services_quiz_srv is not compiled] and [If you defined test2 = Twist()]
test2. will not autocomplete - since services_quiz_srv is not compiled.
So according to the IDE, that line has an unrecognized error and the lines following that line will have no autocomplete working.

So, these are all my observations and may or may not be the same for others.

Unfortunately, I guess there is no certain way around this. That is why I mentioned earlier that this issue may not have a solution.

Regards,
Girish

PS: Others who have read this post till this line, I would like to know your experience(s) too and would like to know if you have any fix(es).

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.