hoverboard-robotics / hoverboard-driver

ROS hardware driver for UART-controlled hoverboard
MIT License
96 stars 52 forks source link

Only one motor spins on /hoverboard_velocity_controller/cmd_vel #5

Closed Richard-Haes-Ellis closed 4 years ago

Richard-Haes-Ellis commented 4 years ago

I'm testing the motors with the launch file included but for some reason only the right wheels pins when I publish to the cmd topic wity linear only velocity, I've made sure that the left motor works by testing it with the ASCII protocol with speed control and it works fine. Any Ideas on how to find the problems? Or what it could be?

alex-makarov commented 4 years ago

Hi @richaeell can you check the actual parameters that are being passed to api->sendSpeedData (left_speed, right_speed, max_power, min_speed);? (hoverboard.cpp:148)

Richard-Haes-Ellis commented 4 years ago

Hi Alex,

I've printed out the variables just before the sendSpeedData and it looks fine, futhermore im also printing out the writespeed->wanted_speed_mm_per_sec variable also in the (HoveboardAPI.cpp:324)

Screenshot from 2020-04-29 09-49-18

So It might be the hoverboardAPI library, I tested the same API with the Arduino example code with the same sendSpeedData and it worked fine over the same serial line. I honestly dont know what it could be.

I recompiled the workspace with catkin_make and I do get the following warning from compiling the hoverboardAPI cc1: warning: command line option ‘-std=c++11’ is valid for C++/ObjC++ but not for C

Screenshot from 2020-04-29 09-53-07

But not sure if this is the problem or how to fix it. Any idea?

Thanks!!

alex-makarov commented 4 years ago

Not many ideas considering that the same hoverboard API call works.

IIRC, I was using the other UART on the STM32 to catch the debug info, there should be a config for that in the firmware. Maybe that helps.

One other idea is the speed itself. At least with the motors I have, one wheel starts spinning a bit later when ramping up the current. So at very low speed values, one wheel might be still stopped.

Richard-Haes-Ellis commented 4 years ago

I've tested the motor at full speed but still not movement on left wheel.

I'm trying to find that configuration to debug it through usart3 but to no avail, ¿What configuration in the config.h file did you use on yours?

alex-makarov commented 4 years ago

here are my changes on the firmware

diff --git a/inc/comms.h b/inc/comms.h
index 53bb7ae..b5334b2 100644
--- a/inc/comms.h
+++ b/inc/comms.h
@@ -11,7 +11,7 @@ typedef struct tag_serial_usart_buffer {

 } SERIAL_USART_BUFFER;

-#if defined(SERIAL_USART2_IT)
+#if defined(SERIAL_USART2_IT) || defined (DEBUG_SERIAL_USART2)

     extern volatile SERIAL_USART_BUFFER usart2_it_TXbuffer;
     extern volatile SERIAL_USART_BUFFER usart2_it_RXbuffer;
@@ -22,7 +22,7 @@ typedef struct tag_serial_usart_buffer {

 #endif

-#if defined(SERIAL_USART3_IT)
+#if defined(SERIAL_USART3_IT) || defined (DEBUG_SERIAL_USART3)

     extern volatile SERIAL_USART_BUFFER usart3_it_TXbuffer;
     extern volatile SERIAL_USART_BUFFER usart3_it_RXbuffer;
diff --git a/inc/config.h b/inc/config.h
index b9ba67f..b018079 100644
--- a/inc/config.h
+++ b/inc/config.h
@@ -16,7 +16,7 @@
   #define HOVERBOARD_WITH_SOFTWARE_SERIAL_B2_C9_6WORDSENSOR 5

   // thoery says this is the only thing you need to change....
-  #define CONTROL_TYPE HOVERBOARD_WITH_SOFTWARE_SERIAL_B2_C9
+  #define CONTROL_TYPE USART2_CONTROLLED
   //////////////////////////////////////////////////////////

   //////////////////////////////////////////////////////////
@@ -261,12 +261,12 @@
 #endif

 #ifndef INACTIVITY_TIMEOUT
-  #define INACTIVITY_TIMEOUT 8        // minutes of not driving until poweroff. it is not very precise.
+  #define INACTIVITY_TIMEOUT 16        // minutes of not driving until poweroff. it is not very precise.
 #endif

 // ############################### SERIAL DEBUG ###############################

-//#define DEBUG_SERIAL_USART3         // right sensor board cable, disable if I2C (nunchuk) is used!
+#define DEBUG_SERIAL_USART3         // right sensor board cable, disable if I2C (nunchuk) is used!
 //#define DEBUG_SERIAL_SENSOR         // send to USART3 sensor board, without framing, at the CONTROL_SENSOR_BAUD rate
 //#define DEBUG_SERIAL_SERVOTERM
 //#define DEBUG_SERIAL_ASCII          // "1:345 2:1337 3:0 4:0 5:0 6:0 7:0 8:0\r\n"
diff --git a/platformio.ini b/platformio.ini
index 855d598..8a3118b 100644
--- a/platformio.ini
+++ b/platformio.ini
@@ -4,11 +4,11 @@
 [platformio]
 include_dir = inc

-env_default = genericSTM32F103RC
+;env_default = genericSTM32F103RC
 ;env_default = hoverboard
 ;env_default = hoverboard_6word
 ;env_default = control_softwareserial
-;env_default = control_usart2
+env_default = control_usart2
 ;env_default = control_usart3
 ;env_default = control_usart3_ADC

diff --git a/src/comms.c b/src/comms.c
index 47585b3..1062a04 100644
--- a/src/comms.c
+++ b/src/comms.c
@@ -28,7 +28,7 @@ volatile int16_t ch_buf[8];
   volatile SERIAL_USART_BUFFER usart2_it_TXbuffer;
   volatile SERIAL_USART_BUFFER usart2_it_RXbuffer;
 #endif
-#if defined(SERIAL_USART3_IT)
+#if defined(SERIAL_USART3_IT) || defined(DEBUG_SERIAL_USART3)
   volatile SERIAL_USART_BUFFER usart3_it_TXbuffer;
   volatile SERIAL_USART_BUFFER usart3_it_RXbuffer;
 #endif
@@ -107,9 +107,9 @@ void consoleLog(char *message)
     USART_sensorSend(1, (unsigned char *)message, strlen(message), 0);
     #else
       // TODO: Method to select which input is used for Protocol when both are active
-      #if defined(SERIAL_USART2_IT) && !defined(READ_SENSOR)
+      #if defined(DEBUG_SERIAL_USART2) && !defined(READ_SENSOR)
         USART2_IT_send((unsigned char *)message, strlen(message));
-      #elif defined(SERIAL_USART3_IT) && !defined(READ_SENSOR)
+      #elif defined(DEBUG_SERIAL_USART3) && !defined(READ_SENSOR)
         USART3_IT_send((unsigned char *)message, strlen(message));
       #elif !defined(READ_SENSOR) && defined(DEBUG_SERIAL_SENSOR)
         HAL_UART_Transmit_DMA(&huart2, (uint8_t *)message, strlen(message));
@@ -167,7 +167,7 @@ void USART2_IT_IRQ(USART_TypeDef *us) {

 #endif

-#ifdef SERIAL_USART3_IT
+#if defined(SERIAL_USART3_IT) || defined(DEBUG_SERIAL_USART3)

 int USART3_IT_starttx() {
     __HAL_UART_ENABLE_IT(&huart3, UART_IT_TXE);
diff --git a/src/setup.c b/src/setup.c
index fb3ffe7..279225b 100644
--- a/src/setup.c
+++ b/src/setup.c
@@ -78,7 +78,7 @@ void UART_Init() {

   UART_HandleTypeDef huart3;
   huart3.Instance          = USART3;
-  huart3.Init.BaudRate     = DEBUG_BAUD;
+  huart3.Init.BaudRate     = 115200;
   huart3.Init.WordLength   = UART_WORDLENGTH_8B;
   huart3.Init.StopBits     = UART_STOPBITS_1;
   huart3.Init.Parity       = UART_PARITY_NONE;

Disclaimer - I haven't used it for a while.

Richard-Haes-Ellis commented 4 years ago

I'm also getting this warning about the dynamic reconfigure server, perhaps is causing this issue due to the warning? I don't know how the reconfigure server works so I'm not sure.

Here's is a screen shot of the warning Screenshot from 2020-04-30 18-45-40

elector102 commented 4 years ago

Just in case, I am following this issue too. I am using robaka robot to run with it. When I run the following command: roslaunch robaka headlessrobaka.launch I am having the following message.

process[ds4_driver-7]: started with pid [26887]                                                                                                                                                                    
process[ds4_to_imu-8]: started with pid [26888]                                                                                                                                                                    
[ WARN] [1588293204.844542093]: The 'state_publisher' executable is deprecated. Please use 'robot_state_publisher' instead                                                                                         
[ WARN] [1588293204.859076985]: The root link base_footprint has an inertia specified in the URDF, but KDL does not support a root link with an inertia.  As a workaround, you can add an extra dummy link to your 
URDF.                                                                                                                                                                                                              
process[ds4_twist-9]: started with pid [26893]                                                                                                                                                                     
process[twist_mux-10]: started with pid [26894]                                                                                                                                                                    
[ WARN] [1588293205.063801614]: Joint state with name: "left_wheel" was received but not found in URDF                                                                                                             
[INFO] [1588293206.573398]: [hidraw]: Scanning for devices                                                                                                                                                         
[ WARN] [1588293215.064217559]: Joint state with name: "left_wheel" was received but not found in URDF                                                                                                             
[ WARN] [1588293225.084514577]: Joint state with name: "left_wheel" was received but not found in URDF                                                                                                             
[ WARN] [1588293235.104526126]: Joint state with name: "left_wheel" was received but not found in URDF                                                                                                             
[ WARN] [1588293245.124734350]: Joint state with name: "left_wheel" was received but not found in URDF                                                                                                             
[ WARN] [1588293255.164677476]: Joint state with name: "left_wheel" was received but not found in URDF                                                                                                             
[ WARN] [1588293265.164833999]: Joint state with name: "left_wheel" was received but not found in URDF                                                                                                             
[ WARN] [1588293275.205796422]: Joint state with name: "left_wheel" was received but not found in URDF
[ WARN] [1588293285.224325017]: Joint state with name: "left_wheel" was received but not found in URDF
[ WARN] [1588293295.225704748]: Joint state with name: "left_wheel" was received but not found in URDF

If I found the issue/solution I will let you know.

elector102 commented 4 years ago

I believe that maybe my mistake is here. you are using that firmware , or this

elector102 commented 4 years ago

It could be an issue with the URDF, but at the moment, I couldn't found any that is causing that error.

alex-makarov commented 4 years ago

@elector102 I'm using this. From the error messages it seems like your URDF does not contain the wheel joints used in the driver.

alex-makarov commented 4 years ago

@richaeell I'll check the issue with the dynamic_reconfigure but it's unlikely to cause your issue. As you've noticed, the sendSpeedData is being called with the correct parameters, so it must be something down the line.

elector102 commented 4 years ago

@alex-makarov Hi Alex, sorry and Thank you very much! I thought that this issue was related to my issue, I will move my question to the other repo(Robaka repo), I am using the same robaka_v2 xacro that you use. Maybe I am missing something.

elector102 commented 4 years ago

In case I can help, I fixed my issue moving to the last version of hoverboard api and to the last version of hoverboard protocol. Now the hoverboard move both wheels but I still have this message: [ WARN] [1588293215.064217559]: Joint state with name: "left_wheel" was received but not found in URDF It is using the original robaka URDF, if I found the issue I will let you know.

alex-makarov commented 4 years ago

Hey @elector102 , thanks -- actually there was an issue with the URDF that somehow was ignored in older versions of ROS components. Today after I've updated my system I started to get the same warning. The issue was with the joint name, I've just fixed and pushed it.

RichardHaesEllis commented 4 years ago

In case I can help, I fixed my issue moving to the last version of hoverboard api and to the last version of hoverboard protocol. Now the hoverboard move both wheels but I still have this message: [ WARN] [1588293215.064217559]: Joint state with name: "left_wheel" was received but not found in URDF It is using the original robaka URDF, if I found the issue I will let you know.

This fixed the issue, only had to rename the folders to biporpellant and hbprotocol. issue can be closed I think.

Thank you @alex-makarov and @elector102

sebastienvg commented 3 years ago

I have this exact issue where only one wheel turns but check with serial and both turn. I tried the suggested solution but whatever I try I end up with the following

[ 28%] Linking CXX executable /home/robaka/catkin_ws/devel/lib/hoverboard_driver/hoverboard_driver CMakeFiles/hoverboard_driver.dir/src/bipropellant/src/protocolFunctions.c.o: In functionfn_customPing': protocolFunctions.c:(.text+0x6c): undefined reference to millis' CMakeFiles/hoverboard_driver.dir/src/bipropellant/src/hbprotocol/machine_protocol.c.o: In functionprotocol_cobsr_decode': machine_protocol.c:(.text+0x3c): undefined reference to cobsr_decode' CMakeFiles/hoverboard_driver.dir/src/bipropellant/src/hbprotocol/machine_protocol.c.o: In functionprotocol_cobsr_encode': machine_protocol.c:(.text+0xf0): undefined reference to cobsr_encode' collect2: error: ld returned 1 exit status hoverboard-driver/CMakeFiles/hoverboard_driver.dir/build.make:285: recipe for target '/home/robaka/catkin_ws/devel/lib/hoverboard_driver/hoverboard_driver' failed make[3]: *** [/home/robaka/catkin_ws/devel/lib/hoverboard_driver/hoverboard_driver] Error 1 CMakeFiles/Makefile2:3946: recipe for target 'hoverboard-driver/CMakeFiles/hoverboard_driver.dir/all' failed make[2]: *** [hoverboard-driver/CMakeFiles/hoverboard_driver.dir/all] Error 2 CMakeFiles/Makefile2:3958: recipe for target 'hoverboard-driver/CMakeFiles/hoverboard_driver.dir/rule' failed make[1]: *** [hoverboard-driver/CMakeFiles/hoverboard_driver.dir/rule] Error 2 Makefile:1566: recipe for target 'hoverboard_driver' failed make: *** [hoverboard_driver] Error 2 Invoking "make hoverboard_driver -j4 -l4" failed

@RichardHaesEllis @elector102 and @alex-makarov any chance you guys help me with the steps to fix Robaka's broken leg?

alex-makarov commented 3 years ago

@sebastienvg can you describe how you clone the project and build it, so that you're getting this error?

sebastienvg commented 3 years ago

@alex-makarov here are the steps that I have followed:

It's embarrassing not being able to apply the solution that works for you all. Can someone help me find out what am I doing wrong?

Happy Holidays!

elector102 commented 3 years ago

Hi @sebastienvg Sorry for the delay, to that this work correctly I am using from that repo git@github.com:alex-makarov/bipropellant-hoverboard-api.git the commit 251e5fe. I change it manually. I didn't try the last version of that repos to see if it is fixed.

elector102 commented 3 years ago

@sebastienvg Sorry, I am reviewing the code to remember exactly what I did. you need to change another submodule too. hoverboard-driver/src/bipropellant/src/hbprotocol, use that repo https://github.com/alex-makarov/bipropellant-protocol.git and that commit 9383e49

elector102 commented 3 years ago

If you want, you can try that branch https://github.com/elector102/hoverboard-driver/tree/test_comunicaiton

sebastienvg commented 3 years ago

@elector102 I appreciate the help and I will try this today. Also I am a bit confused about the firmware that should be flashed on the hoverboard. There is a link above from @alex-makarov but it doesn't point to a firmware. Are you able to confirm the firmware you are using and the port you are connecting to?

elector102 commented 3 years ago

Hi @sebastienvg sorry for the delay, I am using this firmware: https://github.com/bipropellant/bipropellant-hoverboard-firmware , this is the node to control the overboard in the PC. and the commit hb protocol in the firmware is it 6f9d1bd, just in case, but should be the same that master.