Difference between revisions of "Simulator Architecture"

From sdk-wiki
Jump to: navigation, search
(baxter_sim_kinematics)
m (Protected "Simulator Architecture": Setting Permissions for (almost all) Pages - editable and moveable by all logged in users ([Edit=Allow only autoconfirmed users] (indefinite) [Move=Allow only autoconfirmed users] (indefinite)))
(No difference)

Revision as of 15:27, 29 July 2014

Package Description

baxter_sim_hardware

This package controls the functionalities of the simulator and acts as an interface between the user and the simulator. This package has one node

  • /baxter_emulator
    • This node subscribes to the topics robot/set_super_enable, robot/set_super_stop, robot/set_super_reset and enables/disables the controllers accordingly.
    • It also subscribes to the laser messages, wraps and publishes them as IR range and Sonar point cloud messages, accordingly.
    • It activates the head_nod state upon its command and toggles it in 1 second. Also it monitors the change in head_pan and publishes if the head is panning.
    • The digital_io light states are published based on the command received.
    • Upon gazebo startup, this node reads the RSDK image and loads it on Baxter's display.
    • This node also invokes the gravity calculation function at the arm_kinematics library (Package: baxter_sim_kinematics) to calculate the gravity comp torques at 100 Hz.

baxter_sim_io

This package is responsible for the qt plugin that constitute the Naviagtor of the simulator. It has a UI file in which holds the QT buttons for the navigator. This package also listens to the qt events and records the data This has one node

  • /baxter_sim_io
    • This node is responsible for publishing the variables which are updated based on the users input.

baxter_sim_kinematics

This package caluculates the IK, FK and Gravity Compensation torques. It has two nodes, one for each limb

  • /baxter_sim_kinematics_left
    • This node holds the service call for the IK for the left arm. It unwraps the message and adds a seed to it before calling the IK function from the arm_kinematics library.
    • It calculates the endpoint state of the left arm joints (FK) at 100 HZ by subscribing to the robot/joint_states topic.
  • /baxter_sim_kinematics_right
    • This node holds the service call for the IK for the right arm. It unwraps the message and adds a seed to it before calling the IK function from the arm_kinematics library.
    • It calculates the endpoint state of the right arm joints (FK) at 100 HZ by subscribing to the robot/joint_states topic.

This package has a library

  • arm_kinematics
    • This library calcualtes the IK, FK for both the left and right arm.
    • The gravity compensation is calculated here and the resulting joint torques are shared (as shared memory using IPC) with the default_robot_hw_sim library (Package: gazebo_ros_control) which is responsible for writing the torque commands to the simulator.

baxter_sim_controllers

This package constitutes the controller plugins for Baxter. It is also responsible for loading the controller information into the parameter server which is then used by gazebo. This has four plugins

  • baxter_effort_controller
    • This plugin instantiates a publisher for each of the individual joint effort controllers in an arm.
    • It unwraps the Joint command message and passes them to the appropriate controller which is then forwarded to the ros control(joint_effort_controller) and written as torque commands to gazebo
  • baxter_position_controller
    • This plugin instantiates a publisher for each of the individual joint position controllers in an arm.
    • It unwraps the Joint command message and passes them to the appropriate controller which is then forwarded to the ros controllers(joint_position_controller) where pid control is implemented before they are converted as torque commands and passed to gazebo.
  • baxter_velocity_controller
    • This plugin instantiates a publisher for each of the individual joint velocity controllers in an arm.
    • It unwraps the Joint command message and passes them to the appropriate controller which is then forwarded to the ros controllers(joint_velocity_controller) where pid control is implemented before they are converted as torque commands and passed to gazebo.
  • baxter_head_controller
    • This plugin instantiates a publisher for the head joint position controller.
    • It unwraps the Joint command message and passes them to the head joint position controller which is then forwarded to the ros controllers(joint_position_controller) where pid control is implemented before they are converted as torque commands and passed to gazebo.

baxter_sim_gazebo

This package holds the world models that can be loaded into gazebo. It also contains a controller plugin that regulates the messages passed between controllers. The default gazebo control plugin is overloaded as,

  • baxter_gazebo_ros_control_plugin
    • This plugin subscribes to the robot/state topic on initialization and checks if the state is enabled/disabled, based on which it starts/stops the controllers.
    • It also switches the controllers based on the mode, received in the joint command, and passes the messages to those controllers.

The below packages are existing packages that are either forked from various repositories as such or modified to work with Baxter

ros_controllers

This package holds the default controllers. For more information on these visit the ros_controllers wiki

ros_control

This forwards the torque commands from the controllers to gazebo. For more information visit the ros_control wiki

gazebo_ros_control

This package is an interface between the ros control and the gazebo. For more information visit the gazebo_ros_control wiki. The default _robot_hw_sim file was modified to share the gravity torque variables with the arm_kinematics library (Package - baxter_sim_kinematics), where it is updated at 100 Hz.

Program Flow

System Architecture

Sim flowchart.png

There are totally 3 process involved in the gazebo simulator

Process 1:

P1.png

This process is responsible for passing the user commands to the appropriate joints in the various modes.
The steps involved are,

  • The baxter_emulator node waits for the enable command from the user/programs and updates the robot/state topic accordingly.
  • The baxter_gazebo_ros_control plugin waits for the enable command to start the head controller, and then switches the appropriate controller (position, velocity or effort) based on the mode from the JointCommand message. At any point of time, if the topic robot/state receives disable command, it stops all the controllers.
  • At baxter_sim_controllers package, the controller which was switched would read the JointCommand message and unwrap the message before passing them to the individual joint controllers.
  • The individual joint_controllers at the ros_controller would implement a PID control (no PID control for effort controllers) on the messages and would convert them as torque commands.
  • The torque commands to the individual joints are written to a shared location at ros_control.
  • The default_robot_hw_sim reads the torque commands from the shared memory and sums them with the gravity compesnation torquees before it passes them to the appropriate joints in gazebo.

Process 2:

P2.png
This process is responsible for the gravity compensation torques' calculation.
The steps involved are,

  • The baxter_emulator node calls the gravity_compensation function at 100 Hz and passes the current robot/joint_states message.
  • The arm_kinematics library calculates the gravity compensation torques for the current state of the robot using KDL. It shares the gravity compensation torque variables with the gazebo_ros_control in a shared memory.This updates the gravity compensation torques as 0 when the robot is in disabled state.
  • The default_robot_hw_sim sums the gravity compensation torques with the torques from the controllers and passes them to the appropriate joints in gazebo.


Process 1 and Process 2 share the gravity compensation torques through Boost IPC library since they are from different processes.

Process 3

P3.png
This process calculates the Forward Kinematics (endpoint state) and Inverse Kinematics for the simulated Baxter.
The steps involved are,

  • The baxter emulator creates two nodes named as baxter_sim_kinematics_left and baxter_sim_kinematics_right, for each of the arm. It passes the joint states at 100 Hz.
  • The kinematics nodes are subscribed to the robot/joint_states and they calculate the endpoint state by using the KDL function defined in the arm_kinematics library. The endpoint state is published at 100 Hz to the topic robot/limb/<side>/endpoint_state.
  • In addition the nodes also define the IK service. They unwrap the service requests and appends the seed (current joint state) to them before calling the KDL function from the arm_kinematics library.

Ros Nodes

  1. /baxter_emulator
  2. /baxter_sim_io
  3. /baxter_sim_kinematics_left
  4. /baxter_sim_kinematics_right
  5. /gazebo
  6. /gazebo_client
  7. /robot/controller_spawner
  8. /robot/controller_spawner_stopped
  9. /robot_state_publisher
  10. /rosout

