A wrapper for roslibjs that is more fault-tolerant and easier to use
npm install @ifollow/ros-clientRoslibjs Client
====
This is a wrapper around the roslibjs package aiming to improve shortcomings of the original roslib package by introducing a fluent API as well as some useful error and fault handling mechanisms.
For the official roslibjs repository please head to https://github.com/RobotWebTools/roslibjs
It includes documentation about interacting with the robot.
listener.dispose()
var client = new RosClient({
url: "ws://ifollow-server:9090"
});
client.service.call(
"/get_robot_for_picking",
"ifollow_ll_msgs/AssignRobotGlobalStateMachine",
{})
`
Retrieving a robot name means client can now connect to the robot as follow:
`
var client = new RosClient({
url: "ws://ilogistics-2-0001:9090"
});
`
> Be aware that retrieved robot name is ilogistics_2_0001 and url uses ilogistics-2-0001
$3
This feature is an asynchronous service, for which you can use the Promise.then method to get the result as follow:
`
client.action.send(
'/task_manager/picking_care_server',
'ifollow_ll_msgs/TaskManagerOrderAction',
{
label: 'A random name you choose',
overwrite: true,
actions: [
{ label: '', order: '', optional_success: false, retry_count: 0},
...
!!!! See parameters definition below !!!
]
},
undefined, // if not used, timeout must be undefined
function (feedback) {
console.log("Feedback: ", feedback);
},
function () {
console.log("Timed out!");
// In that case, you can, as an example, cancel the group
},
function (result) {
console.log("Result: ", result);
})
`
#### Group of actions structure
| Data | Type | Description |
|---|---|---|
| label |string | Give it a name |
| overwrite | bool | Wether this group will override the previously sent ones or just stack |
| actions | action[] | List of the actions to perform |
#### Action structure
| Data | Type | Description |
|---|---|---|
| label |string | Label of the action (see below) |
| order | string | Order of the action (see below) |
| optional_success | bool | Wether the action is optional or mandatory |
| retry_count | uint_8 | If the action is mandatory, the robot will retry the action this number of time |
#### Actions type
| Label | Order | Description |
|---|---|---
| AutoNav | Stop point label | Sends robot to a location point
| Lift | Up | Lift up the plate
| Lift | Down | Lift down the plate
| Procedure | GetOutOfRoll | Goes out of the roll
| Procedure | SetAvailable | Release robot from duty as it was assigned when requesting a robot
| Procedure | Dock | Go to charging station
| Procedure | Undock | Goes out of charging station
| Wait | Number of seconds or 'Pause' | Pause robot in between two actions
#### Feedback structure
| Data | Type | Description |
|---|---|---|
| id_group | int | Group id |
| group_label | string | Group name you provided calling the action |
| instuction_position_in_the_group | int | |
| number_of_instructions_in_the_group |int | |
| id_action | int | |
| label_action | string | Label of the action you provided calling the action |
| order_action | string | Order of the action you provided calling the action |
| result | int | Type of result (see below) |
#### Result structure
| Data | Type | Description |
|---|---|---|
| output | int | Type of result |
#### Result type
| Label | Value | Description |
|---|---|---|
| OUTPUT_PENDING | 0 | |
| OUTPUT_ACTIVE | 1 | |
| OUTPUT_PREEMPTED | 2 | |
| OUTPUT_SUCCEEDED | 3 | |
| OUTPUT_ABORTED | 4 | |
| OUTPUT_REJECTED | 5 | |
| OUTPUT_PREEMPTING | 6 | |
| OUTPUT_RECALLING | 7 | |
| OUTPUT_RECALLED | 8 | |
| OUTPUT_LOST | 9 | |
| OUTPUT_OVERWRITING | 10 | |
| OUTPUT_OVERWRITTEN | 11 | |
| OUTPUT_STALLED | 12 | |
| OUTPUT_BUSY | 13 | |
$3
This feature is a synchronous service:
`
client.service.call(
'/task_manager/pause_current_group',
'ifollow_ll_msgs/PauseTaskManagerGroup',
{
pause: true or false
})
`
$3
This feature is an asynchronous service, for which you can use the Promise.then method to get the result as follow:
`
client.action.send(
'/task_manager/cancel_group',
'ifollow_ll_msgs/CancelTaskManagerGroup',
{
group_label: 'The name you chose before'
})
``