-
-
Notifications
You must be signed in to change notification settings - Fork 91
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
LM393 speed sensor #24
Comments
That's true
No, not directly a package on its own currently. The code for the encoders is running on the Teensy 4.0 (or 3.2) microcontroller. This script is part of the |
I believe the hardware on my "tank" is quadrature, so I'll try to get software to match that. My previous robot didn't have that, and it caused problems moving backward. |
I fully agree with you on quadrature encoders and my last comment missed that point a bit. As you mentioned, it is possible to read the direction using quadrature encoders and the motors that I use DG01D-E have one built inside. As far as I am aware, the Teensy Encoder lib that I use makes use of quadrature encoders: counting both edges (rising and falling) on both channels to make use of the counts per revolution (CPR) and therefore yield a high resolution. Unfortunately I don't know if there exist a specific ROS package for quadrature encoders already but it would be interesting to know. |
I see, it is just your hardware that isn't quad, the software is capable! That is good to know. I will continue to install the software. |
Seems like that would be best, to let the Teensy deal with the ticks and free up the Raspberry to deal with cameras and navigation and communications. At this point, (in your documentation) the Raspberry is wired with I2C connections to encoders. I don't understand how the Teensy also deals with this counting? |
The ones I use are also quadrature encoders. So I can confirm that it works with the software that I use :-)
Exactly, on the Teensy I also make use of hardware interrupts (done by the Teensy Encoder Library).
This is not the case, otherwise the documentation is wrong. The two "Hall effect pins" (H1 and H2) of each encoder are directly connected to hardware interrupt capable pins on the Teensy. This is documented here but I should add the schematic showing how it is done. I hope to finish that soon. |
From: The LM393 speed sensors also use a single digital GPIO pin each. These pins will be setup using software interrupts with the RPi.GPIO library. |
Thank you! That part of the docs, regarding the LM393 speed sensors, is outdated. Also I don't use software interrupts. Now that you showed me I will update it :-) But it is true that the Grove I2C Motor Driver is connected via I2C to the Rasperry Pi. This motor driver powers the two motors (M+, M-). However, the encoders (H1, H2) are directly connected to the pins on the Teensy, hence no I2C used for them. |
I checked into the Grove I2C motor driver but it was out-of-stock. I got an Ardumoto from SparkFun. But I figured out that their sample program for controlling it was incorrect. They tried to use just one sense line to change direction of motor, and two are required by the L298. In the "spin" portion of the code, they happened to send the two, and the robot will spin, but they failed to note that in the other segments, forward and reverse were not operating properly. In2 and In4 are also needed, and are not wired to the edge of the board, but are accessible in the center portion. I will use the Teensy to drive the Ardumoto board and this should work. Thanks for your guidance! |
Franz, I wonder if you forgot to include the header file for the Teensy encoder program? |
Hi Russ, yes you are right I didn't include the Now after you raised this question I am thinking of including the Teensy Encoder library, because as this would make the (next) tag more robust to changes in the Encoder library. I think this is what Linorobot did and it seems that he includes the whole On the other hand I am not really a fan of copying complete code sections from another source, because this will likely lead to missing updates in the external libraries. However, to cope with braking upstream changes, I think it would be better to state which tag of the external library/dependency was used or is needed in order to build a specific tag. I think I will go this way, and add the exact version of the rosserial lib and the Teensy Encoder library to the documentation and also add a comment into the Encoder script of my repository. |
That is interesting, I didn't know it was already included! That makes it easier, yes. What about the switch for Teensy, making it faster: |
Yes implicitly the library dependency is available and I think that this makes this repository's code base more light weight.
Yes that would be a great addition and would be interesting to know more about results! From the specific section in the encoder library documentation: https://www.pjrc.com/teensy/td_libs_Encoder.html#optimize it seems that this will make the code perform faster on Teensy/Arduino boards. In case you are interested and have the time I would also welcome a PR on this. But I would also add a comment about the possible downside mentioned in the docs:
|
arduino-1.8.13/hardware/teensy/avr/cores/teensy3" -I/home/rodolfo/Arduino/libraries/Rosserial_Arduino_Library/src /tmp/arduino_build_863282/sketch/sketch_feb20a.ino.cpp -o /dev/null -DARDUINO_LIB_DISCOVERY_PHASE |
I copied the file Encoder.h from "Build" under Catkin_ws, and put it into a folder named "diffbot_msgs" under libraries, under Arduino. Seems the Arduino IDE isn't happy with this. |
Copying the What I would try first is to check if the |
Yes, that example does compile. The other doesn't because of diffbot/encoder.msg |
Ok sounds good if that is working. Now regarding the I documented it here: https://fjp.at/diffbot/diffbot_msgs/#using-rosmsg and it is basically from the official documentation here: http://wiki.ros.org/rosserial/Tutorials/Adding%20Other%20Messages |
Sounds good. I will get to work on this in 24 hours. |
I got it to recognize and load Encoder.h ResolveLibrary(ros/types.h) |
There might be a confusion with Can you confirm that your rosserial_library in the Arduino libraries folder contains the diffbot_msgs package? This is what I get when compiling the encoders.ino: Another issue that might cause your compiler error is a rosserial lib that is too old. I am using the latest tag from github: https://github.com/frankjoshua/rosserial_arduino_lib/tree/0.9.1 There might be even two ros_serial libraries inside your Arduino/libraries folder. The one you can download with the Libraries Manager and the latest one. I agree this is not enough documented on my side. I hope the above can still help you but I will also look into this again and try to provide a better workflow to get this working. |
Here are some more insights on how the arduino rosserial library looks for me: In my home folder
Please notice the |
Yes, it could be an issue of different versions. On my laptop I have Melodic, and on the Raspi, Noetic. I am attempting to program the Teensy from the laptop. Maybe the Arduino IDE works on the Raspi? Earlier, I found that the Arduino IDE didn't run on the Nvidia TX1. Thanks for your patience! |
Making progress! This much could run in Rviz and Gazebo: started roslaunch server http://localhost:46705/ SUMMARYPARAMETERS
NODES auto-starting new master setting /run_id to 3809b1b8-7579-11eb-99a1-f17e41f2f6b1 |
My Rosserial library doesn't seem to contain the diffbot_msgs package. How does it get there? Before, I just manually copied your Encoder.h file from a catkin build directory, or some such. |
Hi Russ, good progress!
Yes, I also flashed the Teensy using the Raspi which is running Ubuntu Mate 20.04 and ROS noetic. But most often I flash with my laptop, also running Ubuntu 20.04 and ROS Noetic. Running
To get the
After that it should be possible to compile the encoder.ino. |
rod@rod-raspi:~/catkin_ws$ rosdep check diffbot_control Yes, I did get it to compile correctly! |
The Teensy is able to control motors and send encoder info to Raspi now. Ticks and angle are changing rapidly. Thanks! |
Nice, great that you got the encoder script working! You're welcome, and thanks for going through the not so finished documentation. This helps me to make it better.
In this case, I assume there is either another package missing or some performance issues because of this warning:
On which hardware are you launching the command: By the way thank you for the sponsoring :-) |
That was on the Raspberry Pi that I ran the command. The second time it came up faster, but still with the error. Yes, my laptop is an I5 and should handle it better. I will try the command on that. It also has an Nvidia graphics subsystem. |
Clicking on "Raspberry Pi Setup" on Diffbot website goes to "ROS Network Setup," not the correct page. |
Ok, then I guess the problem comes form the rather low performance of the Raspberry Pi.
Great, the simulation should work without problems on your laptop.
Thanks for reporting this, I will keep track of this in #25. |
Franz, if you want to see my tank robot, it's here. |
Hi Russ, your tank looks good! I also went through the the logs and here is what I can suggest for now:
These values seem to be the same that I am using for DiffBots small wheels. I am not sure how to best set the parameters for the wheel tracks your robot has. Also check that the wheel separation is correct. You can change them in the I also suggest you check with what rate your hardware interface runs. I had that set to 50Hz previously but I encountered some problems when this was too high. So I went back to 10Hz. This can be done in the
The above shows the initialization of the PIDs that are running in the high level hardware interface for each motor. Form this, I see you have the same values that I use for my cheap motors. I suggest you try without PID first. For example set the F=0.0, P=1.0, I=0.0, D=0.01. The inital values should be set here in the Another error that might cause problems later on is the lidar:
Was it possible to run this without erros on its own? |
Franz, thanks for the comments! I will get to work more on it Monday and Tuesday, which is my "weekend." Yes, I never saw the laser spinning, and I don't know why. At first I didn't have the optical sensors plugged into the USB3.0 ports but they are now. I don't have the Intel depth camera enabled yet, though the software is installed and I have seen the output on the Realsense viewer. Did you mean to have so much encoder output to screen? That seems to cover up other info and may take bandwidth. |
You're welcome, you are on the right track and I guess your tank will be running smoothly.
Have you added your (non root) user to the dialout group? It could be a permission problem. I have described how to do this in the hardware interface/usb-devices section of the documentation. But I am not sure if my advice works for the YDLidar, but the steps they describe here: https://github.com/YDLIDAR/ydlidar_ros/blob/master/docs/ydlidar.md seem to be promising.
I did use One thing I forgot to mention previously: Because you have a tracked robot, I think the skid steer config of the ROS control But it may also work with some modified settings in the current two wheeled version of the |
Yes, turning, especially on carpet, will take more power. The Lidar is now working. It needed more power! So installed a second pack of 3 three 18650s and a small regulator, and plugged that into the second Lidar jack. This will also be good when I power up the camera on the same USB bus. I am using "diffbot_bringup_with_laser" and I wonder why the tracks are turning? Shouldn't it wait for a navigation package to be launched? Move_base isn't running yet, is it? Here are the topics: |
Attempted to run diffbot_navigation diffbot_hw.launch But it has errors and then a fatal error. This is to be run on real robot, no? I thought maybe this would complete commands for navigation. Here is output from that terminal. (I made changes to other programs as you suggested.) rod@raspi:~$ roslaunch diffbot_navigation diffbot_hw.launch started roslaunch server http://raspi:44639/ SUMMARYPARAMETERS
NODES ROS_MASTER_URI=http://192.168.1.179:11311/ process[map_server-1]: started with pid [1620] Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, xcb. [ WARN] [1615324533.563991362]: global_costmap: Pre-Hydro parameter "static_map" unused since "plugins" is provided
|
This is a bug, I encounter the same problem on my robot. I suspect missing zero initializations in the Another source of this problem might be the motor driver code. What I do to "solve" this, is to send an empty message on the Thanks for reporting, I'll add a new ticket to track this.
I should update the Readme here for the real robot. The instruction in the readme are just for the gazebo simulation:
For the real robot I made a video where you can see the commands that I used: The commands I use in the video are (as you did correctly):
and in a new terminal on your remote/work pc (not the raspi) run the slam gmapping with the same command as in the simulation:
As you can see in the video, this should open up RViz and the robot_steering_rqt plugin.
Sorry this is missing in the video, but the launch file should work to navigate the real robot using this
|
Franz, Thanks for more guidance! |
The tank is running as it's supposed to! Laser map comes up fast. I had to add steering plugin to diffbot_slam.launch in order to control it. Otherwise it sat and spinned in place! Also got the Gazebo sim working on laptop yesterday. So making real progress! Hope all is well in Austria! |
Hi Russ, you are welcome and glad you got the tank working 👍 The https://github.com/norlab-ulaval/husky-trainer looks interesting indeed, I hope to find more time soon to try it. But first I want to work on the other open TODOs/Issues.
True, that's missing. But because it is also common to use other steering tools such as the http://wiki.ros.org/teleop_twist_keyboard I didn't add it explicitly in the launch file.
Thank you everyting is fine. I hope in Hastings too! |
Here's an interesting top level framework: |
Now I'm using an Xbox controller, wired, via laptop, to drive tank. She's quite hard to control. How can I remove the PID routine? My teleop_twist_joy publishes -0.5 to 0.5 ranges. Is that correct for the input to diffbot/mobile_base_controller/cmd_vel? I tried using the dynamic_reconfiguration tool but didn't have much luck there. It certainly does change how she responds! |
Hi Russ, I haven't tested using a controller so far but it should work. You can see and adjust the linear and angular controller velocity and acceleration limits in the The calculated (F)PID output value is actually used in the If you really want to try disabling the PID, it should be possible when you set just F=1 (or a value near 1) and all other values to zero (P=0, I=0, D=0). This setting will directly use set_point velocity from the controller ( Also please remember that ROS control assumes that the commands its controller generates, must be executed by the motors. |
Franz, I tried these new values, 0,0,0,1 and wheels did jump back and forth. So I put them back as they were. Using pared down launch files, and tank on a stand, without touching the joystick at all, the motor_left value is -14, and that track is turning, not slowly. Why doesn't it send the zero value? I tried changing values in the control.yaml file but this didn't change the left motor running by itself. I checked hw_interface.cpp and it has 42 refs to left and 15 to right. Why are they not equal? |
I can confirm a similar behavior. Let's keep track of this problem in #30. I'll try to find out why the initial read velocity isn't zero, because this seems to be the root cause for this issue.
This is just because I use |
Just wanted to give a short update on the initialization issue mentioned in #30. I think I found the problem and hope the uncontrolled wheel spin at the start is solved soon. For more details please see my latest comment. |
Note that this sensor is deprecated in the current version of DiffBot because it isn’t a quadrature encoder.
Is there a package we can install that is quadrature enabled? Wouldn't that be better?
Russ
The text was updated successfully, but these errors were encountered: