Request for Help – Sending PWM with MAVROS but Motors Are Not Moving

Request for Help – Sending PWM with MAVROS but Motors Are Not Moving

Hello,

I am developing a six-motor underwater vehicle using Jetson Nano Orin 8GB and Pixhawk Cube Orange. I have installed the ArduSub firmware via QGroundControl, but I am not sure which version I am using. I have successfully established a connection with MAVROS and can perform some basic operations.

1. Issues I Am Facing

1.1 – ARM Operation is Successful, but Motors Are Not Moving

  • I can ARM the vehicle using the following command:
rosservice call /mavros/cmd/arming "value: true"
  • QGroundControl shows the “Armed” status.
  • However, when I send PWM signals to the motors, they do not move.

1.2 – Motors Work in STABILIZE and ACRO Modes

  • When switching to STABILIZE and ACRO modes, the motors start moving.
  • This suggests that there is no hardware issue.

1.3 – Unable to Switch to GUIDED Mode

  • When I try to change the mode using the following command, the mode does not switch:
rosservice call /mavros/set_mode "{base_mode: 0, custom_mode: 'GUIDED'}"
  • Even when changing the mode through QGroundControl, I cannot switch to GUIDED mode.
  • Does ArduSub support GUIDED mode?

1.4 – Sending PWM Override via MAVROS, but Motors Are Not Responding

  • I send PWM signals using the following command:
rostopic pub /mavros/rc/override mavros_msgs/OverrideRCIn "[1500, 1600, 1500, 1500, 1500, 1500, 0, 0]"
  • When I check the output of rostopic echo /mavros/rc/override, the signals seem to change, but the motors do not respond.

1.5 – Not Sure Which Mode to Use for My Python Script

  • I want to send commands to the motors using MAVROS with Python.
  • However, I am unsure which mode I should be in.
  • Could the issue be that my Python script is not working properly because I cannot switch to GUIDED mode?

2. Hardware and Software I Am Using

  • Jetson Nano Orin 8GB
  • Pixhawk Cube Orange
  • ArduSub (Version unknown, installed via QGroundControl)
  • MAVROS (Running on ROS Noetic, Ubuntu 20.04)

3. Assistance Requested

  1. Do I need to configure additional settings for the motors to work when using PWM override?
  2. Does ArduSub support GUIDED mode? If not, which mode should I use instead?
  3. Why do the motors work in STABILIZE and ACRO modes but not in other modes?
  4. Which flight mode is the most suitable for running my Python script?

I would greatly appreciate any help. Thank you in advance!

1 Like

Hi @beyza
Happy to help!
Guided (and Auto) mode can only be enabled if the vehicle has a position source, like a GPS (at the surface) or a DVL / underwater GPS.

How are you sending PWM signals? I’d guess that you’re not using the correct method if the motors don’t respond. Typically, rather than control individual motors, mavlink commands to simulate user joystick input are how a vehicle is moved via external control sources.

The Stabilize and Acro modes are moving the motors because they are trying to hold the orientation of the vehicle. If the directions are not configured correctly, this will result in the vehicle “going crazy” when armed and in the water.

It’s tough to know which flight mode is best without knowing your application goals!

Hello,

First of all, thank you for your response!

We will not be using the Guided mode because our vehicle does not have GPS or DVL sensors for positioning. Our goal is to make our underwater vehicle follow a specific line. Our line detection algorithm is ready, but we are trying to determine which flight mode would be the best fit for this task.

Currently, we have observed that the motors work in STABILIZE and ACRO modes, but we are unsure which mode would be the most suitable for our application. For example, should we use MANUAL, DEPTH HOLD, or POSITION HOLD mode to ensure the vehicle maintains its direction and executes the necessary movements for line following? Or would you suggest a different approach?

Additionally, we would appreciate any insights on potential configuration issues that might be causing the motors to not respond when sending PWM signals via MAVROS.

Thank you in advance for your help!

Hi @beyza -
You’ll likely want Stabilize or Depth hold mode for your application - these control the vehicles orientation and maintain the same compass heading when user input is not applied. The only difference between the two modes is the obvious one - depth hold keeps the vehicle at its current depth, which can be adjusted by the user.

Assuming your “line detection” system provides an output that could be translated into joystick control (turn left, turn right, go forward, etc.), you can send mavlink messages via pymavlink. You may be best off commanding a compass heading, and then simulating forward and reverse throttle for best performance. If our line is straight, the ROV will easily maintain the compass heading required instead of the slower response time of your own script.

As mentioned, sending PWM signals is not the best approach for this.

Hello,

Thank you for your suggestion. I want to send speed commands to the motors using MAVROS. What alternative method can I use instead of PWM?

For example, should I use a topic like cmd_vel for speed control via MAVROS? If so, which topic should I use, and what message format should I send the speed commands in?

Also, can I use cmd_vel without position information? Our system does not have any positioning sensors like GPS or DVL.

Lastly, if ArduSub does not support GUIDED mode, which mode would be the most suitable for speed control via MAVROS?

Thanks!

Hi @beyza
@patrickelectric developed this gist to explain individual motor control. As mentioned, you can also send joystick inputs or cmd_vel if he you have a position system on the vehicle and are using under guided mode…

Hello Tony,

We are working on an underwater vehicle (ROV) project using Jetson Nano and ArduSub. I am controlling my motors via MAVROS. When I switch to Stabilize mode, the motors move, so there is no hardware issue. However, when I run my Python code, the motors do not move.

My vehicle does not have a DVL or GPS; it only has the IMU inside the Pixhawk and a depth sensor. I noticed that you previously suggested as if I had a DVL and GPS, but these sensors are not available on my setup.

Which MAVROS mode should I use to make my motors move when running my Python code? What should I consider in my code to control the motors using only the IMU and depth sensor?

Thanks!

Hi @beyza -
Your response feels like that of an LLM AI!
Please review the link provided to the gist in my previous response, it details how to accomplish what you are asking…

1 Like

Hi @tony-white

Thank you. We were able to successfully implement the individual motor control in the GitHub link you shared.

Now I am wondering: Can my vehicle perform autonomous tasks via BlueOS?

Also, how can we transfer the ROS code we wrote to Raspberry Pi via BlueOS?

I want to completely remove the Ethernet cable and have the system perform tasks on its own (completely autonomously). Is this possible? If possible, how should I proceed?

Finally, do I need to use the ROS terminal in the BlueOS interface to run the Python file I wrote?

Hi @beyza
There’s a lot to unpack with your questions!

The BlueROV2 can operate in Auto mode, if the autopilot (ArduSub) is receiving a valid position estimate - from a GPS at the surface, or a DVL / USBL. This is documented and fairly straightforward, but has nothing to do with ROS - the autopilot could receive missions and be controlled by ROS, but ROS would not be “in the driver’s seat.”

There are a couple ROS extensions available, my understanding of them is they make the vehicle itself addressable in the ROS interface, but generally myself and the Blue Robotics have interacted very little with ROS (and have little interest in using it for anything…)

Users have definitely run the BlueROV2 without a tether, via several approaches. The most common is connecting to the vehicle via its WiFi hotspot, uploading a mission to the autopilot, and triggering it - ensuring the last step is for the vehicle to return to the surface!

The ROS terminal is likely not the best place to run your python file. If you’re debugging, you can do so from the terminal, after taking the red-pill. If it is a piece of code you’re wanting to deploy and use more easily, you may want to package it as an extension.