I'm currently trying to get a servo to rotate when I roll my pixhawk past 10 degrees. I have my working code so far and my pixhawk recognizes when I am rolling the device left or right, but instead of rotating left when rolled left, or rotating right when rolled right it end up rotating the same amount to the right side every time, even when rolled left.

What I would like to know is how could I get my servo to rotate to the left instead of the right?

Here is the code I am using to rotate my servo to the left, after this if statement the signal is published to the actuators:

if (roll < -10)


degreechange = m_roll + 10;

rcvalue = degreechange / 180;

acutator.controls[i] = rcvalue;


This should give me a negative rcvalue. If I roll my pixhawk -70 degrees then degreechange will be -60 degrees. Then to turn it in to a value from -1f to 1 I divide by 180, this value is now sent to the actuator.controls[i] and it should then get scaled up by the IO_pass mixer file. Since I am sending a negative value then the pixhawk should move the servo to the left correct?

Am I misunderstanding how the acutator.controls[i] works? Am I sending a wrong float number? or is it a problem with my mixer?

Here is the complete code:

Thank you for the help.

Views: 282

Reply to This

Replies to This Discussion

Could there be another code function I can use to control the servo, for clockwise and counter clockwise motion?

Reply to Discussion



Season Two of the Trust Time Trial (T3) Contest 
A list of all T3 contests is here. The current round, the Vertical Horizontal one, is here

© 2019   Created by Chris Anderson.   Powered by

Badges  |  Report an Issue  |  Terms of Service