Ros Topics

  1. /cameras/head_camera/camera_info
  2. /cameras/head_camera/image
  3. /cameras/head_camera/parameter_descriptions
  4. /cameras/head_camera/parameter_updates
  5. /cameras/left_hand_camera/camera_info
  6. /cameras/left_hand_camera/image
  7. /cameras/left_hand_camera/parameter_descriptions
  8. /cameras/left_hand_camera/parameter_updates
  9. /cameras/right_hand_camera/camera_info
  10. /cameras/right_hand_camera/image
  11. /cameras/right_hand_camera/parameter_descriptions
  12. /cameras/right_hand_camera/parameter_updates
  13. /clock
  14. /gazebo/link_states
  15. /gazebo/model_states
  16. /gazebo/parameter_descriptions
  17. /gazebo/parameter_updates
  18. /gazebo/set_link_state
  19. /gazebo/set_model_state
  20. /robot/analog_io/left_hand_range/state
  21. /robot/analog_io/left_hand_range/value_uint32
  22. /robot/analog_io/right_hand_range/state
  23. /robot/analog_io/right_hand_range/value_uint32
  24. /robot/digital_io/command
  25. /robot/digital_io/left_itb_light_inner/state
  26. /robot/digital_io/left_itb_light_outer/state
  27. /robot/digital_io/left_lower_button/state
  28. /robot/digital_io/left_lower_cuff/state
  29. /robot/digital_io/left_shoulder_button/state
  30. /robot/digital_io/left_upper_button/state
  31. /robot/digital_io/right_itb_light_inner/state
  32. /robot/digital_io/right_itb_light_outer/state
  33. /robot/digital_io/right_lower_button/state
  34. /robot/digital_io/right_lower_cuff/state
  35. /robot/digital_io/right_shoulder_button/state
  36. /robot/digital_io/right_upper_button/state
  37. /robot/digital_io/torso_left_itb_light_inner/state
  38. /robot/digital_io/torso_left_itb_light_outer/state
  39. /robot/digital_io/torso_right_itb_light_inner/state
  40. /robot/digital_io/torso_right_itb_light_outer/state
  41. /robot/end_effector/left_gripper/properties
  42. /robot/end_effector/left_gripper/state
  43. /robot/end_effector/right_gripper/properties
  44. /robot/end_effector/right_gripper/state
  45. /robot/head/command_head_nod
  46. /robot/head/command_head_pan
  47. /robot/head/head_state
  48. /robot/head_position_controller/joints/head_controller/command
  49. /robot/head_position_controller/joints/head_controller/pid/parameter_descriptions
  50. /robot/head_position_controller/joints/head_controller/pid/parameter_updates
  51. /robot/head_position_controller/joints/head_controller/state
  52. /robot/itb/left_itb/state
  53. /robot/itb/right_itb/state
  54. /robot/itb/torso_left_itb/state
  55. /robot/itb/torso_right_itb/state
  56. /robot/joint_states
  57. /robot/laserscan/left_hand_range/state
  58. /robot/laserscan/right_hand_range/state
  59. /robot/left_joint_effort_controller/joints/left_e0_controller/command
  60. /robot/left_joint_effort_controller/joints/left_e1_controller/command
  61. /robot/left_joint_effort_controller/joints/left_s0_controller/command
  62. /robot/left_joint_effort_controller/joints/left_s1_controller/command
  63. /robot/left_joint_effort_controller/joints/left_w0_controller/command
  64. /robot/left_joint_effort_controller/joints/left_w1_controller/command
  65. /robot/left_joint_effort_controller/joints/left_w2_controller/command
  66. /robot/left_joint_position_controller/joints/left_e0_controller/command
  67. /robot/left_joint_position_controller/joints/left_e0_controller/pid/parameter_descriptions
  68. /robot/left_joint_position_controller/joints/left_e0_controller/pid/parameter_updates
  69. /robot/left_joint_position_controller/joints/left_e0_controller/state
  70. /robot/left_joint_position_controller/joints/left_e1_controller/command
  71. /robot/left_joint_position_controller/joints/left_e1_controller/pid/parameter_descriptions
  72. /robot/left_joint_position_controller/joints/left_e1_controller/pid/parameter_updates
  73. /robot/left_joint_position_controller/joints/left_e1_controller/state
  74. /robot/left_joint_position_controller/joints/left_s0_controller/command
  75. /robot/left_joint_position_controller/joints/left_s0_controller/pid/parameter_descriptions
  76. /robot/left_joint_position_controller/joints/left_s0_controller/pid/parameter_updates
  77. /robot/left_joint_position_controller/joints/left_s0_controller/state
  78. /robot/left_joint_position_controller/joints/left_s1_controller/command
  79. /robot/left_joint_position_controller/joints/left_s1_controller/pid/parameter_descriptions
  80. /robot/left_joint_position_controller/joints/left_s1_controller/pid/parameter_updates
  81. /robot/left_joint_position_controller/joints/left_s1_controller/state
  82. /robot/left_joint_position_controller/joints/left_w0_controller/command
  83. /robot/left_joint_position_controller/joints/left_w0_controller/pid/parameter_descriptions
  84. /robot/left_joint_position_controller/joints/left_w0_controller/pid/parameter_updates
  85. /robot/left_joint_position_controller/joints/left_w0_controller/state
  86. /robot/left_joint_position_controller/joints/left_w1_controller/command
  87. /robot/left_joint_position_controller/joints/left_w1_controller/pid/parameter_descriptions
  88. /robot/left_joint_position_controller/joints/left_w1_controller/pid/parameter_updates
  89. /robot/left_joint_position_controller/joints/left_w1_controller/state
  90. /robot/left_joint_position_controller/joints/left_w2_controller/command
  91. /robot/left_joint_position_controller/joints/left_w2_controller/pid/parameter_descriptions
  92. /robot/left_joint_position_controller/joints/left_w2_controller/pid/parameter_updates
  93. /robot/left_joint_position_controller/joints/left_w2_controller/state
  94. /robot/left_joint_velocity_controller/joints/left_e0_controller/command
  95. /robot/left_joint_velocity_controller/joints/left_e0_controller/pid/parameter_descriptions
  96. /robot/left_joint_velocity_controller/joints/left_e0_controller/pid/parameter_updates
  97. /robot/left_joint_velocity_controller/joints/left_e0_controller/state
  98. /robot/left_joint_velocity_controller/joints/left_e1_controller/command
  99. /robot/left_joint_velocity_controller/joints/left_e1_controller/pid/parameter_descriptions
  100. /robot/left_joint_velocity_controller/joints/left_e1_controller/pid/parameter_updates
  101. /robot/left_joint_velocity_controller/joints/left_e1_controller/state
  102. /robot/left_joint_velocity_controller/joints/left_s0_controller/command
  103. /robot/left_joint_velocity_controller/joints/left_s0_controller/pid/parameter_descriptions
  104. /robot/left_joint_velocity_controller/joints/left_s0_controller/pid/parameter_updates
  105. /robot/left_joint_velocity_controller/joints/left_s0_controller/state
  106. /robot/left_joint_velocity_controller/joints/left_s1_controller/command
  107. /robot/left_joint_velocity_controller/joints/left_s1_controller/pid/parameter_descriptions
  108. /robot/left_joint_velocity_controller/joints/left_s1_controller/pid/parameter_updates
  109. /robot/left_joint_velocity_controller/joints/left_s1_controller/state
  110. /robot/left_joint_velocity_controller/joints/left_w0_controller/command
  111. /robot/left_joint_velocity_controller/joints/left_w0_controller/pid/parameter_descriptions
  112. /robot/left_joint_velocity_controller/joints/left_w0_controller/pid/parameter_updates
  113. /robot/left_joint_velocity_controller/joints/left_w0_controller/state
  114. /robot/left_joint_velocity_controller/joints/left_w1_controller/command
  115. /robot/left_joint_velocity_controller/joints/left_w1_controller/pid/parameter_descriptions
  116. /robot/left_joint_velocity_controller/joints/left_w1_controller/pid/parameter_updates
  117. /robot/left_joint_velocity_controller/joints/left_w1_controller/state
  118. /robot/left_joint_velocity_controller/joints/left_w2_controller/command
  119. /robot/left_joint_velocity_controller/joints/left_w2_controller/pid/parameter_descriptions
  120. /robot/left_joint_velocity_controller/joints/left_w2_controller/pid/parameter_updates
  121. /robot/left_joint_velocity_controller/joints/left_w2_controller/state
  122. /robot/limb/left/endpoint_state
  123. /robot/limb/left/joint_command
  124. /robot/limb/right/endpoint_state
  125. /robot/limb/right/joint_command
  126. /robot/range/left_hand_range
  127. /robot/range/right_hand_range
  128. /robot/right_joint_effort_controller/joints/right_e0_controller/command
  129. /robot/right_joint_effort_controller/joints/right_e1_controller/command
  130. /robot/right_joint_effort_controller/joints/right_s0_controller/command
  131. /robot/right_joint_effort_controller/joints/right_s1_controller/command
  132. /robot/right_joint_effort_controller/joints/right_w0_controller/command
  133. /robot/right_joint_effort_controller/joints/right_w1_controller/command
  134. /robot/right_joint_effort_controller/joints/right_w2_controller/command
  135. /robot/right_joint_position_controller/joints/right_e0_controller/command
  136. /robot/right_joint_position_controller/joints/right_e0_controller/pid/parameter_descriptions
  137. /robot/right_joint_position_controller/joints/right_e0_controller/pid/parameter_updates
  138. /robot/right_joint_position_controller/joints/right_e0_controller/state
  139. /robot/right_joint_position_controller/joints/right_e1_controller/command
  140. /robot/right_joint_position_controller/joints/right_e1_controller/pid/parameter_descriptions
  141. /robot/right_joint_position_controller/joints/right_e1_controller/pid/parameter_updates
  142. /robot/right_joint_position_controller/joints/right_e1_controller/state
  143. /robot/right_joint_position_controller/joints/right_s0_controller/command
  144. /robot/right_joint_position_controller/joints/right_s0_controller/pid/parameter_descriptions
  145. /robot/right_joint_position_controller/joints/right_s0_controller/pid/parameter_updates
  146. /robot/right_joint_position_controller/joints/right_s0_controller/state
  147. /robot/right_joint_position_controller/joints/right_s1_controller/command
  148. /robot/right_joint_position_controller/joints/right_s1_controller/pid/parameter_descriptions
  149. /robot/right_joint_position_controller/joints/right_s1_controller/pid/parameter_updates
  150. /robot/right_joint_position_controller/joints/right_s1_controller/state
  151. /robot/right_joint_position_controller/joints/right_w0_controller/command
  152. /robot/right_joint_position_controller/joints/right_w0_controller/pid/parameter_descriptions
  153. /robot/right_joint_position_controller/joints/right_w0_controller/pid/parameter_updates
  154. /robot/right_joint_position_controller/joints/right_w0_controller/state
  155. /robot/right_joint_position_controller/joints/right_w1_controller/command
  156. /robot/right_joint_position_controller/joints/right_w1_controller/pid/parameter_descriptions
  157. /robot/right_joint_position_controller/joints/right_w1_controller/pid/parameter_updates
  158. /robot/right_joint_position_controller/joints/right_w1_controller/state
  159. /robot/right_joint_position_controller/joints/right_w2_controller/command
  160. /robot/right_joint_position_controller/joints/right_w2_controller/pid/parameter_descriptions
  161. /robot/right_joint_position_controller/joints/right_w2_controller/pid/parameter_updates
  162. /robot/right_joint_position_controller/joints/right_w2_controller/state
  163. /robot/right_joint_velocity_controller/joints/right_e0_controller/command
  164. /robot/right_joint_velocity_controller/joints/right_e0_controller/pid/parameter_descriptions
  165. /robot/right_joint_velocity_controller/joints/right_e0_controller/pid/parameter_updates
  166. /robot/right_joint_velocity_controller/joints/right_e0_controller/state
  167. /robot/right_joint_velocity_controller/joints/right_e1_controller/command
  168. /robot/right_joint_velocity_controller/joints/right_e1_controller/pid/parameter_descriptions
  169. /robot/right_joint_velocity_controller/joints/right_e1_controller/pid/parameter_updates
  170. /robot/right_joint_velocity_controller/joints/right_e1_controller/state
  171. /robot/right_joint_velocity_controller/joints/right_s0_controller/command
  172. /robot/right_joint_velocity_controller/joints/right_s0_controller/pid/parameter_descriptions
  173. /robot/right_joint_velocity_controller/joints/right_s0_controller/pid/parameter_updates
  174. /robot/right_joint_velocity_controller/joints/right_s0_controller/state
  175. /robot/right_joint_velocity_controller/joints/right_s1_controller/command
  176. /robot/right_joint_velocity_controller/joints/right_s1_controller/pid/parameter_descriptions
  177. /robot/right_joint_velocity_controller/joints/right_s1_controller/pid/parameter_updates
  178. /robot/right_joint_velocity_controller/joints/right_s1_controller/state
  179. /robot/right_joint_velocity_controller/joints/right_w0_controller/command
  180. /robot/right_joint_velocity_controller/joints/right_w0_controller/pid/parameter_descriptions
  181. /robot/right_joint_velocity_controller/joints/right_w0_controller/pid/parameter_updates
  182. /robot/right_joint_velocity_controller/joints/right_w0_controller/state
  183. /robot/right_joint_velocity_controller/joints/right_w1_controller/command
  184. /robot/right_joint_velocity_controller/joints/right_w1_controller/pid/parameter_descriptions
  185. /robot/right_joint_velocity_controller/joints/right_w1_controller/pid/parameter_updates
  186. /robot/right_joint_velocity_controller/joints/right_w1_controller/state
  187. /robot/right_joint_velocity_controller/joints/right_w2_controller/command
  188. /robot/right_joint_velocity_controller/joints/right_w2_controller/pid/parameter_descriptions
  189. /robot/right_joint_velocity_controller/joints/right_w2_controller/pid/parameter_updates
  190. /robot/right_joint_velocity_controller/joints/right_w2_controller/state
  191. /robot/set_super_enable
  192. /robot/set_super_reset
  193. /robot/set_super_stop
  194. /robot/sonar/head_sonar/state
  195. /robot/state
  196. /robot/xdisplay
  197. /rosout
  198. /rosout_agg
  199. /tf