In this page, I will explain how to setup MJ-VESC when the high-level controller is based on ROS and communication method is USB.
1. First, run VESC-TOOL (I assume that the motor setup of all the MJ-VESC is already finished)
Connect MJ-VESC ID=0.
2. Connect MJ-VESC ID=1~ using CAN-FORWARD (Setup all the other MJ-VESCs as below in case of ID>=1)
The VESC-TOOL setup is finished.
3. Download attached source code named 'vesc_control_ex1.zip'. You also need vesc library for ROS. Download 'vesc.zip' which is ros driver for MJ-VESC.
4. Unzip and put those folders at your catkin workspace and then build. When you build, you may need dependencies as follows:
You can install above packages like this (when you use 'ros-melodic' then replace 'kinetic' to 'melodic').
5. Run the ROS example using launch file below. Change argument 'port' depend on your condition.
The main function of 'vesc_control_ex1_node.cpp' is as below.
You can test 'SetCurrent', 'SetDutyCycle', 'SetSpeed', 'SetPosition', 'SetBrake', 'SetDPS' by un-commenting each functions. "COMM_SET_DPS" is only valid when you use 'teleop_vesc->custom_cmd_type'.
All the encoder data are stored at 'teleop_vesc->rps[id]' and 'teleop_vesc->rad[id]'. The 'rps' is rad/sec' and The 'rad' is Radian. You can easily use these variables at main function.