rethinkrobotics-opensource / rosnodejs Goto Github PK
View Code? Open in Web Editor NEWClient library for writing ROS nodes in JavaScript with nodejs
Home Page: http://wiki.ros.org/rosnodejs/overview
License: Apache License 2.0
Client library for writing ROS nodes in JavaScript with nodejs
Home Page: http://wiki.ros.org/rosnodejs/overview
License: Apache License 2.0
I have a workspace with the following structure:
- src
- CMakeLists.txt
- packages_folder_1 (symlink)
- folder_1_msgs
- CMakeLists.txt
- package.xml
- msg
- MessageDef1.msg
...
- folder_1_other
...
- packages_folder_2 (symlink)
...
My ROS_PACKAGE_PATH
points to the src
directory and the default indigo location.
Running the rosnodejs.loadAllPackages()
in the above tree does not build folder_1_msgs
. However, if I copy the folder_1_msgs
out from packages_folder_1
and put it directly under src
, the messages get built.
See https://github.com/RethinkRobotics-opensource/rosnodejs/pull/65/files#r173348798.
To reproduce, just run the example shown in the code:
let ac = rosNode.getActionClient({
type: "turtle_actionlib/ShapeAction",
actionServer: "/turtle_shape"
});
Which will result in an error like this:
/home/cfritz/work/rosjs/src/lib/NodeHandle.js:210
throw new Error(`Unable to create action client ${actionServer} without type - got ${type}`);
^
Error: Unable to create action client [object Object] without type - got undefined
at NodeHandle.actionClientInterface (/home/cfritz/work/rosjs/src/lib/NodeHandle.js:210:13)
at Object.getActionClient (/home/cfritz/work/rosjs/src/index.js:334:20)
at Timeout._onTimeout (/home/cfritz/work/rosjs/src/examples/turtle.js:82:26)
at ontimeout (timers.js:475:11)
at tryOnTimeout (timers.js:310:5)
at Timer.listOnTimeout (timers.js:270:5)
It's easy to fix. I'll create a PR.
Hi @chris-smith,
This is Minggang from Open Source Technology Center, Intel. I am very glad to meet you on Github:smile:, we just implemented rclnodejs, a Node.js client of ROS2.0, which has the same functions as you did in ROS 1.0, but for the next generation.
My section focuses on promoting the web technology to different fields, like robotics. So I think we can collaborate if possible, especially to escalate the influence of Node.js ecosystem in ROS. As web has built-in advantage in cross-platform and visualization and easy to develop, we want to use JavaScript to facilitate the development of ROS apps. Meanwhile, we hope to leverage platform, like NW.js and modules of RWT to make some wonderful usages in ROS2.0 to show the capabilities of web and improve its status in ROS.
Thanks!
According to 2x2 matrix in http://wiki.ros.org/actionlib/DetailedDescription#The_Messages, the meaning of a cancellation message varies based on goal ID and the timestamp. Currently, ActionClientInterface's cancel
always sets the timestamp to the current time. So there is no way to cancel all goals if some goals have a timestamp in the future.
I realize that's a an uncommon use case, but it seems like a good idea to try to match the documentation as closely as possible. Perhaps we could change cancel(goalId)
to cancel(goalId, stamp)
. If stamp
is undefined, then set it to the current time, so the behavior is unchanged for existing users.
It would also be nice to have an unambiguous cancelAllGoals()
, which is a convenience function for cancel()
. Both the Python and C++ action clients have a cancelAllGoals
method.
Thoughts?
As pointed out in #22, the md5sums for service classes generated by the on-the-fly code is currently wrong. The correct md5sum for a service is the md5sum of the concatenation of the request and the response md5 text -- which is the message text without a trailing new line. For instance, for SetBool, the text to use for md5 is:
bool databool success
string message
(Yes, there is no whitespace or new line between the two parts!).
If we want to write an action server, how do we get the contents of the goal message? It looks like when an ActionServer constructs a GoalHandle, it only provides a goal ID, but the contents of the goal are not saved anywhere.
Is there any way to get list of all the services, similar to the rosnodejs.getAvailableMessagePackages()
function ?
I guess ros_msg_utils
package need to be ported to services for this, can you please help ?
I'm running this in an electron app, and to initialize the node it takes a good minute. Is this normal behaviour?
rosnodejs.initNode('my_node',{onTheFly: true})
.then(() => {
let nh = rosnodejs.nh;
console.log('Initialized');
paramName = "Hello";
paramValue = "Goodbty";
// a whole new parameter-y world
nh.setParam(paramName, paramValue);
console.log('Set Param');
nh.getParam(paramName)
.then((paramValue) => {
console.log(paramValue);
});
});
Is it possible to get the image stream from ROS like rospy does it?
Hey guys,
rosnodejs had this nice ability to find and load .msg files for the used message types and generate the appropriate js class definitions on the fly -- and I extended that to .srv files, too. This essentially brings what you currently seem to have in genjs into the library itself, i.e., it saves a compilation step. I was thinking of porting that functionality to rosjs. Are you open to pull requests like that?
In general I'd like to contribute to rosjs if I can. I was just pointed to this project by Brandon Alexander, who wrote rosnodejs. I was going to complete that project, but it seems that you guys are way ahead of me and already rewrote the whole thing in super clean ES6 :-)
Anyhow, please let me know how you feel about contributions in general and this particular feature in particular.
If roscore is disconnected, can this library fire an event?
if no, then we can have lazy checking of the last communication happened some 20 secs ago, so its not connected..(communication might count everything from messages, services, api calls)
What is your thought on implementing this?
use case:
This library is used in an nodejs application running on same/different system as roscore, and is connected, its publishing some action based commands(for example /cmd_vel) to roscore..
If in doing so, if roscore is crashed/ killed/ disconnected, this lib should fire an event so that the software can stop sending(atleast show status that roscore is disconnected)
Hi,
I had recently installed rosnodejs as described in your instructions. Basically, just did this:
npm install rosnodejs
I am using an ubuntu 16.04 with kinetic system.
After downloading the latest version (rosnodejs@^2.2.0) I am not seeing the latest version with a disabled version of the latching in action lib.
Could you let me know how could I get the latest version of rosnodejs?
Renato.
Hi,
I'm running a gazebo simulation on a computer, and the ros master + my rosnodejs nodes on another.
However, i always get this error trying to subscribe to topics:
/home/rafael/Workspace/HyDrone/drone_ws/src/hydrone/interface/node_modules/rosnodejs/dist/utils/log/ConsoleLogStream.js:51 [WARN] [1533916224.920] (ros.rosnodejs): Error during subscriber /clock registration: Error: Unable to find host and port from uri http://192.168.0.109 :34763/ with regex /(?:http:\/\/|rosrpc:\/\/)?([a-zA-Z\d\-.:]+):(\d+)/
write @ /home/rafael/Workspace/HyDrone/drone_ws/src/hydrone/interface/node_modules/rosnodejs/dist/utils/log/ConsoleLogStream.js:51
/home/rafael/Workspace/HyDrone/drone_ws/src/hydrone/interface/node_modules/rosnodejs/dist/utils/log/ConsoleLogStream.js:51 [WARN] [1533916224.926] (ros.rosnodejs): Error during subscriber /rosout registration: Error: Unable to find host and port from uri http://192.168.0.109 :39363/ with regex /(?:http:\/\/|rosrpc:\/\/)?([a-zA-Z\d\-.:]+):(\d+)/
write @ /home/rafael/Workspace/HyDrone/drone_ws/src/hydrone/interface/node_modules/rosnodejs/dist/utils/log/ConsoleLogStream.js:51
/home/rafael/Workspace/HyDrone/drone_ws/src/hydrone/interface/node_modules/rosnodejs/dist/utils/log/ConsoleLogStream.js:51 [WARN] [1533916224.927] (ros.rosnodejs): Error during subscriber /mavros/local_position/pose registration: Error: Unable to find host and port from uri http://192.168.0.109 :39363/ with regex /(?:http:\/\/|rosrpc:\/\/)?([a-zA-Z\d\-.:]+):(\d+)/
write @ /home/rafael/Workspace/HyDrone/drone_ws/src/hydrone/interface/node_modules/rosnodejs/dist/utils/log/ConsoleLogStream.js:51
My code:
function listener(){
rosnodejs.initNode('/listener_node', {rosMasterUri: "http://127.0.0.1:11311"}).then((nh) => {
let local_position_sub = nh.subscribe('/mavros/local_position/pose', geometry_msgs.PoseStamped, local_position_cb);
let rosout_sub = nh.subscribe('/rosout', rosgraph_msgs.Log, rosout_cb);
});
}
Also probably worth mentioning: 192.168.0.109 is the ip address of the computer running the simulation.
Hi.
I am trying to use rosnodejs for my project, but it is ignoring the remappings set by the command-line arguments or roslaunch files.
I have a node like this
rosnodejs.initNode('foo').then(....);
and want to rename it with roslauch like this
<node pkg="..." name="foo" type="..."> <remap from="foo" to="bar"/> </node>
, but rosnode list
is just showing /foo.
Is there a quick way to fix this problem?
I am using the version 2.1.1.
Thank you.
ROS supports a lot of namespacing options (base, relative, global, and private) and validation that we don't provide. We should. NodeHandle
's should provide quick access to nested resources.
const nh = rosnodejs.nh('/my/local/namespace');
const sub = nh.subscribe('input_data'); // subscribe to /my/local/namespace/input_data
I'm trying to include rosnodejs into a project, which uses messages that are not in 'std_msgs'. These messages are defined in our own packages. I want to subscribe to these custom messages, but I cannot find a way to do so. Plugging in std_msgs.msg.String gives me the following error :
"[ERROR] [1504707499.036] (ros.rosnodejs): Client [/jsNode] wants topic /robotcommands to have datatype/md5sum [std_msgs/String/992ce8a1687cec8c8bd883ec73ca41d1], but our version has [myproject_msgs/RobotCommand/bd4e3fb1e84585feac0a9174a19b71be]. Dropping connection.
"
code :
let ros = require('rosnodejs');
let std_msgs = ros.require('std_msgs')
ros.initNode('/jsNode')
.then((rosNode) => {
rosNode.subscribe('/robotcommands', std_msgs.msg.String, msg => {
console.log(msg)
})
})
Is there a way to describe to these messages?
Logging right now is very rough. It should be cleaned up, provide similar options/interface to rospy
or roscpp
, log to /rosout
, etc. I've started reworking it so that you could do something like
rosnodejs.logInfo("You should know about this");
rosnodejs.logInfoThrottle(1000, "You should know about this every so often");
rosnodejs.logInfoOnce("I'm not going to repeat myself");
or alternately ask for a logger and not need to pass around rosnodejs
let log = rosnodejs.createLogger("myCustomLogger");
log.info("Hey, that's cool");
I'm currently wrapping a bunyan
logger and and plan to expose some ability to add streams and modify formatting. Throttling right now is done by temporarily storing the first argument (excluding throttle time) in a set - this would make formatted strings strongly preferred over composed ones because:
let i = 0;
setInterval(() => {
log.infoThrottle(1000, "Counter: %d", i); // prints once a second
log.infoThrottle(1000, "Counter: " + i); // prints twice a second
++i;
}, 500);
Very open to recommendations about other ways to do this or anything else, but before diving into this too much more I wanted to at least publicly check if people (a) hate some of this, (b) hate all of this, or (c) have other opinions/thoughts.
Hi,
I would like to know if I should subscribe manually to get result and the feedback when using the actionClientInterface
or if there is another way
Any help would be very helpful.
Regards,
Renato.
In the macOS environment, the value here may be EISDIR.
This time it will run error
Error: EISDIR: illegal operation on a directory, mkdir '/'
MessageLoader.js:118
(node:83626) UnhandledPromiseRejectionWarning: Error: EISDIR: illegal operation on a directory, mkdir '/'
please fix it๏ผlike:
if (err && err.code !== 'EEXIST' && err.code !== 'EISDIR')
If there is no ROS master available, rosnodejs
will wait in a loop for one to appear. However, it currently kicks out with an error:
$ node example.js
[/my_node][INFO] 2016-05-18 11:25:14.994-0400: Connecting to ROS Master at http://localhost:11311
/home/imcmahon/dev/gennodejs_tests2/src/rosnodejs/utils/xmlrpc_utils.js:7
log.debug('Calling method ' + method +': ' + data);
^
TypeError: Cannot read property 'debug' of undefined
at Object.call (/home/imcmahon/dev/gennodejs_tests2/src/rosnodejs/utils/xmlrpc_utils.js:7:8)
at ClientRequest.<anonymous> (/home/imcmahon/dev/gennodejs_tests2/src/rosnodejs/utils/xmlrpc_utils.js:23:16)
at emitOne (events.js:90:13)
at ClientRequest.emit (events.js:182:7)
at Socket.socketErrorListener (_http_client.js:306:9)
at emitOne (events.js:90:13)
at Socket.emit (events.js:182:7)
at emitErrorNT (net.js:1265:8)
at _combinedTickCallback (internal/process/next_tick.js:74:11)
at process._tickCallback (internal/process/next_tick.js:98:9)
Please respect the original rosjs creators with acknowledgement citations (e.g., [Osentoski et al. 2011 ICRA]):
Thank you,
-Chad
I need to publish "mavros_msgs/Mavlink" from rosnodejs.
which has an array of UINT64 (Uint64[]) inside the message.
All I've done is receiving raw data packet as a buffer, split it and assign to the others field.
For receiving and reading, I've followed the code and found that it used "BN.JS"
, I used it to translate and the use them successfully.
but for the UInt64[], I still have no idea how to pack it as ROSMSG.
Should I pack it as Array of Bignum [BN:XXXXXXX , BN:YYYYYYYY , .... ]
or send it as the array of buffer?
Also, it has a header which requires timestamp.
Again, I've followed the code and found that I can call rosnode.Time to get now() from that util,
is that the correct thing to do?
I've check the source code, In
deserializeInnerMessage (message.js)
reading buildin-type array one-by-one using buffer.readUInt8 ,eating-up the CPU.
I followed the instruction on rosnodejs_examples, but could not run neither of the nodes. The error is:
/home/user/rosnodejs_ws/src/rosnodejs_examples/scripts/talker.js:28
const std_msgs = rosnodejs.require('std_msgs').msg;
^
TypeError: Cannot read property 'msg' of undefined
at Object.<anonymous> (/home/user/rosnodejs_ws/src/rosnodejs_examples/scripts/talker.js:28:47)
at Module._compile (module.js:410:26)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Function.Module.runMain (module.js:442:10)
at startup (node.js:136:18)
at node.js:966:3
So, apparently the standard messages were not built. In the dev-space under gennodejs
I only see the packages local to the workspace.
I tried to add rosnodejs.loadAllPackages()
before loading std_msgs
, but it made no difference.
My configuration is:
Any clue what could be wrong?
please upload 3.0.0 release to npm, can't wait. thank you!
I was trying to get some simple examples working based on the currently published npm version (claims to be 1.0.0
).
For the life of me, I could not get even the simplest messages to send or be received without node crashing.
cameron@AuntPolly:~$ rostopic pub /topic std_msgs/String test
cameron@AuntPolly:~/ros/node-test-recv$ npm start
> [email protected] start /home/cameron/ros/node-test-recv
> babel-node .
[/test-rcv][INFO] 2017-01-04 23:40:39.426-0800: Connecting to ROS Master at http://localhost:11311
[INFO] 2017-01-04 23:40:39.962-0800: Connected to master!
[sub/topic][WARN] 2017-01-04 23:40:39.980-0800: Error requesting topic: Error: connect ECONNREFUSED 127.0.1.1:60412, undefined
test
[sub/topic][INFO] 2017-01-04 23:40:48.703-0800: Pub AuntPolly:37577 sent END
[sub/topic][INFO] 2017-01-04 23:40:48.704-0800: Pub AuntPolly:37577 closed
/home/cameron/ros/node-test/node_modules/xmlrpc/lib/server.js:41
if (that._events.hasOwnProperty(methodName)) {
^
TypeError: that._events.hasOwnProperty is not a function
at /home/cameron/ros/node-test/node_modules/xmlrpc/lib/server.js:41:24
at Deserializer.callback (/home/cameron/ros/node-test/node_modules/xmlrpc/lib/deserializer.js:65:7)
at Deserializer.onDone (/home/cameron/ros/node-test/node_modules/xmlrpc/lib/deserializer.js:92:12)
at emitNone (events.js:86:13)
at SAXStream.emit (events.js:185:7)
at SAXParser.SAXStream._parser.onend (/home/cameron/ros/node-test/node_modules/sax/lib/sax.js:184:8)
at emit (/home/cameron/ros/node-test/node_modules/sax/lib/sax.js:615:33)
at end (/home/cameron/ros/node-test/node_modules/sax/lib/sax.js:654:3)
at SAXParser.end (/home/cameron/ros/node-test/node_modules/sax/lib/sax.js:149:24)
at SAXStream.end (/home/cameron/ros/node-test/node_modules/sax/lib/sax.js:234:16)
The exact sequence / set of messages printed changes based on if published or receiver is started first, if roscore is restarted before, or if I use a rosnodejs
based trivial publisher. I can elaborate on this if requested.
I then tried using the kinetic-dev
branch here. That gave very different errors. Probably because it's not a stable branch. Moving on...
I finally tried the version tagged 1.1
in git (which according to packages.json
is version 1.0.0
still) and the simple finally examples worked as expected.
How to catch error for a subscriber initiated with different type (say std_msgs/UInt16MultiArray) and receives in different type(say std_msgs/String)?
the library catches this error somewhere, but can it emit this event ?
[ERROR] [1492332455.554] (ros.rosnodejs): topic types do not match: [std_msgs/UInt16MultiArray] vs. [std_msgs/String]
What would be the best way to include more loggers into rosnodejs? As in rospy (logging) and roscpp (log4cxx), we would like to keep adding existing loggers such like syslog (bunyan-syslog) or customised ones.
rosnodejs deserialize buildin-type array data oneByone using deserializePrimitive(), can we use typeArray instead?
run code :
var req = rosnodejs.require('srv').Request();
req.city = "city111";
serviceClient.call(req, (resp) => { console.log(resp); });
but can't received response data
SericeClient.js 158 line
key: 'call',
value: function call(request, resolve, reject) {
var _this2 = this;
return new Promise(function (resolve, reject) {
var newCall = new ServiceCall(request, resolve, reject);
i change
key: 'call',
value: function call(request, resolve, reject) {
var _this2 = this;
var _resolve = resolve;
return new Promise(function (resolve, reject) {
if(_resolve != undefined) resolve = _resolve;
var newCall = new ServiceCall(request, resolve, reject);
i wonder that is ok
At least when using on-the-fly message definitions, when publishing messages that include strings with Unicode characters this fatal error occurs:
RangeError: Index out of range
at checkInt (buffer.js:1187:11)
at Buffer.writeUInt32LE (buffer.js:1265:5)
at /home/cfritz/tmp/out_of_bounds/node_modules/rosnodejs/dist/utils/messageGeneration/messages.js:545:16
at Array.forEach (<anonymous>)
at serializeInnerMessage (/home/cfritz/tmp/out_of_bounds/node_modules/rosnodejs/dist/utils/messageGeneration/messages.js:540:15)
at Function.Message.serialize (/home/cfritz/tmp/out_of_bounds/node_modules/rosnodejs/dist/utils/messageGeneration/messages.js:488:5)
at Object.serializeMessage (/home/cfritz/tmp/out_of_bounds/node_modules/rosnodejs/dist/utils/tcpros_utils.js:195:18)
at msgQueue.forEach.msg (/home/cfritz/tmp/out_of_bounds/node_modules/rosnodejs/dist/lib/impl/PublisherImpl.js:224:43)
at Array.forEach (<anonymous>)
at PublisherImpl._handleMsgQueue (/home/cfritz/tmp/out_of_bounds/node_modules/rosnodejs/dist/lib/impl/PublisherImpl.js:219:16)
This is the minimal code I was able to reproduce this with:
const rosnodejs = require('rosnodejs');
rosnodejs
.initNode('/test', { onTheFly: true })
.then((rosNode) => {
const pub = rosNode.advertise('/rosout', 'rosgraph_msgs/Log', {});
const Log = rosnodejs.require('rosgraph_msgs').msg.Log;
const msg = 'โ'; // a unicode character
pub.publish(new Log({
level: 1,
name: rosNode.nodeName,
msg,
file: '',
function: 'test',
line: 0,
topics: []
}));
});
rosnodejs.initNode('/my_node', { rosMasterUri: `http://robot:11311` }).then(n => {
n.subscribe(
'/global_state', 'std_msgs/msgs/Int8MultiArray',
(data) => {
console.log('SUB DATA ', data, data.data)
},
{ queueSize: 1, throttleMs: 1000 }
)
}).catch(e => console.log(e))
yields:
[INFO] [1507485372.058] (ros): Connected to master at http://robot:11311!
[WARN] [1507485372.062] (ros): Unable to setup ros logging stream
[WARN] [1507485372.066] (ros): Unable to setup ros logging services
[ERROR] [1507485372.251] (ros.rosnodejs): Exception trying to subscribe to topic /global_state
Error: Unable to include message package std_msgs - Error: Couldn't find preset "env" relative to directory "/opt/ros/kinetic/share/gennodejs/ros/std_msgs"
at Object.loadMessagePackage (/home/mtl/work/emt/node_modules/rosnodejs/dist/utils/message_utils.js:172:13)
at Object.getHandlerForMsgType (/home/mtl/work/emt/node_modules/rosnodejs/dist/utils/message_utils.js:214:14)
at NodeHandle.subscribe (/home/mtl/work/emt/node_modules/rosnodejs/dist/lib/NodeHandle.js:126:44)
at /home/mtl/work/emt/src/main.js:184:9
at process._tickCallback (internal/process/next_tick.js:103:7)
I can't seem to trace the error referring to "preset 'env'" any farther back then NodeHandle's subscribe function. But all the generated messages appear to correctly be in the path /opt/ros/kinetic/share/gennodejs/ros/std_msgs/msg/
so I'm wondering if I'm misusing the API somehow? std_msgs/msgs/Int8MultiArray
vs std_msgs/Int8MultiArray
doesn't seem to make a difference.
rosbag
seems to depend on publishers including the message definition in their connection header although that field is not mentioned in the spec. Without the message definition, rosbag
tools complain about mismatching md5 sums.
Including the message definition still results in different bags, though I'm not certain if this is a problem.
Message definition in connection header for a rosnodejs
bag
message_definition=# A Pose with reference coordinate frame and timestamp
Header header
Pose pose
Message definition in connection header for a rospy
bag
message_definition=# A Pose with reference coordinate frame and timestamp
Header header
Pose pose
================================================================================
MSG: std_msgs/Header
# Standard metadata for higher-level stamped data types.
# This is generally used to communicate timestamped data
# in a particular coordinate frame.
#
# sequence ID: consecutively increasing ID
uint32 seq
#Two-integer timestamp that is expressed as:
# * stamp.sec: seconds (stamp_secs) since epoch (in Python the variable is called 'secs')
# * stamp.nsec: nanoseconds since stamp_secs (in Python the variable is called 'nsecs')
# time-handling sugar is provided by the client library
time stamp
#Frame this data is associated with
#0: no frame
#1: global frame
string frame_id
================================================================================
MSG: geometry_msgs/Pose
# A representation of pose in free space, composed of postion and orientation.
Point position
Quaternion orientation
================================================================================
MSG: geometry_msgs/Point
# This contains the position of a point in free space
float64 x
float64 y
float64 z
================================================================================
MSG: geometry_msgs/Quaternion
# This represents an orientation in free space in quaternion form.
float64 x
float64 y
float64 z
float64 w
Can we make a transform_boardcaster in some way ?
http://wiki.ros.org/tf/Tutorials/Writing%20a%20tf%20broadcaster%20%28C%2B%2B%29
@IanTheEngineer Ive tried executing the same code that is available and I'm getting this error.
at one point i got an error saying that the package std_msgs was not defined, I've also tried reinstalling rosnodejs and npm just incase there were any problems while installing
Ive made a few changes so that i could debug ive attached the code below
forceFeedback.js.tar.gz
Is there any specific reason why this package has not been submitted for inclusion in the 3-day doc builder cycle on the farm? Searching for rosnodejs
in the Kinetic distribution.yaml yields no results, and the wiki page appears to have the package header hand crafted.
I can submit the PR against ros/rosdistro
, but first wanted to make sure there wasn't an actual reason that hadn't happened yet.
ActionClient and ActionServer use timeUtils.now()
throughout, but timeUtils.now()
gets the time from Date.now()
. This does not work when running in simulation. Should these be replaced with Time.now()
?
Getting the following error -
TypeError: Cannot read property 'split' of undefined
at Object.<anonymous> (/home/project/electron/project/app/node_modules/rosnodejs/dist/ros_msg_utils/lib/message_cache.js:24:35)
at Object.<anonymous> (/home/project/electron/project/app/node_modules/rosnodejs/dist/ros_msg_utils/lib/message_cache.js:65:3)
at Module._compile (module.js:569:30)
at Module._extensions..js (module.js:580:10)
at Object.require.extensions.(anonymous function) [as .js] (/home/project/electron/project/node_modules/babel-register/lib/node.js:152:7)
at Module.load (module.js:503:32)
at tryModuleLoad (module.js:466:12)
at Function.Module._load (module.js:458:3)
at Module.require (module.js:513:17)
at require (internal/module.js:11:18)
Node - v9.5.0
npm - v5.6.0
ROS Kinetic
I think the way the type names for an ActionClient are generated is inaccurate. If you create an action client for a type foo_msgs/Bar
(filename Bar.action), the correct message types are foo_msgs/BarActionGoal
, foo_msgs/BarActionFeedback
, etc.
This should be true even if the type name ends with "Action." For example, if the action type is foo_msgs/BarAction
(filename BarAction.action), the correct message types should be foo_msgs/BarActionActionGoal
, foo_msgs/BarActionActionFeedback
, etc.
The ActionServerInterface correctly appends "ActionGoal", "ActionFeedback", etc. to the base name of the action type. However, ActionClientInterface only appends "Goal", "Feedback", etc. The string "Action" is appended beforehand in NodeHandle.js, but only after this check:
if (!type.endsWith('Action')) {
type += 'Action';
}
If you have an action whose type name ends with "Action," this leads the ActionClientInterface to generate type names like foo_msgs/BarActionGoal
instead of foo_msgs/BarActionActionGoal
. This leads to md5 matching errors with other nodes, since foo_msgs/BarActionGoal
is also a valid type.
I think the fix should be simple: remove the three lines quoted above from NodeHandle.js, and change ActionClientInterface to always append "ActionGoal", "ActionFeedback", etc. to the type name.
Please let me know what you think. Is this just an edge case that should be fixed, or is it likely that lots of people depend on this behavior? If we want to fix it, I'd be happy to make the pull request.
Hi,
I was trying to understand the following code from your README file:
const nh = rosnodejs.nh;
const sub = nh.subscribe('/chatter', 'std_msgs/String', (msg) => {
console.log('Got msg on chatter: %j', msg);
});
But is ending not defining the node handler itself and in an error (NodeHandle.js:134). Shall I always use the rosnodejs.initNode way?
Regards,
Renato.
Hi,
I'm interested in creating a ROS web client and this seems to be the only way to do it while using Kinetic. However, there is something wrong with this since the npm test fails on 1) Logging Rosout Check Publishing and so on. Here is a part of the npm test output:
9 passing (17s)
18 failing
Logging Rosout Check Publishing:
Uncaught Error: not implemented
at DeserializeStream.Transform._transform (_stream_transform.js:142:9)
at DeserializeStream.Transform._read (_stream_transform.js:167:10)
at DeserializeStream.Transform._write (_stream_transform.js:155:12)
at doWrite (_stream_writable.js:292:12)
at writeOrBuffer (_stream_writable.js:278:5)
at DeserializeStream.Writable.write (_stream_writable.js:207:11)
at Socket.ondata (_stream_readable.js:528:20)
at readableAddChunk (_stream_readable.js:146:16)
at Socket.Readable.push (_stream_readable.js:110:10)
at TCP.onread (net.js:523:20)
DeserializeStream basic:
Error: not implemented
at DeserializeStream.Transform._transform (_stream_transform.js:142:9)
at DeserializeStream.Transform._read (_stream_transform.js:167:10)
at DeserializeStream.Transform._write (_stream_transform.js:155:12)
at doWrite (_stream_writable.js:292:12)
at writeOrBuffer (_stream_writable.js:278:5)
at DeserializeStream.Writable.write (_stream_writable.js:207:11)
at Context. (test/DeserializeStream.js:22:23)
DeserializeStream 2 chunks:
Error: timeout of 2000ms exceeded. Ensure the done() callback is being called in this test.
Any ideas? Is there something I'm missing here?
test_srvs
package of complex ROS Servicesrosjs
or gennodejs
See #12 (comment).
This is complicated slightly by the fact that pre-compiled message classes can be instantiated synchronously, whereas on-the-fly generation of message classes is asynchronous. So a unified interface may need to follow the asynchronous approach, i.e., use a callback rather than a return value.
Hi,
Many thanks for your library as it has become very useful. However, recently I had found some issues that perhaps you could help me to clarify.
I am trying to make use of custom defined messages from another module but I receive the error:
TypeError: Cannot read property 'msg' of undefined
I am including the custom message module in the package.xml as build_depend
and exec_depend
and in the CMakelists.txt in the parts related to find_package
and CATKIN_DEPENDS
of the "catkin_package".
I also tried to load the messages explicitly with rosnodejs.loadAllPackages();
before calling the require
of the custom-made module, but this only works when I execute the node inside the ROS module.
I installed the node_modules/ inside the ROS module itself. The file structure looks like this:
my_ws/
custom_messages_module/
msg/
myMessage.msg
error_module/
scripts/
node_modules/
package-lock.json
ros_node_script.js
user@host: ~/my_ws$ rosrun error_module ros_node_script.js
TypeError: Cannot read property 'msg' of undefined
The file ros_node_script.js would look like this:
#!/usr/bin/env node
const rosnodejs = require('rosnodejs');
rosnodejs.loadAllPackages();
const custom_messages_module = rosnodejs.require('custom_messages_module').msg;
Any idea would be very helpful.
Regards,
Renato.
We need to update the README to contain
rosjs
, papers, and previous projectsWe're thinking about renaming rosjs
but are unsure of what to call it. The name rosjs
originally belonged to a package developed at Brown for Rosbridge 1.0 - our repo is also specifically targeting Node.js so the name rosjs
could be misleading. rosnodejs
seems like an obvious answer, but there is also an existing deprecated rosnodejs project.
Our attempts to follow ROS client library naming conventions have apparently led us into a trap.
Have any thoughts, @baalexander?
This is the console output from my ROS workspace:
$ rosnode info /my_rosnodejs_node
--------------------------------------------------------------------------------
Node [/my_rosnodejs_node]
Publications:
* /chatter [std_msgs/String]
* /rosout [rosgraph_msgs/Log]
Subscriptions: None
Services:
* /my_rosnodejs_node/get_loggers
* /my_rosnodejs_node/set_logger_level
contacting node http://Artoo.local:39868 ...
ERROR: Communication with node[http://Artoo.local:39868] failed!
and the console.log reads the following:
ConsoleLogStream.js:56 [ERROR] [1481253678.610] (ros.rosnodejs): Not implementedwrite
@ ConsoleLogStream.js:56Logger._emit
@ bunyan.js:938(anonymous function)
@ bunyan.js:1037_handleGetBusInfo
@ RosNode.js:524emitThree @ events.js:116emit
@ events.js:194(anonymous function)
@ server.js:42callback
@ deserializer.js:65Deserializer.onDone
@ deserializer.js:92emitNone
@ events.js:86emit
@ events.js:185SAXStream._parser.onend
@ sax.js:190emit
@ sax.js:640end
@ sax.js:683end
@ sax.js:154SAXStream.end
@ sax.js:248onend
@ _stream_readable.js:511g
@ events.js:286emitNone
@ events.js:86emit
@ events.js:185endReadableNT
@ _stream_readable.js:974_combinedTickCallback
@ internal/process/next_tick.js:74_tickCallback
@ internal/process/next_tick.js:98
I'm trying to run this very trivial node program:
const rosnodejs = require('rosnodejs');
const std_msgs = rosnodejs.require('std_msgs');
rosnodejs.initNode('my_node')
.then(nh => {
const pub = nh.advertise('/topic', std_msgs.msg.String);
const msg = new std_msgs.msg.String();
msg.data = 'Hello!';
setInterval(() => {
pub.publish(msg);
}, 1000);
});
Using the kinetic-devel
git branch.
It connects to master just fine but then instantly fills the screen with repeated error messages.
[INFO] [1484793140.047] (ros): Connected to master at http://localhost:11311!
[ERROR] [1484793140.057] (ros.rosnodejs): Exception trying to advertise service /my_node/get_loggers
[WARN] [1484793140.058] (ros): Unable to setup ros logging services
[ERROR] [1484793140.063] (ros.rosnodejs): Error when publishing message on topic /rosout: TypeError: MessageClass.getMessageSize is not a function
at Object.serializeMessage (/home/cameron/ros/node-test/node_modules/rosnodejs/utils/tcpros_utils.js:264:34)
at msgQueue.forEach (/home/cameron/ros/node-test/node_modules/rosnodejs/lib/Publisher.js:168:43)
at Array.forEach (native)
at Publisher._handleMsgQueue (/home/cameron/ros/node-test/node_modules/rosnodejs/lib/Publisher.js:162:14)
at ClientQueue.handleClientMessages (/home/cameron/ros/node-test/node_modules/rosnodejs/utils/GlobalSpinner.js:45:22)
at GlobalSpinner._handleQueue (/home/cameron/ros/node-test/node_modules/rosnodejs/utils/GlobalSpinner.js:203:24)
at ontimeout (timers.js:365:14)
at tryOnTimeout (timers.js:237:5)
at Timer.listOnTimeout (timers.js:207:5)
[ERROR] [1484793140.063] (ros.rosnodejs): Error when publishing message on topic /rosout: TypeError:
...
I'm a little new to ROS still. The first error & warning looks like it's just that I don't have a ROS logger running.
I'm at a loss as to what the other errors are being caused by. Maybe that would be fixed by logger stuff. I haven't had the time to try it yet.
Any insight would be greatly appreciated.
There are subscribers, publishers, parameters, services... but nothing about tf!
Add basic parameter testing (get, set, delete, has) through expansion of test/utils/MasterStub
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.