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

make vesc_driver work with latest VESC firmware 3.38 #13

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

erwincoumans
Copy link

(copy datatypes.h and update vesc_packet.cpp with new layout)
also use /dev/ttyACM0 by default, since that is what TX2 uses

This fixes Issue #11

(copy datatypes.h and update vesc_packet.cpp with new layout)
also use /dev/ttyACM0 by default, since that is what TX2 uses
@christopherkao
Copy link

Would love to see this work out! Using the TX2 here at F1/10 with the VESC on firmware 2.18 and am often getting the "failed to connect to the VESC" error: https://mit-racecar.github.io/2017/01/01/faq/

@mboulet
Copy link
Contributor

mboulet commented Jun 29, 2018

Thanks - sorry for the delay. On travel but will review when I return this weekend.

@erwincoumans
Copy link
Author

erwincoumans commented Jun 29, 2018

Thanks - sorry for the delay.

No hurry. This pull request will make it work with VESC firmware 3.38 but it won't work with firmware 2.18 anymore. If needed/wanted, perhaps we can make it work with both firmwares, or create a branch for old/new?

Would love to see this work out!

"failed to connect to the VESC" may be due to different assigned USB (/dev/ttyUSB0/1/2 or /dev/ttyACM0/1/2)?

Also, you need to add some delay if this connection failure happens at boot time, when the USB may not be fully initialized, when you start your racecar/vesc service.

I added 20 seconds sleep to my racecar.service file and it works much better (under /lib/systemd/system or /etc/systemd/system)

[Unit]
Description=Racecar

[Service]
ExecStartPre=/bin/sleep 20
Type=oneshot
ExecStart=/usr/bin/racecar-start

[Install]
WantedBy=multi-user.target

@christopherkao
Copy link

I think it would be fine to make it work with 3.38 and not 2.18. It is pretty trivial to upgrade to 3.38 using BLDC Tool or VESC tool. Sometimes the VESC works on 2.18 and sometimes I get the "failed to connect to VESC" error. I unplug power and unplug usb, which sometimes solves the problem, most of the time doesn't. I am using the VESC with a USB hub, so perhaps that may be the issue? Using the serial Github library per the f1tenth.org instructions: https://github.com/wjwwood/serial.

@mboulet
Copy link
Contributor

mboulet commented Aug 2, 2018

@erwincoumans It seems the FOCBOX ESC is shipping with the 2.18 firmware. While I agree that it is easy to upgrade the firmware, I think it is important to support shipping hardware without additional steps. I think the long-term goal is to support multiple firmware versions. I'll work on incorporating such functionality with other improvements to to driver (such as documentation). But for now, would you consider submitting the pull request to the fw338 branch?

@steffensol
Copy link

steffensol commented Aug 8, 2018

If you do happen to push to the new branch Erwin, i would like to ask if you could add the byte-locations for the last packets as well? Perhaps it could be a possibility of sorting the file based on byte location as well.

double VescPacketValues::temp_pcb() const
{
  int32_t v = 0;
  return static_cast<double>(v);
}

double VescPacketValues::watt_hours() const
{
  int32_t v = 0;
  return static_cast<double>(v);
}

double VescPacketValues::watt_hours_charged() const
{
  int32_t v = 0;
  return static_cast<double>(v);
}

Change into;

 double VescPacketValues::temp_pcb() const
 {
   int16_t v = static_cast<int16_t>((static_cast<uint16_t>(*(payload_.first + 1)) << 8) +
                                    static_cast<uint16_t>(*(payload_.first + 2)));
   return static_cast<double>(v) / 10.0;
 }
 
 double VescPacketValues::watt_hours() const
 {
 
   int32_t v = static_cast<int32_t>((static_cast<uint32_t>(*(payload_.first + 37)) << 24) +
                                    (static_cast<uint32_t>(*(payload_.first + 38)) << 16) +
                                    (static_cast<uint32_t>(*(payload_.first + 39)) << 8) +
                                    static_cast<uint32_t>(*(payload_.first + 40)));
   return static_cast<double>(v);
 }
 
 double VescPacketValues::watt_hours_charged() const
 {
   int32_t v = static_cast<int32_t>((static_cast<uint32_t>(*(payload_.first + 41)) << 24) +
                                    (static_cast<uint32_t>(*(payload_.first + 42)) << 16) +
                                    (static_cast<uint32_t>(*(payload_.first + 43)) << 8) +
                                    static_cast<uint32_t>(*(payload_.first + 44)));
   return static_cast<double>(v);
 }

@subodh-malgonde
Copy link

subodh-malgonde commented Sep 17, 2018

@erwincoumans Will this work without any changes to the configuration files at hardware/vesc?

@mboulet Maytech VESCs ship with firmware 3.30 as of today.

UPDATE: I tested the code in the PR with HW 4.12 and FW 3.40. It works fine.

@MrDadaGuy
Copy link

Hi all,

I have HW 4.12 and FW 3.40, but I can't get it to work. I cloned this repo, then I made the changes to datatypes.h and vesc_packet.cpp, but it still does not work for me. It does build successfully, but when I run I get this:
[ERROR] [1540226400.360175373]: Out-of-sync with VESC, discarding 2 bytes. terminate called after throwing an instance of 'serial::SerialException' what(): SerialException device reports readiness to read but returned no data (device disconnected?) failed. .
VESC has blue and green LED. Configuration was successfully using VESC Tool (from ubuntu workstation) and I'm running on TX2 -- I've not been able to have any success from TX2 yet.

@subodh-malgonde
Copy link

When you say you cloned 'this repo', which repo do you mean? You just need to clone @erwincoumans 's repository which is https://github.com/erwincoumans/vesc. Then you don't need to make any changes to any of the files. I am also using HW 4.12 and FW 3.40. It works well for me.

@raess1
Copy link

raess1 commented Oct 23, 2018

@MrDadaGuy
If you want you can try our modified FW 3.33, Rros-driver and pyvesc.
We implemented multi-turn position control with speed settings.

ROS test video:
https://www.youtube.com/watch?v=iflbHGTBwwo
https://www.youtube.com/watch?v=lDOAy9ZJrX0

https://github.com/raess1/Vesc-ROS-FW-3.33
https://github.com/raess1/vesc-FW
https://github.com/raess1/PyVESC-FW3.33

