Replies: 1 comment
-
Hello, i tested the code you provided against foxglove-bridge but i found no issues at all. This is the foxglove-based subscriber that i used to perform the test: const { FoxgloveClient } = require("@foxglove/ws-protocol");
const { parse } = require("@foxglove/rosmsg");
const { MessageReader } = require("@foxglove/rosmsg-serialization");
const { WebSocket } = require("ws");
const def0 = `# foxglove_msgs/LocationFix
# A navigation satellite fix for any Global Navigation Satellite System
# Generated by https://github.com/foxglove/schemas
# Timestamp of the message
time timestamp
# Frame for the sensor. Latitude and longitude readings are at the origin of the frame.
string frame_id
# Latitude in degrees
float64 latitude
# Longitude in degrees
float64 longitude
# Altitude in meters
float64 altitude
# Position covariance (m^2) defined relative to a tangential plane through the reported position. The components are East, North, and Up (ENU), in row-major order.
float64[9] position_covariance
uint8 UNKNOWN=0
uint8 APPROXIMATED=1
uint8 DIAGONAL_KNOWN=2
uint8 KNOWN=3
# If \`position_covariance\` is available, \`position_covariance_type\` must be set to indicate the type of covariance.
uint8 position_covariance_type
`;
async function main() {
const client = new FoxgloveClient({
ws: new WebSocket(`ws://localhost:8765`, [FoxgloveClient.SUPPORTED_SUBPROTOCOL]),
});
let reader = null;
client.on("advertise", (channels) => {
for (const channel of channels) {
if (channel.topic !== "/test_topic") {
continue;
}
console.log("subscribing");
client.subscribe(channel.id);
reader = new MessageReader(parse(def0));
}
});
client.on("message", ({ subscriptionId, timestamp, data }) => {
const message = reader.readMessage(data);
console.log({
subscriptionId,
timestamp,
message,
});
});
}
main().catch(console.error); output:
Make sure that the message definition is the same on both sides and that you are using |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
I am trying to publish a custom message type and consume it with foxglove/foxglove bridge. I generated a definition from this
https://github.com/foxglove/schemas/blob/main/schemas/ros1/LocationFix.msg
. And it seems correct to me:I am publishing it like this:
The problem is, that the message arrives but has incorrect values. For example, it assigns the 1 to Longitude instead of Altitude and some fields are not sent at all. Here is an example:
It seems there are some kinds of precision issues here? I would appreciate any help. Thanks!
Beta Was this translation helpful? Give feedback.
All reactions