Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Syntax error compiling base_controller in VSCode+PIO #40

Closed
joeuser846 opened this issue Oct 5, 2021 · 10 comments · Fixed by #41
Closed

Syntax error compiling base_controller in VSCode+PIO #40

joeuser846 opened this issue Oct 5, 2021 · 10 comments · Fixed by #41
Assignees
Labels
bug Something isn't working
Projects

Comments

@joeuser846
Copy link
Contributor

I've imported the base_controller project directory into VSCode+PIO. I added the Paul Stoffregen "Encoder" library but when I build I get the following syntax errors. I'd really appreciate a little guidance on what I did wrong and how to fix it. The issue seems to have something to do with namespace and scope, but exactly what? Thanks in advance for any help.

[platformio]
default_envs = teensy31
[env:teensy31]
platform = teensy
board = teensy31
framework = arduino
lib_deps =
frankjoshua/Rosserial Arduino Library@^0.9.1
./lib
adafruit/Adafruit Motor Shield V2 Library@^1.0.11
Wire
paulstoffregen/Encoder@^1.4.1

Building in release mode
Compiling .pio/build/teensy31/src/main.cpp.o
Compiling .pio/build/teensy31/lib821/SPI/SPI.cpp.o
Compiling .pio/build/teensy31/lib8c6/Ethernet/Dhcp.cpp.o
Compiling .pio/build/teensy31/lib8c6/Ethernet/Dns.cpp.o
In file included from .pio/libdeps/teensy31/lib/base_controller.h:17:0,
from src/main.cpp:4:
lib/encoder/encoder.h:39:11: error: 'Encoder' in namespace '::' does not name a type
::Encoder encoder;
^
lib/encoder/encoder.h: In member function 'int32_t diffbot::Encoder::read()':
lib/encoder/encoder.h:89:40: error: 'encoder' was not declared in this scope
inline int32_t read() { return encoder.read(); };
^
lib/encoder/encoder.h: In member function 'void diffbot::Encoder::write(int32_t)':
lib/encoder/encoder.h:97:40: error: 'encoder' was not declared in this scope
inline void write(int32_t p) { encoder.write(p); };
^

@fjp
Copy link
Member

fjp commented Oct 5, 2021

Hi @joeuser846, this is indeed strange. I noticed you added paulstoffregen/Encoder@^1.4.1 explicitly in the platformio.ini. As far as I know this shouldn't be required, the platformio.ini I use looks like this:

[platformio]
default_envs = teensy31
[env:teensy31]
platform = teensy
board = teensy31
framework = arduino
lib_deps =
frankjoshua/Rosserial Arduino Library@^0.9.1
./lib
adafruit/Adafruit Motor Shield V2 Library@^1.0.11
Wire

The reason is that the encoder library should be already integrated in the framework-arduino package.
Can you please try compiling after removing this line: paulstoffregen/encoder@^1.4.1 and let me know if this works for you?

There might be an issue with this version of the library, which comes up also in this thread (although it seems to be not directly the same issue you have):

  • it seems you have the Encoder library installed in the local library storage via the VSCode UI. This is not necessary since the encoder library is already integrated in the framework-arduino package. If you remove it, it should take the fixed version from the Arduino Package.
  • force usage of the updated version; that is, in the platformio.ini in the lib_deps directive, instead of saying Encoder give it the git link https://github.com/PaulStoffregen/Encoder.git

After the program compiles please also make sure to have the Teensyduino GUI installed, explained here: https://ros-mobile-robots.com/teensy-mcu/. Alternatively you could also try the teensy-cli upload_protocol without installing the GUI. Would be interesting to know if it works also without installing the GUI, because I have always installed and used the Teensyduino GUI so far.

@joeuser846
Copy link
Contributor Author

joeuser846 commented Oct 5, 2021 via email

@fjp
Copy link
Member

fjp commented Oct 5, 2021

I am sorry you ran into this issue, I didn't expect someone will build on other OS than Ubuntu and that this would cause an issue.

I can confirm that the base_controller doesn't compile on Windows either. It is a letter case issue. The problem is that Windows and seemingly macOS are case-insensitive to header file names. Ubuntu is case-sensitive and therefore "encoder.h" and <Encoder.h> are treated differently only on Ubuntu. For Windows and macOS these are the same header.

