poppy-robot-core
v12.0.1
Published
Remotely drive/query Poppy/Poppy Ergo Jr robots.
Downloads
27
Maintainers
Readme
Poppy Robot Core
This module is dedicated to remotely drive/query robots of the Poppy project family.
Below a script example and its execution:
const { createPoppy, createScript } = require('poppy-robot-core')
const script = createScript()
.select('all') // Select all motors
.speed(150) // Set their speeds
.stiff() // Make them programmatically "drivable"
.goto(0, 5, true) // Then move them to '0' degree in 5s, awaiting the end of movement
.select('m1') // Select 'm1'
.goto('150', 1) // And send instruction to move it to 150 degrees in 1s without awaiting the end of the movement
.select('m6') // Select motor 'm6'
.rotate(90, 0.5, true) // And rotate it by +90 degrees in half of second.
.rotate(-90, 0.5) //...
createPoppy().then(async poppy => {
await poppy.exec(script)
// Other nice stuff with the poppy instance, next to this script execution
...
})
Next an example of querying registers:
const { createPoppy } = require('poppy-robot-core')
createPoppy().then(poppy => poppy.query({
motors: ['m1', 'm2'],
registers: ['present_position', 'goal_position']
})).then(console.log)
// will display
// {
// m1: {present_position: 10, goal_position: 80},
// m2: {present_position: 0, goal_position: -90},
// }
It has been done aiming to easily and automatically connect to any kind of/configuration of robot driven by the pypot library (a live discovering of the targeted robot is performed in order to get its structure aka aliases and motors).
Note this module is based on the REST API exposed by the pypot library and then, depends on its release (see prerequisite).
Table of Contents
- Prerequisite
- Install
- Configuring Connection to Poppy
- Writing Scripts
- Examples
- API
- Known Limitations
- Credits
- License
Prerequisite
This module requires the pypot REST API v4.0.0 aka Poppy software ^v4.0.0 installed on robot.
Install
npm i poppy-robot-core
Configuring Connection to Poppy
By default, the poppy robot core performs a live discovering of the target robot using default connection settings for a Poppy Ergo Jr aka setting are respectively set to 'poppy.local' and 8080 for host and port for the pypot REST API.
Users can easily set their own settings through optional arguments of the createPoppy factory.
const { createPoppy } = require('poppy-robot-core')
const config = {
host: poppy1.local,
port: 8081
}
const poppy = createPoppy(config)
Refer to the module API for further details or, in an easier way, users can use the poppy-robot-cli module that re-export api of this module and provides a set of additional functionalities for such purpose (flags automatically appended to the node command line to set hostname/port or using a config file to store them).
Writing Scripts
The poppy robot core module is provided with a script execution engine and then, users, can write their own scripts to test complex combination of actions.
Such scripts are written in javascript language but all technical 'difficulties' have been hidden as much as possible and then, it allows users writing their own scripts without any particular knowledges/skills on javascript.
A set of examples of scripts are available into a dedicated repository. In this case too, their javascript-technical matters have been reduced insofar as possible or explained when needed.
At last, users can refers to the Script API for further details.
Examples
A set of scripts are available into a dedicated repository.
API
See API.md for more details.
Known Limitations
This module have been only tested with the Poppy Ergo Jr (aka with a set of dynamixel XL-320). As it communicates with the robot via the REST API of the pypot library, it should work with any robots of the poppy family.
position/rotate functions of Script/ExtMotorRequest: Awaiting end of movement i.e. setting the 'wait' argument to 'true' is based on the velocity of dynamixel XL-320 in order to compute/estimate the movement duration. The value is 0.666 degree per second (see documentation).
Credits
- Nicolas Barriquand (nbarikipoulos)
License
The poppy-robot-core is MIT licensed. See LICENSE.