Skip to content

Changes to support new tacho driver updates #152

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

Merged
merged 5 commits into from
May 8, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions autogen/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ exports.extraLiquidFilters = {
json_stringify: function(value) {
return JSON.stringify(value);
},
trim: function(value) {
return value.trim();
},
//evaluates expression as JavaScript in the given context
eval: function (expression, context) {
var vm = require('vm');
Expand Down
136 changes: 89 additions & 47 deletions spec.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
{
"meta": {
"version": "1.0.0",
"supportedKernel": "v3.16.7-ckt21-9-ev3dev"
"version": "1.1.0",
"specRevision": 0,
"supportedKernel": {
"pattern": "{upstream_version}-{kernel}-{flavour}",
"kernels": [
"10-ev3dev",
"10-rc1-ev3dev"
]
}
},
"classes": {
"motor": {
Expand All @@ -19,7 +26,7 @@
],
"docsLink": "http://www.ev3dev.org/docs/drivers/tacho-motor-class/",
"systemClassName": "tacho-motor",
"systemDeviceNameConvention": "motor{0}",
"systemDeviceNameConvention": "*",
Copy link
Member

Choose a reason for hiding this comment

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

What's this?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's a workaround for the fact that we have two types of motors - the Firgellis have a device name of linear* while all others are motor* - if you instantiate using ev3dev.Motor and then change the driver type to a linear motor, the device name changes to linear*.

You can always instantiate the right motor type and get the more precise motor name

"systemProperties": [
{ "name": "Address", "systemName": "address", "type": "string", "readAccess": true, "writeAccess": false,
"description": [
Expand Down Expand Up @@ -59,8 +66,14 @@
"description": [
"Returns the number of tacho counts in one rotation of the motor. Tacho counts",
"are used by the position and speed attributes, so you can use this value",
"to convert rotations or degrees to tacho counts. In the case of linear",
"actuators, the units here will be counts per centimeter."
"to convert rotations or degrees to tacho counts. (rotation motors only)"
]
},
{ "name": "Count Per M", "systemName": "count_per_m", "type": "int", "readAccess": true, "writeAccess": false,
"description": [
"Returns the number of tacho counts in one meter of travel of the motor. Tacho",
"counts are used by the position and speed attributes, so you can use this",
"value to convert from distance to tacho counts. (linear motors only)"
]
},
{ "name": "Driver Name", "systemName": "driver_name", "type": "string", "readAccess": true, "writeAccess": false,
Expand All @@ -78,8 +91,7 @@
"description": [
"Writing sets the duty cycle setpoint. Reading returns the current value.",
"Units are in percent. Valid values are -100 to 100. A negative value causes",
"the motor to rotate in reverse. This value is only used when `speed_regulation`",
"is off."
"the motor to rotate in reverse."
]
},
{ "name": "Encoder Polarity", "systemName": "encoder_polarity", "type": "string", "readAccess": true, "writeAccess": true,
Expand All @@ -91,6 +103,13 @@
"`inversed`."
]
},
{ "name": "Full Travel Count", "systemName": "full_travel_count", "type": "int", "readAccess": true, "writeAccess": false,
"description": [
"Returns the number of tacho counts in the full travel of the motor. When",
"combined with the `count_per_m` atribute, you can use this value to",
"calculate the maximum travel distance of the motor. (linear motors only)"
]
},
{ "name": "Polarity", "systemName": "polarity", "type": "string", "readAccess": true, "writeAccess": true,
"description": [
"Sets the polarity of the motor. With `normal` polarity, a positive duty",
Expand Down Expand Up @@ -130,6 +149,13 @@
"rotations or degrees."
]
},
{ "name": "Max Speed", "systemName": "max_speed", "type": "int", "readAccess": true, "writeAccess": false,
"description": [
"Returns the maximum value that is accepted by the `speed_sp` attribute. This",
"may be slightly different than the maximum speed that a particular motor can",
"reach - it's the maximum theoretical speed."
]
},
{ "name": "Speed", "systemName": "speed", "type": "int", "readAccess": true, "writeAccess": false,
"description": [
"Returns the current motor speed in tacho counts per second. Note, this is",
Expand All @@ -139,49 +165,43 @@
},
{ "name": "Speed SP", "systemName": "speed_sp", "type": "int", "readAccess": true, "writeAccess": true,
"description": [
"Writing sets the target speed in tacho counts per second used when `speed_regulation`",
"is on. Reading returns the current value. Use the `count_per_rot` attribute",
"to convert RPM or deg/sec to tacho counts per second."
"Writing sets the target speed in tacho counts per second used for all `run-*`",
"commands except `run-direct`. Reading returns the current value. A negative",
"value causes the motor to rotate in reverse with the exception of `run-to-*-pos`",
"commands where the sign is ignored. Use the `count_per_rot` attribute to convert",
"RPM or deg/sec to tacho counts per second. Use the `count_per_m` attribute to",
"convert m/s to tacho counts per second."
]
},
{ "name": "Ramp Up SP", "systemName": "ramp_up_sp", "type": "int", "readAccess": true, "writeAccess": true,
"description": [
"Writing sets the ramp up setpoint. Reading returns the current value. Units",
"are in milliseconds. When set to a value > 0, the motor will ramp the power",
"sent to the motor from 0 to 100% duty cycle over the span of this setpoint",
"when starting the motor. If the maximum duty cycle is limited by `duty_cycle_sp`",
"or speed regulation, the actual ramp time duration will be less than the setpoint."
"are in milliseconds and must be positive. When set to a non-zero value, the",
"motor speed will increase from 0 to 100% of `max_speed` over the span of this",
"setpoint. The actual ramp time is the ratio of the difference between the",
"`speed_sp` and the current `speed` and max_speed multiplied by `ramp_up_sp`."
]
},
{ "name": "Ramp Down SP", "systemName": "ramp_down_sp", "type": "int", "readAccess": true, "writeAccess": true,
"description": [
"Writing sets the ramp down setpoint. Reading returns the current value. Units",
"are in milliseconds. When set to a value > 0, the motor will ramp the power",
"sent to the motor from 100% duty cycle down to 0 over the span of this setpoint",
"when stopping the motor. If the starting duty cycle is less than 100%, the",
"ramp time duration will be less than the full span of the setpoint."
]
},
{ "name": "Speed Regulation Enabled", "systemName": "speed_regulation", "type": "string", "readAccess": true, "writeAccess": true,
"description": [
"Turns speed regulation on or off. If speed regulation is on, the motor",
"controller will vary the power supplied to the motor to try to maintain the",
"speed specified in `speed_sp`. If speed regulation is off, the controller",
"will use the power specified in `duty_cycle_sp`. Valid values are `on` and",
"`off`."
"are in milliseconds and must be positive. When set to a non-zero value, the",
"motor speed will decrease from 0 to 100% of `max_speed` over the span of this",
"setpoint. The actual ramp time is the ratio of the difference between the",
"`speed_sp` and the current `speed` and max_speed multiplied by `ramp_down_sp`."
]
},
{ "name": "Speed Regulation P", "systemName": "speed_pid/Kp", "type": "int", "readAccess": true, "writeAccess": true,
{ "name": "Speed P", "systemName": "speed_pid/Kp", "type": "int", "readAccess": true, "writeAccess": true,
"description": [
"The proportional constant for the speed regulation PID."
]
},
{ "name": "Speed Regulation I", "systemName": "speed_pid/Ki", "type": "int", "readAccess": true, "writeAccess": true,
{ "name": "Speed I", "systemName": "speed_pid/Ki", "type": "int", "readAccess": true, "writeAccess": true,
"description": [
"The integral constant for the speed regulation PID."
]
},
{ "name": "Speed Regulation D", "systemName": "speed_pid/Kd", "type": "int", "readAccess": true, "writeAccess": true,
{ "name": "Speed D", "systemName": "speed_pid/Kd", "type": "int", "readAccess": true, "writeAccess": true,
"description": [
"The derivative constant for the speed regulation PID."
]
Expand Down Expand Up @@ -304,22 +324,6 @@
}
]
},
{
"propertyName": "Speed Regulation",
"values": [
{ "name": "on",
"description": [
"The motor controller will vary the power supplied to the motor",
"to try to maintain the speed specified in `speed_sp`."
]
},
{ "name": "off",
"description": [
"The motor controller will use the power specified in `duty_cycle_sp`."
]
}
]
},
{
"propertyName": "Stop Command",
"values": [
Expand Down Expand Up @@ -349,6 +353,7 @@
},
"largeMotor": {
"friendlyName": "Large Motor",
"systemDeviceNameConvention": "*",
"description": [
"EV3 large servo motor"
],
Expand All @@ -359,6 +364,7 @@
},
"mediumMotor": {
"friendlyName": "Medium Motor",
"systemDeviceNameConvention": "*",
"description": [
"EV3 medium servo motor"
],
Expand All @@ -367,6 +373,39 @@
],
"inheritance": "motor"
},
"nxtMotor": {
Copy link
Member

Choose a reason for hiding this comment

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

I think we should do something like we did for specialSensorTypes for these, because they should be able to be completely automatically generated.

Copy link
Member

Choose a reason for hiding this comment

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

"friendlyName": "NXT Motor",
"systemDeviceNameConvention": "*",
"description": [
"NXT servo motor"
],
"driverName": [
"lego-nxt-motor"
],
"inheritance": "motor"
},
"firgelli50Motor": {
"friendlyName": "Firgelli L12 50 Motor",
"systemDeviceNameConvention": "linear{0}",
"description": [
"Firgelli L12 50 linear servo motor"
],
"driverName": [
"fi-l12-ev3-50"
],
"inheritance": "motor"
},
"firgelli100Motor": {
"friendlyName": "Firgelli L12 100 Motor",
"systemDeviceNameConvention": "linear{0}",
"description": [
"Firgelli L12 100 linear servo motor"
],
"driverName": [
"fi-l12-ev3-100"
],
"inheritance": "motor"
},
"dcMotor": {
"friendlyName": "DC Motor",
"description": [
Expand Down Expand Up @@ -1411,11 +1450,12 @@
{ "name" : "Right", "entries" : ["Red Right", "Green Right"] }
],
"colors": [
{ "name" : "Black", "value" : [ 0.0, 0.0 ] },
{ "name" : "Red", "value" : [ 1.0, 0.0 ] },
{ "name" : "Green", "value" : [ 0.0, 1.0 ] },
{ "name" : "Amber", "value" : [ 1.0, 1.0 ] },
{ "name" : "Orange", "value" : [ 1.0, 0.5 ] },
{ "name" : "Yellow", "value" : [ 0.5, 1.0 ] }
{ "name" : "Yellow", "value" : [ 0.1, 1.0 ] }
]
},
"button": {
Expand All @@ -1441,9 +1481,11 @@
{ "name" : "Led2", "entries" : ["Blue Led2"] }
],
"colors": [
{ "name" : "Black", "value" : [ 0.0 ] },
{ "name" : "Blue", "value" : [ 1.0 ] }
]
}
}
}
}