Skip to content

Instantly share code, notes, and snippets.

@patrickelectric
Created January 29, 2025 17:27
Show Gist options
  • Save patrickelectric/54fbb7d5afdac83619c089d68ab55f98 to your computer and use it in GitHub Desktop.
Save patrickelectric/54fbb7d5afdac83619c089d68ab55f98 to your computer and use it in GitHub Desktop.
Individual motor control

Individual motor control

ROS

  1. Configure servo\d_function to RC_IN, one for each channel

IQboSywxAiTgRiJeoO55--ixADaCd7ujxmmWNy7KzFo=

  1. Restart the autopilot after configuring all parameters, can be done when changing the last parameter or via the Autopilot Firmware page

PqFqV0wPqPYyvQabdVibR-ONDo5QVbPxGE-ANixUOcA= 1Uv4OguRh79zx6e6FIy1A77F5LjcjxQzZHxIb5GHUxU=

  1. Install and open the ROS extension

eq0orYDDdUzJwgJhKHvuwX8GZJ5fo-sNGaL56XgbXRs= aEYQI6f23CXZVPJGxaBmp-ngHOp7Ndb8BBnz61QHUDU=

  1. Select the bottom left corner terminal, hit control-c, and change the fcu_url adding the "ids" parameter, will look something like this:

    while true; do sleep 10; /ros_entrypoint.sh roslaunch mavros apm.launch fcu_url:=tcp://0.0.0.0:5777@/?ids=255,240; done

Note the "/?ids=255,240", this will change the system_id and component_id of mavros to operate as a ground control station. This is necessary for MANUAL_CONTROL and RC_OVERRIDE to work.

  1. Select the bottom right corner terminal and hit ctrl-b " space this will split the terminal in two vertically. You can also right click the terminal and click in vertical split.

A7cgWyaiyP5lZWdQf_api6LKaQRzFNwyURtHo33zp1o=

  1. On the first terminal, run: `/ros_entrypoint.sh rostopic pub -r 10 /mavros/rc/override mavros_msgs/OverrideRCIn '[1600, 1575, 1550, 1450, 1425, 1400, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]'`. This will publish different values per motor.
  2. To see the published values, you can run the following command on the second terminal. /ros_entrypoint.sh rostopic echo /mavros/rc/out

dvPpMVS0fToduzvCaIaQuoxqzMdppYw51HZ_hAFwow8=

  1. On cockpit, you can configure multiple mini widgets, one per motor.

tE_lN5rTuYe3DT-amPP3vSfTdzCOoJEcrsCbNV23q1s= vKbCaOtv6yyCFBS5xOQXGWyStatZ2lQnd_mPMg71Tpc= NaFqUqXfr6qm9TD6sfx4KYyuadO5Go4XTUZ8pJlIBro=

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment