-
Notifications
You must be signed in to change notification settings - Fork 234
added motor-plugin and DroneCAN ESC telemetry script #146
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| /* | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| * | ||
| */ | ||
|
|
||
| #ifndef MOTORPLUGIN_HH_ | ||
| #define MOTORPLUGIN_HH_ | ||
|
|
||
| #include <memory> | ||
|
|
||
| #include <gz/sim/System.hh> | ||
|
|
||
| namespace gz { | ||
| namespace sim { | ||
| inline namespace GZ_SIM_VERSION_NAMESPACE { | ||
| namespace systems { | ||
|
|
||
|
|
||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Include a doc string describing the plugins purpose and SDF parameters. See for example: https://github.com/ArduPilot/ardupilot_gazebo/blob/main/include/GstCameraPlugin.hh |
||
| class MotorPlugin : | ||
| public System, | ||
| public ISystemPreUpdate, | ||
| public ISystemConfigure | ||
| { | ||
| /// \brief Destructor | ||
| public: virtual ~MotorPlugin(); | ||
|
|
||
| /// \brief Constructor | ||
| public: MotorPlugin(); | ||
|
|
||
| // Documentation inherited | ||
| public: void PreUpdate(const gz::sim::UpdateInfo &_info, | ||
| EntityComponentManager &_ecm) final; | ||
|
|
||
| // Documentation inherited | ||
| public: void Configure(const Entity &_entity, | ||
| const std::shared_ptr<const sdf::Element> &_sdf, | ||
| EntityComponentManager &_ecm, | ||
| EventManager &) final; | ||
|
|
||
| /// \brief Load control channels | ||
| private: void LoadControlChannels( | ||
| sdf::ElementPtr _sdf, | ||
| gz::sim::EntityComponentManager &_ecm); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can be in the private |
||
|
|
||
| /// \internal | ||
| /// \brief Private implementation | ||
| private: class Impl; | ||
| private: std::unique_ptr<Impl> impl; | ||
| }; | ||
|
|
||
| } // namespace systems | ||
| } | ||
| } // namespace sim | ||
| } // namespace gz | ||
|
|
||
| #endif // MOTORPLUGIN_HH_ | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -215,14 +215,15 @@ | |
| <offset>0</offset> | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd prefer to see the changes to the models split into a separate PR. That way we can proceed with including the motor plugin without altering the existing models and their behaviour. When we're more comfortable with the plugin we can consider migrating the examples over to it. In the meanwhile a small test model (one of the iris motors and prop fixed to a thrust stand would be good). That would allow testing and demonstrations. It could even have a force torque sensor plugin included in the joint for additional feedback. |
||
| <servo_min>1100</servo_min> | ||
| <servo_max>1900</servo_max> | ||
| <type>VELOCITY</type> | ||
| <type>COMMAND</type> | ||
| <p_gain>0.20</p_gain> | ||
| <i_gain>0</i_gain> | ||
| <d_gain>0</d_gain> | ||
| <i_max>0</i_max> | ||
| <i_min>0</i_min> | ||
| <cmd_max>2.5</cmd_max> | ||
| <cmd_min>-2.5</cmd_min> | ||
| <cmd_topic>joint_0</cmd_topic> | ||
| <controlVelocitySlowdownSim>1</controlVelocitySlowdownSim> | ||
| </control> | ||
|
|
||
|
|
@@ -233,14 +234,15 @@ | |
| <offset>0</offset> | ||
| <servo_min>1100</servo_min> | ||
| <servo_max>1900</servo_max> | ||
| <type>VELOCITY</type> | ||
| <type>COMMAND</type> | ||
| <p_gain>0.20</p_gain> | ||
| <i_gain>0</i_gain> | ||
| <d_gain>0</d_gain> | ||
| <i_max>0</i_max> | ||
| <i_min>0</i_min> | ||
| <cmd_max>2.5</cmd_max> | ||
| <cmd_min>-2.5</cmd_min> | ||
| <cmd_topic>joint_1</cmd_topic> | ||
| <controlVelocitySlowdownSim>1</controlVelocitySlowdownSim> | ||
| </control> | ||
|
|
||
|
|
@@ -251,14 +253,15 @@ | |
| <offset>0</offset> | ||
| <servo_min>1100</servo_min> | ||
| <servo_max>1900</servo_max> | ||
| <type>VELOCITY</type> | ||
| <type>COMMAND</type> | ||
| <p_gain>0.20</p_gain> | ||
| <i_gain>0</i_gain> | ||
| <d_gain>0</d_gain> | ||
| <i_max>0</i_max> | ||
| <i_min>0</i_min> | ||
| <cmd_max>2.5</cmd_max> | ||
| <cmd_min>-2.5</cmd_min> | ||
| <cmd_topic>joint_2</cmd_topic> | ||
| <controlVelocitySlowdownSim>1</controlVelocitySlowdownSim> | ||
| </control> | ||
|
|
||
|
|
@@ -269,14 +272,15 @@ | |
| <offset>0</offset> | ||
| <servo_min>1100</servo_min> | ||
| <servo_max>1900</servo_max> | ||
| <type>VELOCITY</type> | ||
| <type>COMMAND</type> | ||
| <p_gain>0.20</p_gain> | ||
| <i_gain>0</i_gain> | ||
| <d_gain>0</d_gain> | ||
| <i_max>0</i_max> | ||
| <i_min>0</i_min> | ||
| <cmd_max>2.5</cmd_max> | ||
| <cmd_min>-2.5</cmd_min> | ||
| <cmd_topic>joint_3</cmd_topic> | ||
| <controlVelocitySlowdownSim>1</controlVelocitySlowdownSim> | ||
| </control> | ||
|
|
||
|
|
@@ -318,6 +322,65 @@ | |
|
|
||
| </plugin> | ||
|
|
||
| <plugin filename="MotorPlugin" name="MotorPlugin"> | ||
|
|
||
| <control channel="0"> | ||
| <joint_name>iris_with_standoffs::rotor_0_joint</joint_name> | ||
| <voltage_bat>16</voltage_bat> | ||
| <speed_constant>920</speed_constant> | ||
| <resistance>0.115</resistance> | ||
| <no_load_current>0.8</no_load_current> | ||
| <cmd_topic>joint_0</cmd_topic> | ||
| <multiplier>838</multiplier> | ||
| <offset>0</offset> | ||
| <thermal_resistance>1.4</thermal_resistance> | ||
| <thermal_capacitance>214.28</thermal_capacitance> | ||
| <ambient_temperature>25.0</ambient_temperature> | ||
| </control> | ||
|
|
||
| <control channel="1"> | ||
| <joint_name>iris_with_standoffs::rotor_1_joint</joint_name> | ||
| <voltage_bat>16</voltage_bat> | ||
| <speed_constant>920</speed_constant> | ||
| <resistance>0.115</resistance> | ||
| <no_load_current>0.8</no_load_current> | ||
| <cmd_topic>joint_1</cmd_topic> | ||
| <multiplier>838</multiplier> | ||
| <offset>0</offset> | ||
| <thermal_resistance>1.4</thermal_resistance> | ||
| <thermal_capacitance>214.28</thermal_capacitance> | ||
| <ambient_temperature>25.0</ambient_temperature> | ||
| </control> | ||
|
|
||
| <control channel="2"> | ||
| <joint_name>iris_with_standoffs::rotor_2_joint</joint_name> | ||
| <voltage_bat>16</voltage_bat> | ||
| <speed_constant>920</speed_constant> | ||
| <resistance>0.115</resistance> | ||
| <no_load_current>0.8</no_load_current> | ||
| <cmd_topic>joint_2</cmd_topic> | ||
| <multiplier>-838</multiplier> | ||
| <offset>0</offset> | ||
| <thermal_resistance>1.4</thermal_resistance> | ||
| <thermal_capacitance>214.28</thermal_capacitance> | ||
| <ambient_temperature>25.0</ambient_temperature> | ||
| </control> | ||
|
|
||
| <control channel="3"> | ||
| <joint_name>iris_with_standoffs::rotor_3_joint</joint_name> | ||
| <voltage_bat>16</voltage_bat> | ||
| <speed_constant>920</speed_constant> | ||
| <resistance>0.115</resistance> | ||
| <no_load_current>0.8</no_load_current> | ||
| <cmd_topic>joint_3</cmd_topic> | ||
| <multiplier>-838</multiplier> | ||
| <offset>0</offset> | ||
| <thermal_resistance>1.4</thermal_resistance> | ||
| <thermal_capacitance>214.28</thermal_capacitance> | ||
| <ambient_temperature>25.0</ambient_temperature> | ||
| </control> | ||
| </plugin> | ||
|
|
||
| <plugin | ||
| filename="gz-sim-joint-position-controller-system" | ||
| name="gz::sim::systems::JointPositionController"> | ||
|
|
@@ -341,4 +404,4 @@ | |
| </plugin> | ||
|
|
||
| </model> | ||
| </sdf> | ||
| </sdf> | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,20 @@ | ||||||
| syntax = "proto3"; | ||||||
| package ardupilot_gazebo.msgs; | ||||||
|
|
||||||
| // Message to hold the status of a single motor. | ||||||
| message MotorStats { | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| // Motor Id | ||||||
| int32 motor_id = 1; | ||||||
|
|
||||||
| // Rotational speed of the motor in revolutions per minute (RPM). | ||||||
| double rpm = 2; | ||||||
|
|
||||||
| // Voltage supplied to the motor in Volts. | ||||||
| double voltage = 3; | ||||||
|
|
||||||
| // Current drawn by the motor in Amperes. | ||||||
| double current = 4; | ||||||
|
|
||||||
| // Motor Temperature in Celsius. | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Temperature in Kelvin. |
||||||
| double temperature = 5; | ||||||
| } | ||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be LGPLv3. The original ArduPilotPlugin code was Apache, but new works should match the repo license (https://github.com/ArduPilot/ardupilot_gazebo/blob/main/LICENSE.md). See https://github.com/ArduPilot/ardupilot_gazebo/blob/main/include/SocketUDP.hh for example text to include in source files.