BTW: We based the modification on FW3.33, since we could not get the encoder (AS5048A) via SPI & HW pins to work on newer versions. :(

Cheers

@MarcusFutterlieb
Copy link

Hi all,

I have HW 4.12 and FW 3.40, but I can't get it to work. I cloned this repo, then I made the changes to datatypes.h and vesc_packet.cpp, but it still does not work for me. It does build successfully, but when I run I get this:
[ERROR] [1540226400.360175373]: Out-of-sync with VESC, discarding 2 bytes. terminate called after throwing an instance of 'serial::SerialException' what(): SerialException device reports readiness to read but returned no data (device disconnected?) failed. .
VESC has blue and green LED. Configuration was successfully using VESC Tool (from ubuntu workstation) and I'm running on TX2 -- I've not been able to have any success from TX2 yet.

Hi @MrDadaGuy ,

I had the issue before and it was because the battery was not charged properly (you can get a better analysis with the help of the BLDC tool --> Realtime Data --> Activate sampling).

Good luck!

@Scottapotamas
Copy link

@MarcusFutterlieb I've been having the same issues with this PR (FW3.40) but I don't think its battery related. I've got a 48V powersupply running on mains, and even using the VESC tool has these issues which cause dropouts. There isn't any voltage sag on the supply, and I don't really get any visible errors other than the link drop.

For me, I'm able to run for anywhere between a few seconds/minutes and then eventually this happens and the connection is lost -> shutdown.

@ncnynl
Copy link

ncnynl commented Jan 20, 2019

Hi, all

I have the issue like this :

rocess[vesc/vesc_driver-15]: started with pid [2823]
process[vesc/vesc_to_odom-16]: started with pid [2836]
process[vesc/throttle_interpolator-17]: started with pid [2846]
process[imu_node-18]: started with pid [2859]
terminate called after throwing an instance of 'serial::SerialException'
what(): SerialException device reports readiness to write but returned no data (device disconnected?) failed.
[vesc/vesc_driver-15] process has died [pid 2823, exit code -6, cmd /home/ubuntu/racecar-ws/devel/lib/vesc_driver/vesc_driver_node __name:=vesc_driver __log:=/home/ubuntu/.ros/log/ba525a30-fdb7-11e8-97dd-00044bc49637/vesc-vesc_driver-15.log].
log file: /home/ubuntu/.ros/log/ba525a30-fdb7-11e8-97dd-00044bc49637/vesc-vesc_driver-15*.log

I get it run in tx2 with hardware is 4.12 and firmware is 3.40
I set up the car and the wheels didn't touch the ground. It worked very well.
When I put the car on the ground, it is easy to get an abnormal situation when the control runs back and forth.
I still not fix it .

@sourajitdas
Copy link

PLEASE HELP!!! I am facing the same issue of Out-of-sync error.

I'm working on designing a fleet of F1/10 cars for my project. The first two cars were designed using the FOCBox and VESC 6 MKII. These cars are running perfectly fine. The 3rd, 4th and 5th car are designed using the VESC 6+. These 3 cars have given me trouble with the Out-of-sync error. I tried numerous alternatives to get rid of the error but none of them worked. The company changing the version of the VESCs pretty fast has also been a matter of concern but using VESC 6+ for the remaining cars is the only option I have with me now.

P.S

  1. I flashed the Jetson using JetPack 3.3
  2. I use VESC Tool 2.2 and firmware 4.1
    I cloned the repository of the MIT Racecar project. I followed Jim's tutorials for most of the car setup. I even updated the drivers for the VESC 6 from the MIT Racecar repository.

Any help would be appreciated. Thank you.

@jasilberman
Copy link

Fellows, hello from San Diego, CA.

I hope this is the right place to post this.
Like @sourajitdas, I have been working with different versions of VESC hardware.

Is there work to make vesc_driver for the latest firmware? Firmware V4.x (4.2)?
If feasible, maybe make vesc_driver for each major release?

The VESC Tools along with the latest firmware has some really nice feature to detect the motor parameters. I imagine it is going just to make better.

Thank you,
-Jack

@jasilberman
Copy link

PLEASE HELP!!! I am facing the same issue of Out-of-sync error.

I'm working on designing a fleet of F1/10 cars for my project. The first two cars were designed using the FOCBox and VESC 6 MKII. These cars are running perfectly fine. The 3rd, 4th and 5th car are designed using the VESC 6+. These 3 cars have given me trouble with the Out-of-sync error. I tried numerous alternatives to get rid of the error but none of them worked. The company changing the version of the VESCs pretty fast has also been a matter of concern but using VESC 6+ for the remaining cars is the only option I have with me now.

P.S

  1. I flashed the Jetson using JetPack 3.3
  2. I use VESC Tool 2.2 and firmware 4.1
    I cloned the repository of the MIT Racecar project. I followed Jim's tutorials for most of the car setup. I even updated the drivers for the VESC 6 from the MIT Racecar repository.

Any help would be appreciated. Thank you.

Have you solved your issues?

@sourajitdas
Copy link

PLEASE HELP!!! I am facing the same issue of Out-of-sync error.
I'm working on designing a fleet of F1/10 cars for my project. The first two cars were designed using the FOCBox and VESC 6 MKII. These cars are running perfectly fine. The 3rd, 4th and 5th car are designed using the VESC 6+. These 3 cars have given me trouble with the Out-of-sync error. I tried numerous alternatives to get rid of the error but none of them worked. The company changing the version of the VESCs pretty fast has also been a matter of concern but using VESC 6+ for the remaining cars is the only option I have with me now.
P.S

  1. I flashed the Jetson using JetPack 3.3
  2. I use VESC Tool 2.2 and firmware 4.1
    I cloned the repository of the MIT Racecar project. I followed Jim's tutorials for most of the car setup. I even updated the drivers for the VESC 6 from the MIT Racecar repository.

Any help would be appreciated. Thank you.

Have you solved your issues?

Unfortunately Nopes my friend. Let me know if you get any leads. Thanks in advance.

@suprnrdy
Copy link

PLEASE HELP!!! I am facing the same issue of Out-of-sync error.
I'm working on designing a fleet of F1/10 cars for my project. The first two cars were designed using the FOCBox and VESC 6 MKII. These cars are running perfectly fine. The 3rd, 4th and 5th car are designed using the VESC 6+. These 3 cars have given me trouble with the Out-of-sync error. I tried numerous alternatives to get rid of the error but none of them worked. The company changing the version of the VESCs pretty fast has also been a matter of concern but using VESC 6+ for the remaining cars is the only option I have with me now.
P.S

  1. I flashed the Jetson using JetPack 3.3
  2. I use VESC Tool 2.2 and firmware 4.1
    I cloned the repository of the MIT Racecar project. I followed Jim's tutorials for most of the car setup. I even updated the drivers for the VESC 6 from the MIT Racecar repository.

Any help would be appreciated. Thank you.

Have you solved your issues?

Unfortunately Nopes my friend. Let me know if you get any leads. Thanks in advance.

I wasn't able to get my VESC 4.12 working with the latest firmware, so I had to reflash my VESC to firmware version 3.01. Not sure why but I stopped trying to figure it out. I was using the FLIPSKY VESC found on Amazon for reference.

@jasilberman
Copy link

jasilberman commented Apr 28, 2020

Not sure this is the right place to discuss this. I have been playing with it since yesterday afternoon.

I like the new VESC Tool to detect the motor parameters. It seems when an older firmware (V3.x) is loaded in the VESC HW V4.12, an one is is using the latest VESC Tool, the cool FOC motor detection wont work. The latest version of i.e., VESC Tool 2.05, has firmware 5.1 on it. But, I can't find firmware 5.1 VESC_servoout.bin. Yes, I selected Show non-default firmware. Go figure ...

I had a copy of VESC Tool 2.03 that has firmware 4.2 with VESC_servoout.
I am going to try to make firmware v4.2 VESC_servoout with the modifications above on vesc_driver to see if it will play nice.

One can get a VESC HW V4.12 out of Banggoo these days for less than US$60. That makes it nice for a classroom environment where one needs to buy dozens of these.
So the time spent making it work can help lots people in education.

I wish we could have a release of the vesc_driver (ROS) for each major release of the VESC firmware. It would help. I know we are all busy. Not sure anyone is listening...

Thanks,
-Jack

@sourajitdas
Copy link

Not sure this is the right place to discuss this. I have been playing with it since yesterday afternoon.

I like the new VESC Tool to detect the motor parameters. It seems when an older firmware (V3.x) is loaded in the VESC HW V4.12, an one is is using the latest VESC Tool, the cool FOC motor detection wont work. The latest version of i.e., VESC Tool 2.05, has firmware 5.1 on it. But, I can't find firmware 5.1 VESC_servoout.bin. Yes, I selected Show non-default firmware. Go figure ...

I had a copy of VESC Tool 2.03 that has firmware 4.2 with VESC_servoout.
I am going to try to make firmware v4.2 VESC_servoout with the modifications above on vesc_driver to see if it will play nice.

One can get a VESC HW V4.12 out of Banggoo these days for less than US$60. That makes it nice for a classroom environment where one needs to buy dozens of these.
So the time spent making it work can help lots people in education.

I wish we could have a release of the vesc_driver (ROS) for each major release of the VESC firmware. It would help. I know we are all busy. Not sure anyone is listening...

Thanks,
-Jack

I asked for help on jetsonhacks.com as well but no reply as such. The link is below https://www.jetsonhacks.com/2017/06/01/get-your-motor-running-vesc-jetson-racecar-build/
Would you mind a chat to collaborate or discuss about the issue and try possible solutions? If yes feel free to email me at sourajit19@gmail.com. Thank you.

@jasilberman
Copy link

For all, sorry to hijack this thread. Gitbhub went away with the personal messages.
Last one for now.

@sourajitdas e-mail sent. I wonder if you work with Professor Rahul Mangharam at UPenn.

Jim from JetsonHacks is a super cool guy. I am sure there is something in the way for him not replying. Maybe he missed the post.
Lets follow-up on e-mail and if we make things work we share back to the community and with Jim.
Talk to you soon.
Jack

@jasilberman
Copy link

Did I say it was my last post above? How about one more?

VESC HW4.12.
At this point I am using VESC Tool V2.03. It supplies the latest firmware that I could find that has VESC_servoout.bin. As of 28Apr20, the latest VESC Tool is 2.05.  It has firmware 5.1. I don’t see vesc_servoout.bin available with it...

I uploaded firmware V4.2 VESC_servoout.bin to the VESC HW 4.12
The BLDC sensored motor was detected without problems.

Need to use this repository to build the vesc_driver into the ROS
This is how you can do it. Adjust your paths accordingly
ssh to the jetson

cd ~/projects/f110/f110_ws/src/f110_system
rm -rf vesc
git clone https://github.com/erwincoumans/vesc
cd ~/projects/f110/f110_ws
catkin_make
source devel/setup.bash

No errors during the catkin_make ...
That is all.

A quick test with your robot framework with the joystick should do it
ex using F1/10. On a terminal tab

source devel/setup.bash
roscore

Another terminal tab
roslaunch racecar teleop.launch

I had to adjust the axis of my joystick
~/projects/f110/f110_ws/src/f110_system/racecar/racecar/config/racecar-v2/joy_teleop.yaml

I changed the axis to map the jstest I ran
     
axis: 4        target: drive.speed                    
axis: 0        target: drive.steering_angle

@PatRocks99
Copy link

Hi, all

I have the issue like this :

rocess[vesc/vesc_driver-15]: started with pid [2823] process[vesc/vesc_to_odom-16]: started with pid [2836] process[vesc/throttle_interpolator-17]: started with pid [2846] process[imu_node-18]: started with pid [2859] terminate called after throwing an instance of 'serial::SerialException' what(): SerialException device reports readiness to write but returned no data (device disconnected?) failed. [vesc/vesc_driver-15] process has died [pid 2823, exit code -6, cmd /home/ubuntu/racecar-ws/devel/lib/vesc_driver/vesc_driver_node __name:=vesc_driver __log:=/home/ubuntu/.ros/log/ba525a30-fdb7-11e8-97dd-00044bc49637/vesc-vesc_driver-15.log]. log file: /home/ubuntu/.ros/log/ba525a30-fdb7-11e8-97dd-00044bc49637/vesc-vesc_driver-15*.log

I get it run in tx2 with hardware is 4.12 and firmware is 3.40 I set up the car and the wheels didn't touch the ground. It worked very well. When I put the car on the ground, it is easy to get an abnormal situation when the control runs back and forth. I still not fix it .

I am having the same issue. Would love to know if you ever found a solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.