Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PID controller for tests #363

Merged
merged 7 commits into from
Aug 10, 2015
Merged

PID controller for tests #363

merged 7 commits into from
Aug 10, 2015

Conversation

TSC21
Copy link
Member

@TSC21 TSC21 commented Aug 7, 2015

This implements a PID controller so it can be used on velocity control when sending velocity setpoints to the FCU when issuing a offboard control test. Now the velocity is much more smoother and doesn't overshoot cause it's effort is firstly computed on mavros side before sending to the FCU.
Also added usage to test_setup, previously named test_type.

@vooon
Copy link
Member

vooon commented Aug 7, 2015

There several issues with test_mavros packages:

  1. Bad names for libraries. Just do catkin config --install and after build look inside install/lib directory.
  2. Why different library for PID?
  3. Why PID instances from PIDControler is outside from class?

In my opinion all that stuff may be written more easy...

@TSC21
Copy link
Member Author

TSC21 commented Aug 7, 2015

Bad names for libraries. Just do catkin config --install and after build look inside install/lib directory.

OK I'll review this.

Why different library for PID?
Why PID instances from PIDControler is outside from class?

Well those are not issues as you say. A different lib for the controller cause it's a util and I'm expecting to move this to mavros utils instead of this just existing for test uses. The PID instances it's because I was having problems with the library links on those. If I put them inside the class it gives me a library problem, saying it's not declared, so this was the only solution I found.

@TSC21
Copy link
Member Author

TSC21 commented Aug 7, 2015

@vooon after configuring install space and build it, I can't find any lib related to test_mavros. Can you point out the reason?

@TSC21
Copy link
Member Author

TSC21 commented Aug 7, 2015

Update: I removed pid_controller as a lib, and have this in CmakeLists.txt:

## Declare a cpp library
add_library(
  sitl_test
  sitl_test/lib/sitl_test.cpp
  sitl_test/lib/pid_controller.cpp
)

## Declare a cpp executable
add_executable(
  sitl_test_node
  sitl_test/sitl_test_node.cpp
)

## Add cmake target dependencies of the executable/library
## as an example, message headers may need to be generated before nodes
add_dependencies(
  sitl_test_node
  sitl_test
)

## Specify libraries to link a library or executable target against
target_link_libraries(
  sitl_test
  ${Boost_LIBRARIES}
  ${catkin_LIBRARIES}
)

target_link_libraries(
  sitl_test_node
  sitl_test
)

and moved the variables inside the class (on pid_controller.h) as:

    // Control toolbox PID controllers
    static control_toolbox::Pid pid_linvel_x;
    static control_toolbox::Pid pid_linvel_y;
    static control_toolbox::Pid pid_linvel_z;
    static control_toolbox::Pid pid_yaw_rate;

    // PID values
    static std::array<double, 3> linvel_pid;
    static std::array<double, 3> yawrate_pid;

    // Min/max bounds for the integral windup
    static double yawrate_imax;
    static double yawrate_imin;
    static double linvel_imax;
    static double linvel_imin;

But then I'm getting these errors when building:

[100%] Building CXX object CMakeFiles/sitl_test_node.dir/sitl_test/sitl_test_node.cpp.o
Linking CXX executable /home/nuno/AIMAV_Project/devel/lib/test_mavros/sitl_test_node
/home/nuno/AIMAV_Project/devel/lib/libsitl_test.so: undefined reference to `pidcontroller::PIDController::linvel_imin'
/home/nuno/AIMAV_Project/devel/lib/libsitl_test.so: undefined reference to `pidcontroller::PIDController::pid_linvel_x'
/home/nuno/AIMAV_Project/devel/lib/libsitl_test.so: undefined reference to `pidcontroller::PIDController::linvel_pid'
/home/nuno/AIMAV_Project/devel/lib/libsitl_test.so: undefined reference to `pidcontroller::PIDController::pid_linvel_z'
/home/nuno/AIMAV_Project/devel/lib/libsitl_test.so: undefined reference to `pidcontroller::PIDController::yawrate_pid'
/home/nuno/AIMAV_Project/devel/lib/libsitl_test.so: undefined reference to `pidcontroller::PIDController::linvel_imax'
/home/nuno/AIMAV_Project/devel/lib/libsitl_test.so: undefined reference to `pidcontroller::PIDController::yawrate_imin'
/home/nuno/AIMAV_Project/devel/lib/libsitl_test.so: undefined reference to `pidcontroller::PIDController::yawrate_imax'
/home/nuno/AIMAV_Project/devel/lib/libsitl_test.so: undefined reference to `pidcontroller::PIDController::pid_yaw_rate'
/home/nuno/AIMAV_Project/devel/lib/libsitl_test.so: undefined reference to `pidcontroller::PIDController::pid_linvel_y'
collect2: error: ld returned 1 exit status
make[2]: *** [/home/nuno/AIMAV_Project/devel/lib/test_mavros/sitl_test_node] Error 1
make[1]: *** [CMakeFiles/sitl_test_node.dir/all] Error 2
make: *** [all] Error 2

@TSC21
Copy link
Member Author

TSC21 commented Aug 7, 2015

I got a workaround by instantiating an object of class PIDController and used it on offboard_controller.h. Also removed pid_controller as a lib for now as it's not really needed as a lib.

vooon added a commit that referenced this pull request Aug 10, 2015
@vooon vooon merged commit 657c3d9 into mavlink:master Aug 10, 2015
@vooon vooon added this to the Version 0.14 milestone Aug 10, 2015
@TSC21 TSC21 deleted the velocity_controller branch August 11, 2015 13:42
@vooon vooon mentioned this pull request Aug 13, 2015
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants