GithubHelp home page GithubHelp logo

masterrobotica-uvic / copter_arm_robot Goto Github PK

View Code? Open in Web Editor NEW
12.0 5.0 37.0 44 KB

Project designed to learn PID control, relying on ros_control + gazebo for sim/real scenarios

License: GNU General Public License v3.0

CMake 13.07% C++ 86.93%

copter_arm_robot's Introduction

Copter Arm Project

Project designed to learn PID control, relying on ros_control + gazebo for sim/real scenarios, heavily inspired by the example given in the Introduction to Control System Design - A First Look online course from MIT.

Here is a short video showing this package working

Hardware

The list of components required to mount the real platform is:

  • Linear potentiomer
  • Arduino
  • H bridge motor driver
  • Motor DC + Helix (They must agree, shaft, speed, power, etc.)
  • 2x 2A / 7VDC supply
  • Wires
  • Protoboard (optional)
  • Chienesse stick, wooden clothespin, ramplug and a wood strip (or whatever you find that suit a similar purpose)

If you don't have the money or the skills to build it, don't worry, you can use the simulation, see the Usage section below.

Software

  1. The package is built using the Gazebo/ROS ecosystem, in particular, the ROS/Kinetic distro. Installation instruction can be found here.
  2. After the installation, you need to create a ROS workspace, following these instructions
  3. In addition, this package requires the forked version of the teleop_tools/mouse_teleop package. Thus, you need to clone the package using the following command in a terminal (after steps 1 and 2): roscd && cd ../src/ && git clone https://github.com/MasterRobotica-UVic/teleop_tools.git
  4. Finally, get this package usingt he following command in a terminal: roscd && cd ../src/ && git clone https://github.com/MasterRobotica-UVic/copter_arm_robot.git
  5. You are good to build: roscd && cd .. && catkin_make

Usage

For the real scenario, connect everything, power up and type:

roslaunch copter_arm_robot copter_arm_real.launch

Or use the simulated scenario:

roslaunch copter_arm_robot copter_arm_sim.launch

Description of the real scenario

The arduino board doesn't do any computation, it is just a hardware interface between PC and motor driver. If you take a peek in the code running as firmware is pretty simple, it only subscribes to the motor command and publishes the measured angle. The former is forwarded directly to the pin where the motor driver is connected to, and the latter comes directly from the pin where the potentiometer is connected to.

This part of the code is mainly composed of three functions. The init() function that takes care of initilize subscribers, publishers, and populate all (typical) memebers of a hardware_interface::RobotHW object. The read() that updates the measured values from the Arduino to the shared memory for the controller, and the write() that updates the commanded values from the controller shared memory for the Aruino.

The calibrated values of the potentiometer are in fact computed here as well here. The gain and bias values are parameters that can be set in this file, where there is a brief explanation of how to calibrate a linear potentiometer. Note that, changing these values does not require to re-build the project.

It is worth to note that, in our scenario, there is a free joint (the one with the potentiometer) and an actuated joint (the one with the motor/helix couple), from the URDF point of view. Thus, if one takes a look of the controller configuration there are two controllers that basically forward commands, and this is because in the ROS controls project there is no way to set such scenario for a PID control.

To overcome this issue, the generic pid is used. This is reflected in the launch file. For this to work, the /control_effor topic is remapped, the /setpoint transformed from the mouse readings, and the /state from the /joint_states topic.

copter_arm_robot's People

Contributors

carlosjoserg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

copter_arm_robot's Issues

failed in sim mode

The output is as follows:


itfanr@itfanr-pc:catkin_ws$ roslaunch copter_arm_robot copter_arm_sim.launch
... logging to /home/itfanr/.ros/log/fa6e36cc-b63e-11e8-bf7f-408d5c402b0c/roslaunch-itfanr-pc-25125.log
Checking log directory for disk usage. This may take awhile.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.

started roslaunch server http://itfanr-pc:38009/

SUMMARY
========

PARAMETERS
 * /copter_arm/free_controller/joint: free_joint
 * /copter_arm/free_controller/type: effort_controller...
 * /copter_arm/motor_controller/joint: motor_joint
 * /copter_arm/motor_controller/type: velocity_controll...
 * /copter_arm/state_controller/publish_rate: 50
 * /copter_arm/state_controller/type: joint_state_contr...
 * /copter_arm_angle_controller/Kd: 0.0
 * /copter_arm_angle_controller/Ki: 0.0
 * /copter_arm_angle_controller/Kp: 0.0
 * /copter_arm_angle_controller/diagnostic_period: 0.25
 * /copter_arm_angle_controller/lower_limit: -9999999
 * /copter_arm_angle_controller/max_loop_frequency: 100.0
 * /copter_arm_angle_controller/min_loop_frequency: 100.0
 * /copter_arm_angle_controller/upper_limit: 9999999
 * /copter_arm_angle_controller/windup_limit: 500
 * /joint_state_publisher/source_list: ['copter_arm/join...
 * /joint_state_publisher/use_gui: False
 * /mouse_teleop/frequency: 10.0
 * /mouse_teleop/holonomic: False
 * /mouse_teleop/scale: 1.4
 * /robot_description: <?xml version="1....
 * /rosdistro: kinetic
 * /rosversion: 1.12.14
 * /use_sim_time: True

NODES
  /copter_arm/
    controller_spawner (controller_manager/spawner)
  /
    copter_arm_angle_controller (pid/controller)
    gazebo (gazebo_ros/gzserver)
    gazebo_gui (gazebo_ros/gzclient)
    joint_state_publisher (joint_state_publisher/joint_state_publisher)
    mouse_teleop (mouse_teleop/mouse_teleop.py)
    plots (rqt_gui/rqt_gui)
    robot_state_publisher (robot_state_publisher/robot_state_publisher)
    setpoint_transformer (topic_tools/transform)
    state_transformer (topic_tools/transform)
    urdf_spawner (gazebo_ros/spawn_model)

auto-starting new master
process[master]: started with pid [25139]
ROS_MASTER_URI=http://localhost:11311

setting /run_id to fa6e36cc-b63e-11e8-bf7f-408d5c402b0c
process[rosout-1]: started with pid [25152]
started core service [/rosout]
process[joint_state_publisher-2]: started with pid [25168]
process[robot_state_publisher-3]: started with pid [25177]
process[copter_arm/controller_spawner-4]: started with pid [25178]
process[gazebo-5]: started with pid [25179]
process[gazebo_gui-6]: started with pid [25186]
process[urdf_spawner-7]: started with pid [25200]
process[copter_arm_angle_controller-8]: started with pid [25210]
process[mouse_teleop-9]: started with pid [25221]
process[setpoint_transformer-10]: started with pid [25233]
process[state_transformer-11]: started with pid [25237]
process[plots-12]: started with pid [25242]
[INFO] [1536724225.747098, 0.000000]: Controller Spawner: Waiting for service controller_manager/load_controller
ERROR: Wrong input topic (or topic field): /copter_arm/joint_states
ERROR: Wrong input topic (or topic field): /mouse_vel
[ INFO] [1536724226.180601325]: Finished loading Gazebo ROS API Plugin.
[ INFO] [1536724226.184209954]: waitForService: Service [/gazebo/set_physics_properties] has not been advertised, waiting...
[ INFO] [1536724226.198175747]: Finished loading Gazebo ROS API Plugin.
[ INFO] [1536724226.210003024]: waitForService: Service [/gazebo/set_physics_properties] has not been advertised, waiting...
[setpoint_transformer-10] process has died [pid 25233, exit code 1, cmd /opt/ros/kinetic/lib/topic_tools/transform /mouse_vel /setpoint std_msgs/Float64 m.linear.x /control_effort:=/copter_arm/motor_controller/command __name:=setpoint_transformer __log:=/home/itfanr/.ros/log/fa6e36cc-b63e-11e8-bf7f-408d5c402b0c/setpoint_transformer-10.log].
log file: /home/itfanr/.ros/log/fa6e36cc-b63e-11e8-bf7f-408d5c402b0c/setpoint_transformer-10*.log
[state_transformer-11] process has died [pid 25237, exit code 1, cmd /opt/ros/kinetic/lib/topic_tools/transform /copter_arm/joint_states /state std_msgs/Float64 m.position[0] /control_effort:=/copter_arm/motor_controller/command __name:=state_transformer __log:=/home/itfanr/.ros/log/fa6e36cc-b63e-11e8-bf7f-408d5c402b0c/state_transformer-11.log].
log file: /home/itfanr/.ros/log/fa6e36cc-b63e-11e8-bf7f-408d5c402b0c/state_transformer-11*.log
[setpoint_transformer-10] restarting process
process[setpoint_transformer-10]: started with pid [25475]
[state_transformer-11] restarting process
process[state_transformer-11]: started with pid [25476]
X Error of failed request:  BadDrawable (invalid Pixmap or Window parameter)
  Major opcode of failed request:  153 (DRI2)
  Minor opcode of failed request:  3 (DRI2CreateDrawable)
  Resource id in failed request:  0x5600002
  Serial number of failed request:  31
  Current serial number in output stream:  33
SpawnModel script started
terminate called after throwing an instance of 'boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::lock_error> >'
terminate called recursively
[INFO] [1536724226.743930, 0.000000]: Loading model XML from ros parameter
[INFO] [1536724226.757329, 0.000000]: Waiting for service /gazebo/spawn_urdf_model
Aborted (core dumped)
[gazebo_gui-6] process has died [pid 25186, exit code 134, cmd /opt/ros/kinetic/lib/gazebo_ros/gzclient /control_effort:=/copter_arm/motor_controller/command __name:=gazebo_gui __log:=/home/itfanr/.ros/log/fa6e36cc-b63e-11e8-bf7f-408d5c402b0c/gazebo_gui-6.log].
log file: /home/itfanr/.ros/log/fa6e36cc-b63e-11e8-bf7f-408d5c402b0c/gazebo_gui-6*.log
[ INFO] [1536724226.946387932, 0.026000000]: waitForService: Service [/gazebo/set_physics_properties] is now available.
[ INFO] [1536724227.042736693, 0.119000000]: Physics dynamic reconfigure ready.
[INFO] [1536724227.068358, 0.144000]: Calling service /gazebo/spawn_urdf_model
PluginManager._load_plugin() could not load plugin "rqt_publisher/Publisher": plugin not available
PluginManager._load_plugin() could not load plugin "rqt_reconfigure/Param": plugin not available
PluginManager._load_plugin() could not load plugin "rqt_plot/Plot": plugin not available
[INFO] [1536724227.352071, 0.325000]: Spawn status: SpawnModel: Successfully spawned entity
[ INFO] [1536724227.370441750, 0.325000000]: Loading gazebo_ros_control plugin
[ INFO] [1536724227.370531264, 0.325000000]: Starting gazebo_ros_control plugin in namespace: /copter_arm
[ INFO] [1536724227.371216852, 0.325000000]: gazebo_ros_control plugin is waiting for model URDF in parameter [/robot_description] on the ROS param server.
[ INFO] [1536724227.485771049, 0.325000000]: Loaded gazebo_ros_control.
[urdf_spawner-7] process has finished cleanly
log file: /home/itfanr/.ros/log/fa6e36cc-b63e-11e8-bf7f-408d5c402b0c/urdf_spawner-7*.log
[INFO] [1536724227.618617, 0.467000]: Controller Spawner: Waiting for service controller_manager/switch_controller
[INFO] [1536724227.620351, 0.469000]: Controller Spawner: Waiting for service controller_manager/unload_controller
[INFO] [1536724227.622116, 0.471000]: Loading controller: state_controller
[INFO] [1536724227.631978, 0.481000]: Loading controller: motor_controller
[INFO] [1536724227.649024, 0.499000]: Controller Spawner: Loaded controllers: state_controller, motor_controller
[INFO] [1536724227.653153, 0.503000]: Started controllers: state_controller, motor_controller

Can you help with me?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.