The problem can be solved by renaming encoder.h (and encoder.cpp) to something else. For example, I tried with encoder_diffbot.h, which makes the script compile successfully on Windows.

You can try this solution for now. If it works for you, a pull request with a suitable new name for the header is most welcome :-) Otherwise please just let me know if it works and I probably will fix this in the near future.

@fjp fjp self-assigned this Oct 5, 2021
@fjp fjp added the bug Something isn't working label Oct 5, 2021
@fjp fjp added this to To Do in Noetic via automation Oct 5, 2021
@joeuser846
Copy link
Contributor Author

joeuser846 commented Oct 6, 2021 via email

@joeuser846
Copy link
Contributor Author

joeuser846 commented Oct 27, 2021 via email

@fjp
Copy link
Member

fjp commented Oct 27, 2021

Hi @joeuser846 thanks for reporting this issue and the typo.

Looks like a naming mistake of the the link (frame) in the diffbot_description urdf and the frame id used in bringup_with_laser.launch:

<arg name="laser_frame_id" default="rplidar_gpu_laser_link" />

Can you please try again after changing the default value from rplidar_gpu_laser_link to rplidar_laser_link in the bringup_with_laser.launchand let me know if this is working?

@fjp
Copy link
Member

fjp commented Oct 27, 2021

I assume the suggested solution in my previous comment won't solve the issue. However, a possible solution is to modify the rplidar.launch file. Changing

<param name="frame_id"            type="string" value="laser"/>

to

<param name="frame_id"            type="string" value="rplidar_laser_link"/>

Or you can add an argument, which I will do to fix this issue:

<launch>
  <arg name="laser_frame_id" default="rplidar_laser_link" />

  <node name="rplidarNode"          pkg="rplidar_ros"  type="rplidarNode" output="screen">
  <param name="serial_port"         type="string" value="/dev/ttyUSB0"/>
  <param name="serial_baudrate"     type="int"    value="115200"/><!--A1/A2 -->
  <!--param name="serial_baudrate"     type="int"    value="256000"--><!--A3 -->
  <param name="frame_id"            type="string" value="$(arg laser_frame_id)"/>
  <param name="inverted"            type="bool"   value="false"/>
  <param name="angle_compensate"    type="bool"   value="true"/>
  </node>
</launch>

Would be great to know if this gets rid of the error messages.

@fjp
Copy link
Member

fjp commented Oct 27, 2021

Definitely make sure to rename rplidar_gpu_laser_link to rplidar_laser_link and change it in the rplidar.launch to match the frame_id to the link name in the diffbot_description urdf.

@joeuser846
Copy link
Contributor Author

joeuser846 commented Oct 27, 2021 via email

@fjp
Copy link
Member

fjp commented Oct 28, 2021

Thank you Ian for sharing this kind feedback! Glad to hear, the project is useful to you. I started it because I was facing the same difficulties as you mention. Congrats to you on getting this far and setting up your own robot 👏 The documentation on slam, navigation and robotics theory might also give you some starting points to explore more, although it is far from complete.

In case you run into any new errors or have suggestions to improve the project (documentation or code), please don't hesitate to open a new issue or discussion. Valuable feedback from collaborators like you is most welcome and helps to improve the project.

Best regards
Franz

@fjp fjp linked a pull request Nov 4, 2021 that will close this issue
@fjp fjp closed this as completed Nov 4, 2021
Noetic automation moved this from To Do to Done Nov 4, 2021
fjp added a commit that referenced this issue Jan 22, 2022
- Rename rplidar_gpu_laser_link to rplidar_laser_link in bringup_with_laser.launch
- Add rplidar.launch to diffbot_bringup to support framed_id argument
- Make use of new diffbot_bringup/launch/rplidar.launch in bringup_with_laser.launch

This solves issues in RViz:
Transform [sender=unknown_publisher]
For frame [rplidar_gpu_laser_link]: Frame [rplidar_gpu_laser_link] does not exist

and in the terminal from whic diffbot_slam is launched:

[ WARN] [1635345613.864692611]: MessageFilter [target=odom ]: Dropped 100.00% of messages so far. Please turn the [ros.gmapping.message_filter] rosconsole logger to DEBUG for more information.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Noetic
  
Done
Development

Successfully merging a pull request may close this issue.

2 participants