srmainwaring / curio

ROS packages to control a version of Roger Chen's Sawppy Rover.
Other
57 stars 20 forks source link

The wheels of a car don't move #9

Closed ddwy closed 3 years ago

ddwy commented 4 years ago

Hello, can you provide the hardware wiring diagram and the curio firmware?

Here is my hardware wiring diagram. If there is any error, please point it out for me.

Thank you

image image image

srmainwaring commented 4 years ago

@ddwy The serial connection between the BusLinker servo board and the Arduino should not use TX0 / RX0 (Serial) as it this UART is also used to communicate with the computer by USB (see for example: Arduino Serial Reference). This would explain why you are seeing the ROS serial connection sync issues here 1 #4.

In curio_firmware.ino Serial1 is used to connect to the servo bus. This uses pins 18 and 19 on the Arduino Mega.

https://github.com/srmainwaring/curio_firmware/blob/1fbf725c350dac708893b4af6523db931e931abb/firmware/curio_firmware/curio_firmware.ino#L172

I don't have a wiring diagram but have attached photos of my set up. The Arduino is hiding under the breadboard (which holds an IMU and a Teensy4 which is used to relay the IMU and RC data onto ROS serial). I am only using the Arduino to relay the serial commands between the BusLinker board and the RPi4.

The Buslinker is in the middle and the power regulator providing the 5V supply is above it.

IMG_7263

The second photo shows the connection from BusLinker RX (yellow) to pin 18 (Arduino Mega TX1) and BusLinker TX (green) to pin 18 (Arduino Mega RX1). I use the 5V supply near the UART pins, but that is neither here nor there.

IMG_7260

I also notice you have a micro USB on the BusLinker board. I have used this for a optional failsafe, but to start with I'd disconnect that to avoid confusion.

ncnynl commented 3 years ago

Hello srmainwaring

I debugged the curio code and found that as long as ros is introduced, the servo cannot be controlled normally. The problem is that serial1 cannot output normally. LobotSerialServoAngleAdjust function can be executed normally, SerialX.write cannot take effect. The default definition servo uses serial1 as the serial port for controlling the servo, and serial as the serial port for ros interaction. I use the serial cable to monitor serial1 alone, but there is no output.

I suspect it is, but after the introduction of ros, serial will cause serial1, 2, and 3 to fail. I have tested 1, 2, and 3 serial ports, but there is no output. If ros is not introduced, several serial ports are working normally.

srmainwaring commented 3 years ago

@ncnynl I have not seen the issue you describe when using ROS serial to communicate with an Arduino that is connected to the BusLinker on Serial1. I have seen ROS lose sync with the Arduino when data rates get too high or missed packets between the BusLinker and Arduino. The serial baud rate for ros_serial and servo loop update frequencies have been tuned to try and minimise this.

To help me replicate the problem you are seeing could you describe the hardware and software setup you are using for testing . The following would be helpful:

Hardware

Software

And anything else you think relevant.

ncnynl commented 3 years ago

@srmainwaring

hi srmainwaring

I have tested the code and it runs normally.

At the beginning, I modified the servo ID under windows and flashed the firmware through arduino, but it didn't work normally. Later, I moved this modified code to Linux, and then flashed the firmware, but it didn't work properly.

Later, I tested a minimal version of ros and it worked normally.

Then I downloaded the code directly from github to linux to flash the firmware. is normal.

The code is ok.

It may be a problem with my modified version under windows that caused it to not work properly.

srmainwaring commented 3 years ago

@ncnynl I have not tested the ROS code under Windows, only linux and macOS. It may be that when you copied from Windows to linux the line endings were changed which gave rise to the issues you saw?

In any case it is good to hear that you have the software working now and I'll close the issue.