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

Motor naming discrepancy #18

Closed
melissajcruz opened this issue Aug 10, 2023 · 6 comments
Closed

Motor naming discrepancy #18

melissajcruz opened this issue Aug 10, 2023 · 6 comments
Assignees
Labels
robot description conflict Mismatched parameter names/definitions

Comments

@melissajcruz
Copy link
Collaborator

V5MotorCommand.msg identifies motors using motor_name

string motor_name
int32 device_id             # Corresponds to V5 Port Number

int32 desired_angle         # Degrees
float32 desired_velocity    # RPM
float32 desired_torque      # N-m
float32 desired_voltage     # Normalized (-1.0 -> 1.0)
int32 current_limit         # milliAmps

bool angle_control
bool velocity_control
bool torque_control
bool voltage_control

The V5MotorCommand.msg is used to populate the V5ActuatorCommand.msg

# Header
std_msgs/Header header
uint32 msg_id

\# Motor Commands
ghost_msgs/V5MotorCommand[21] motor_commands

\# Digital Outputs
bool[8] digital_port_vector`

I'd like to parse the V5ActuatorCommand.msg using the joint names in ghost1_sim_pid.xacro/ ghost1_sim_voltage.xacro

 \<!-- Gazebo Plugins -->
    <gazebo>
        <!-- Motor Models -->
        <!-- 0.05 Steering -->
        <xacro:joint_pid_macro
            joint_name="steering_left"
            link_name="mod_left"
            gear_ratio="2.0"
            position_gain="0.05"
            vel_gain="0.04"
            accel_gain="0.0">
        </xacro:joint_pid_macro>

        <xacro:joint_pid_macro
            joint_name="steering_right"
            link_name="mod_right"
            gear_ratio="2.0"
            position_gain="0.05"
            vel_gain="0.04"
            accel_gain="0.0">
        </xacro:joint_pid_macro>

        <xacro:joint_pid_macro
            joint_name="steering_back"
            link_name="mod_back"
            gear_ratio="2.0"
            position_gain="0.05"
            vel_gain="0.04"
            accel_gain="0.0">
        </xacro:joint_pid_macro>

        <xacro:joint_pid_macro
            joint_name="driveshaft_left"
            link_name="wheel_left"
            gear_ratio="5.0"
            position_gain="0.0"
            vel_gain="0.04"
            accel_gain="0.0">
        </xacro:joint_pid_macro>

        <xacro:joint_pid_macro
            joint_name="driveshaft_right"
            link_name="wheel_right"
            gear_ratio="5.0"
            position_gain="0.0"
            vel_gain="0.04"
            accel_gain="0.0">
        </xacro:joint_pid_macro>

        <xacro:joint_pid_macro
            joint_name="driveshaft_back"
            link_name="wheel_back"
            gear_ratio="5.0"
            position_gain="0.0"
            vel_gain="0.04"
            accel_gain="0.0">
        </xacro:joint_pid_macro>  
    </gazebo>

versus the motor_names in v5_sim_config.yaml

motor_names:
  - "DRIVE_LEFT_FRONT_MOTOR"
  - "DRIVE_LEFT_BACK_MOTOR"
  - "DRIVE_RIGHT_FRONT_MOTOR"
  - "DRIVE_RIGHT_BACK_MOTOR"
  - "DRIVE_BACK_LEFT_1_MOTOR"
  - "DRIVE_BACK_RIGHT_1_MOTOR"
  - "TURRET_MOTOR"

since joint_name is already being referenced in gazebo_joint_pid_plugin.cpp.

@melissajcruz melissajcruz added the robot description conflict Mismatched parameter names/definitions label Aug 10, 2023
@MaxxWilson
Copy link
Collaborator

So...

There are typically going to be more motors on a VEX robot than there will be joints because the actuators are weak. Because of this, joint names and motor names wont match up 1:1. We definitely want to modify the gazebo plugins to take in a motor name which corresponds to that joint (I would use name instead of port id for clarity).

TBH, I am not sure how this looks on a standard robot (i.e. tank drive), because I built it all for Swerve. Ideally you would group related motors and address them as one, which would allow you to connect multiple motors to one joint, but this isn't supported by Serial Driver rn and I don't plan on doing it. I suppose you can pick one motor from the motor group and then add a multiplier lol.

So for a tank drive robot with three motors on each side of the drive, gazebo plugin would link the primary wheel joint to ONE of the motors and then also be configured to multiply torque/current/power by three?

@melissajcruz
Copy link
Collaborator Author

I'll set the motor names to be prefaced with driveshaft_left , driveshaft_right , driveshaft_back to group them.

As for picking which motor to actuate, do all of the motors that actuate the wheel joints like wheel_left have the same input command type (angle, velocity, torque, voltage)? If they're all doing the same command type, I'll just pick the first motor encountered when moving along the base CCW.

@MaxxWilson
Copy link
Collaborator

Take a look at this URDF I added. This is how I think plugin can be configured.

https://github.com/VEXU-GHOST/VEXU_GHOST/blob/feature/v5-general-sim-node/ghost_sim/urdf/ghost1_sim_base.xacro

The V5 Sim plugin in that branch is also somewhat up to date and can be worked off.

The matrices I added there can map a vector of joint velocities/torques to the vector of motor torques/velocities arbitrarily, so don't need to worry about specifics of how things are configured, can just do as big block ops.

Next up would be to add a callback that gets the velocity and position setpoint vectors for the motors of interest. Then we get velocity and position vector for all the joints we list in URDF, and transform them to actuator/sensor space. Then can apply the motor controllers (which I still need to migrate) to those position / velocity errors to get torque cmd and then transform back to joints and poly in gazebo.

@melissajcruz
Copy link
Collaborator Author

Motors could be ordered in actuator jacobian by port number?

@MaxxWilson
Copy link
Collaborator

Motor names should always be the same, while port number can change very easily. I would order by the index in the name vector

@MaxxWilson
Copy link
Collaborator

Closed in favor of #6.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
robot description conflict Mismatched parameter names/definitions
Projects
None yet
Development

No branches or pull requests

3 participants