Skip to content
Snippets Groups Projects
Commit 23a85f31 authored by Simon Oehrl's avatar Simon Oehrl
Browse files

Merge branch 'feature/rework_mesh_loading' into 'main'

Adding stuff from testing with Pete

See merge request !12
parents 559af471 2b711a89
No related branches found
No related tags found
1 merge request!12Adding stuff from testing with Pete
Pipeline #299522 passed
{
"robots": [
"./robots/crawler.json"
],
"ship": {
"rosbridge": {
"uri": "wss://localhost/rosbridge"
},
"topics": {
"streamed_mesh": "/mesh_publisher/get_mesh"
}
},
"transformTree": {
"rosbridge": {
"uri": "wss://localhost/rosbridge"
}
}
}
\ No newline at end of file
{
"rosbridge": {
"uri": "wss://localhost/rosbridge"
},
"type": "SMV",
"name": "Crawler",
"topics": {
"pose": "",
"images": [
{
"topic": "/IFM/color/image_raw/compressed",
"name": "Camera"
}
]
},
"mesh": {
"uri": "meshes/crawler/Altiscan.gltf",
"transform": {
"translation": [
0,
0.06,
0
],
"rotation": [
0,
-90,
180
],
"scale": [
1,
1,
1
]
}
},
"services": {
"prepareMission": "/mission_manager/prepare_missions",
"executeMission": "/mission_manager/execute_missions"
},
"missionFrame": "world",
"poseFrame": "base_footprint"
}
\ No newline at end of file
{
"robots": [
"./robots/uib_drone.json"
"./robots/crawler.json"
],
"ship": {
"rosbridge": {
"uri": "ws://127.0.0.1:9090"
},
"static_mesh": {
"uri": "meshes/Porto_230616_122018.gltf",
"tf_frame": "mesh_ref",
"transform": {
"rotation": [
-90,
0,
180
]
}
"topics": {
"streamed_mesh": "/mesh_publisher/get_mesh"
}
},
"transformTree": {
......
......@@ -5,15 +5,20 @@
"type": "SMV",
"name": "Crawler",
"topics": {
"pose": "/mesh_pf1/pose",
"images": []
"pose": "",
"images": [
{
"topic": "/IFM/color/image_raw/compressed",
"name": "Camera"
}
]
},
"mesh": {
"uri": "meshes/crawler/Altiscan.gltf",
"transform": {
"translation": [
0,
0.1,
0.06,
0
],
"rotation": [
......@@ -29,9 +34,9 @@
}
},
"services": {
"prepareMission": "foo",
"executeMission": "foo"
"prepareMission": "/mission_manager/prepare_missions",
"executeMission": "/mission_manager/execute_missions"
},
"missionFrame": "world",
"poseFrame": "world"
"poseFrame": "base_footprint"
}
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
#
# Wavefront material file
# Converted by Meshlab Group
#
newmtl material_0
Ka 0.200000 0.200000 0.200000
Kd 1.000000 1.000000 1.000000
Ks 1.000000 1.000000 1.000000
Tr 1.000000
illum 2
Ns 0.000000
map_Kd Altiscan2_color.png
import { Messages } from "./ROS"
import geometry_msgs from "./ROS/geometry_msgs";
import mesh_msgs from "./ROS/mesh_msgs";
import { Service } from "./service";
export enum MissionType {
......@@ -32,4 +33,12 @@ export type Services = {
response: boolean
},
},
GetGeometry: {
Request: {
uuid: string
},
Response: {
mesh_geometry_stamped: mesh_msgs['MeshGeometryStamped']
}
}
}
import { useEffect, useState } from "react";
import { useCallback, useEffect, useState } from "react";
import { Service as ROSService } from "roslib";
import { Services } from "./BugWright2";
import { useConnection } from "./store";
......@@ -27,9 +27,11 @@ export function useService<ServiceType extends string & keyof Services>(uri?: st
[connection?.rosbridge, name, serviceType]
);
return (request: Services[ServiceType]['Request']) => {
const callback = useCallback((request: Services[ServiceType]['Request']) => {
return new Promise<Services[ServiceType]['Response']>((resolve, reject) => {
service?.callService(request, (response) => resolve(response), reject);
});
};
}, [service]);
return callback;
}
import { EventHandlers } from "@react-three/fiber/dist/declarations/src/core/events";
import { useEffect, useState } from "react";
import { useEffect, useMemo, useState } from "react";
import { BufferGeometry, DoubleSide, Float32BufferAttribute, Uint32BufferAttribute } from "three";
import { Messages } from "../../common/ROS";
import { useService } from "../../common/service";
import mesh_msgs from "../../common/ROS/mesh_msgs";
import { useTopic } from "../../common/store";
export interface StreamedMeshProps extends EventHandlers {
rosbridgeURI: string;
topic: string;
......@@ -11,7 +14,19 @@ export interface StreamedMeshProps extends EventHandlers {
}
const StreamedMesh = (props: StreamedMeshProps) => {
const mesh = useTopic(props.rosbridgeURI, props.topic, 'mesh_msgs/MeshGeometryStamped');
const getGeometry = useService(props.rosbridgeURI, props.topic, 'GetGeometry');
const [mesh, setMesh] = useState<mesh_msgs['MeshGeometryStamped']>();
useEffect(() => {
console.log("UseEffect");
if (mesh) return;
getGeometry({ uuid: "" })
.then((value: { mesh_geometry_stamped: mesh_msgs['MeshGeometryStamped'] }) => { setMesh(value.mesh_geometry_stamped); })
.catch((reason) => { console.log("Error loading Mesh: " + reason); });
}, [getGeometry]);
// const mesh2 = useTopic(props.rosbridgeURI, props.topic, 'mesh_msgs/MeshGeometryStamped');
const [geometry, setGeometry] = useState<BufferGeometry>();
useEffect(() => {
......
import { PropsWithoutRef, useEffect, useMemo, useRef, useState } from 'react';
import { Euler, Group, Object3D, Quaternion, Vector3 } from 'three';
import { Euler, Group, MathUtils, Object3D, Quaternion, Vector3 } from 'three';
import { useTopic } from '../../common/store';
import { Robot as RobotConfig } from '../../schemas/Robot.schema';
import { Frame } from './TF2';
......@@ -19,7 +19,7 @@ export default function Robot(props: PropsWithoutRef<RobotProps>) {
const static_quaternion = new Quaternion();
if (props.config.mesh?.transform?.rotation) {
static_quaternion.setFromEuler(new Euler(props.config.mesh.transform.rotation[0], props.config.mesh.transform.rotation[1], props.config.mesh.transform.rotation[2]), true);
static_quaternion.setFromEuler(new Euler(MathUtils.degToRad(props.config.mesh.transform.rotation[0]), MathUtils.degToRad(props.config.mesh.transform.rotation[1]), MathUtils.degToRad(props.config.mesh.transform.rotation[2]), "XYZ"), true);
}
return (
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment