Code Monkey home page Code Monkey logo

vesc's Introduction

How to get VESC working with ROS

originally from: https://github.com/mrsd16teamd/loco_car/wiki/VESC

ROS drivers for the VESC are provided by the MIT RACECAR team:

https://github.com/mit-racecar/vesc

After cloning, you might need to install the ros serial package for it to compile.

sudo apt-get install ros-indigo-serial

Once installed, catkin_make

The vesc_driver package establishes a connection to the VESC via UART.

Be sure to check the default port in the launch file: roscd vesc_driver/launch

Edit the vesc_driver_node.launch file. Once done, do roslaunch vesc_driver vesc_driver_node.launch

Now, do a rostopic list and you will be able to see several topics be published/listened on

  • /commands/motor/brake
  • /commands/motor/current
  • /commands/motor/duty_cycle
  • /commands/motor/position
  • /commands/motor/speed
  • /commands/servo/position
  • /sensors/core
  • /sensors/servo_position_command
Do a rostopic echo /sensors/core to view certain sensor information like:

state:

  • voltage_input: 12.0
  • temperature_pcb: 28.7
  • current_motor: -0.06
  • current_input: 0.0
  • speed: -193.0
  • duty_cycle: -0.014
  • charge_drawn: 18.0
  • charge_regen: 0.0
  • energy_drawn: 223.0
  • energy_regen: 2.0
  • displacement: -2077.0
  • distance_traveled: 16301.0
  • fault_code: 0
ext, we can publish on the /commands/motor/speed topic to execute RPM commands. From the CLI, you can do:

rostopic pub -r 20 /commands/motor/speed -- std_msgs/Float64 -200

The syntax is rostopic pub --args

In this case, the -r 20 argument makes it publish at a constant rate of 20Hz, the -- after the topic is needed to specify that there are no further arguments so that it can parse negative values correctly.

This will cause the wheel to spin at -200 RPM, given that the VESC motor params have be set correctly with the BLDC_Tool.

Servo command:

rostopic pub -r 20 /commands/servo/position -- std_msgs/Float64 45

servo command value range is still unknown...

Getting odometry from the VESC

roslaunch vesc_ackermann vesc_to_odom_node.launch

Launch will fail, as we need to specify 5 rosparams:

  • speed_to_erpm_gain
  • speed_to_erpm_offset
  • steering_angle_to_servo_gain
  • steering_angle_to_servo_offset
  • wheelbase
These can be set manually via CLI by running: rosparam set speed_to_erpm_gain -1664

erpm gain of -1664 is what the VESC + MST is currently tuned for. offset should be 0, may go back to investigate whether we can use this to account for steady-state error

TODO: set the rosparams from the .launch file, using a .xml list

once these params are set, the node should launch properly. The node publishes on the /odom_vesc topic a nav_msgs/Odometry message.

If you echo it, it will be empty, until you publish on BOTH the /commands/motor/speed and /commands/servo/position topics.

rostopic echo /odom_vesc --noarr

It will also publish a transform from base_link to the odom frame.

Steering Mapping

steering_angle_to_servo_gain = 1 steering_angle_to_servo_offset = 0.22

vesc's People

Contributors

renanmb avatar

Stargazers

 avatar

Watchers

James Cloos avatar  avatar

Forkers

saumya-kushwaha

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.