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

Feat/publish our own #2

Merged
merged 23 commits into from
Oct 17, 2024
Merged

Feat/publish our own #2

merged 23 commits into from
Oct 17, 2024

Conversation

dnikitop
Copy link
Collaborator

@dnikitop dnikitop commented Oct 17, 2024

generate-message-types creates .js files and .d.ts files.
Currently we can't import the .js files because they rely on a local ros installation.

The .d.ts files work well, but don't allow us to use CONSTS at runtime.

This pr adds a simple interfaces.js file that defines all constants for each class.

Sample:

Before, the DropoffPallet_Result constants were defined in interfaces.d.ts with

export interface DropoffPallet_ResultConstructor {
        readonly PALLET_DROPOFF_LOCATION_OCCUPIED: number;
        readonly PALLET_UNSTABLE: number;
        readonly PALLET_DROPOFF_MECHANICAL_ISSUE: number;
        readonly PALLET_DROPOFF_OBSTRUCTED: number;
        readonly PALLET_DROPOFF_INTERRUPTED: number;
        readonly PALLET_DROPOFF_INITIAL_CONDITION: number;
        readonly PALLET_DROPOFF_OUT_OF_ALIGNMENT_WITH_FIFO: number;
        new(other?: DropoffPallet_Result): DropoffPallet_Result;
      }

After. In interfaces.d.ts

      export enum DropoffPallet_ResultConstants {
        NONE = 0,
        OUT_OF_ALIGNMENT_WITH_FIFO = 1,
        DO_NOT_HAVE_PALLET = 2,
        LOCATION_OCCUPIED = 3,
        INACCESSIBLE = 4,
        MECHANICAL_ISSUE = 5,
        DROPOFF_OBSTRUCTED = 6,
        PALLET_DROPOFF_INTERRUPTED = 7,
        FIFO_LANE_EXIT_FAILED = 8,
        CANCELED = 9,
        STATE_INVALIDATED = 10,
        UNKNOWN_ERROR_CASE = 11,
      }
      export interface DropoffPallet_ResultConstructor {
        readonly NONE: DropoffPallet_ResultConstants.NONE;
        readonly OUT_OF_ALIGNMENT_WITH_FIFO: DropoffPallet_ResultConstants.OUT_OF_ALIGNMENT_WITH_FIFO;
        readonly DO_NOT_HAVE_PALLET: DropoffPallet_ResultConstants.DO_NOT_HAVE_PALLET;
        readonly LOCATION_OCCUPIED: DropoffPallet_ResultConstants.LOCATION_OCCUPIED;
        readonly INACCESSIBLE: DropoffPallet_ResultConstants.INACCESSIBLE;
        readonly MECHANICAL_ISSUE: DropoffPallet_ResultConstants.MECHANICAL_ISSUE;
        readonly DROPOFF_OBSTRUCTED: DropoffPallet_ResultConstants.DROPOFF_OBSTRUCTED;
        readonly PALLET_DROPOFF_INTERRUPTED: DropoffPallet_ResultConstants.PALLET_DROPOFF_INTERRUPTED;
        readonly FIFO_LANE_EXIT_FAILED: DropoffPallet_ResultConstants.FIFO_LANE_EXIT_FAILED;
        readonly CANCELED: DropoffPallet_ResultConstants.CANCELED;
        readonly STATE_INVALIDATED: DropoffPallet_ResultConstants.STATE_INVALIDATED;
        readonly UNKNOWN_ERROR_CASE: DropoffPallet_ResultConstants.UNKNOWN_ERROR_CASE;
        new(other?: DropoffPallet_Result): DropoffPallet_Result;
      }

And in interfaces.js

class srsbot_pallet_handling_interfaces_action_DropoffPallet_ResultConstants {}
srsbot_pallet_handling_interfaces_action_DropoffPallet_ResultConstants.NONE = 0
srsbot_pallet_handling_interfaces_action_DropoffPallet_ResultConstants.OUT_OF_ALIGNMENT_WITH_FIFO = 1
srsbot_pallet_handling_interfaces_action_DropoffPallet_ResultConstants.DO_NOT_HAVE_PALLET = 2
srsbot_pallet_handling_interfaces_action_DropoffPallet_ResultConstants.LOCATION_OCCUPIED = 3
srsbot_pallet_handling_interfaces_action_DropoffPallet_ResultConstants.INACCESSIBLE = 4
srsbot_pallet_handling_interfaces_action_DropoffPallet_ResultConstants.MECHANICAL_ISSUE = 5
srsbot_pallet_handling_interfaces_action_DropoffPallet_ResultConstants.DROPOFF_OBSTRUCTED = 6
srsbot_pallet_handling_interfaces_action_DropoffPallet_ResultConstants.PALLET_DROPOFF_INTERRUPTED = 7
srsbot_pallet_handling_interfaces_action_DropoffPallet_ResultConstants.FIFO_LANE_EXIT_FAILED = 8
srsbot_pallet_handling_interfaces_action_DropoffPallet_ResultConstants.CANCELED = 9
srsbot_pallet_handling_interfaces_action_DropoffPallet_ResultConstants.STATE_INVALIDATED = 10
srsbot_pallet_handling_interfaces_action_DropoffPallet_ResultConstants.UNKNOWN_ERROR_CASE = 11
module.exports = {
  srsbot_pallet_handling_interfaces: {
    action: {
      DropoffPallet_FeedbackConstants: srsbot_pallet_handling_interfaces_action_DropoffPallet_FeedbackConstants,
      DropoffPallet_ResultConstants: srsbot_pallet_handling_interfaces_action_DropoffPallet_ResultConstants,
      PickupPallet_FeedbackConstants: srsbot_pallet_handling_interfaces_action_PickupPallet_FeedbackConstants,
      PickupPallet_ResultConstants: srsbot_pallet_handling_interfaces_action_PickupPallet_ResultConstants,
    },
    msg: {
      LiftStateConstants: srsbot_pallet_handling_interfaces_msg_LiftStateConstants,
      RobotWorkflowStateConstants: srsbot_pallet_handling_interfaces_msg_RobotWorkflowStateConstants,
    },
  },
}

The weird naming is because some interfaces have the same name but in different packages. So made it do explicit naming for everything.

Copy link

@mgabeler-lee-6rs mgabeler-lee-6rs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we'll follow up later to cleanup the ros/nodejs versions it uses for running the tests

@dnikitop dnikitop merged commit 1115719 into develop Oct 17, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants