Skip to content

Instantly share code, notes, and snippets.

View mxgrey's full-sized avatar
🦀
Rustacean

Grey mxgrey

🦀
Rustacean
View GitHub Profile
@mxgrey
mxgrey / gist:ce991a208e367d5a5f9c8617f7463463
Created February 14, 2023 04:56
Automatic Inheritance by Deref
use std::{sync::Arc, ops::Deref};
fn main() {
listen(Arc::new(Foo));
}
fn listen<N: Noisy>(n: N) {
n.noise();
}
@mxgrey
mxgrey / optional_trait_bounds.rs
Last active February 19, 2023 06:17
Sketch of optional trait bounds idea for Rust
fn serve_customer<C>(mut customer: &C) -> u32
where
// When a trait bound is wrapped in [], that means it's optional
C: Noisy + [Hungry] + [Thirsty]
{
// Mandatory trait bounds can always be called
let order = customer.talk();
let food_price: u32 = with C as Hungry {
// This block only gets compiled if C implements Hungry.
@mxgrey
mxgrey / flat.rs
Created February 27, 2023 07:34
Example of a flat mesh being outline by bevy_mod_outline
use std::f32::consts::PI;
use bevy::{
prelude::*,
render::mesh::{PrimitiveTopology, Indices},
window::close_on_esc,
};
use bevy_mod_outline::*;
@mxgrey
mxgrey / Cargo.toml
Created February 28, 2023 13:00
z-fighting test for depth bias
[package]
name = "depth_bias_test"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
bevy = "0.9"
#![feature(array_windows)]
use std::f32::consts::PI;
use bevy::{
prelude::*,
render::mesh::{PrimitiveTopology, Indices},
window::close_on_esc,
};
@mxgrey
mxgrey / weird.rs
Last active March 6, 2023 15:11
Strange bug where outlines diverge from their object
use bevy::{
prelude::*,
render::mesh::shape::{Box, UVSphere},
window::close_on_esc,
};
use bevy_mod_outline::*;
#[bevy_main]
fn main() {
@mxgrey
mxgrey / main.rs
Last active December 11, 2023 15:16
Draft of proposed API usage for async rclrs
fn main() {
// BasicExecutor will be the executor that we provide out-of-the-box from rclrs.
// Using the plain new() constructor for BasicExecutor will create a Context using
// the user's command line arguments.
let mut executor = rclrs::BasicExecutor::new();
// String-like types can be automatically converted into NodeOptions.
let node = executor.create_node("mobility");
// Create a "worker" that manages some data that callbacks associated with this worker
ros2 launch rmf_demos_gz_classic office.launch.xml
[INFO] [launch]: All log files can be found below /home/krms/.ros/log/2024-01-29-14-19-10-683060-krms-115814
[INFO] [launch]: Default logging verbosity is set to INFO
[INFO] [rmf_traffic_schedule-1]: process started with pid [115816]
[INFO] [rmf_traffic_blockade-2]: process started with pid [115818]
[INFO] [building_map_server-3]: process started with pid [115820]
[INFO] [schedule_visualizer_node-4]: process started with pid [115822]
[INFO] [fleetstates_visualizer_node-5]: process started with pid [115824]
[INFO] [rmf_visualization_building_systems-6]: process started with pid [115826]
[INFO] [navgraph_visualizer_node-7]: process started with pid [115828]
@mxgrey
mxgrey / gist:b7a8ede7075cf7764e622ce8e2996888
Created February 28, 2024 02:46
cancellation_test.json
{
"phases": [
{
"activity": {
"category": "go_to_place",
"description": "hardware_2"
},
"on_cancel": [
{
"category": "go_to_place",
@mxgrey
mxgrey / cmake_install.cmake
Created March 19, 2024 18:37
bad resource generation
if("x${CMAKE_INSTALL_COMPONENT}x" STREQUAL "xUnspecifiedx" OR NOT CMAKE_INSTALL_COMPONENT)
file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/share/ament_index/resource_index/rust_packages" TYPE FILE FILES "/usr/local/google/home/mxgrey/projects/ros2-rolling/build/libstatistics_collector/ament_cmake_index/share/ament_index/resource_index/rust_packages/libstatistics_collector")
endif()