I'm working on a project that has evolved so many times, I've really started thinking about writing a generic class that controls other nested generic classes.
The issue is, I have so many ways I could go about it that I've become completely overwhelmed. I've reviewed vectors and template class examples, but I truly have no idea how to begin.
Let me explain,
I need to be able to use this template to create an object that I control directly.
The main, top level object, is the robot I'm working on documented here (Probably not helpful to read, included as reference):
Github: MiddleMan5/Onyx-BeagleBone which pulls from:
Github: MiddleMan5/Project-Onyx-Quadruped
(New member 2-link restriction)
Which has the C++ Assembly.h file I'm working on making generic:
"Assembly File"
Now I'm sorry if my syntax is a little rusty, I'm very new to C++ in a general sense. I have great difficulty with pointers, object vectors, etc.
I'm really just looking to be guided in a general direction of study, and less a "Fix my code!" answer.
Bear with me as I may mar C++ terms:
I want to be able to create any type of robot configuration and manipulate EITHER it's individual assembly's End Effectors, or the entire chassis as a point particle physics object (if the robot is mobile).
This would allow me to use the same template to create a robot arm as well as my intended Quadruped. (Which is, in reality, a solid mobile mass that has a center and 4 "Arms"
Each initialized Robot must contain only one Body that in-itself contains at least one Base, one Joint, and one End Effector.
The creation of Top-Level object should fail if any of these things should fail to be included before Body.assemble creates the now-active robot. (Body.assemble creates Chassis Onyx)
I can now move the entire structure by saying something like Onyx.Leg(1).move(X,Y) or Onyx.rotate(X,45); //Move all legs to satisy final body rotation angle
Documented in my Brainstorming file here: Please at least skim.
This file contains diagrams and the "definitions" I'm using to prototype pseudo-code.
I only want one "Robot".h and "Robot".cpp to define actions, movements, sizes, shapes, etc. and one Main.cpp to provide entry into the code. (Maybe I'm asking a bit much) but logically to me, this seems do-able.
Includes:
Main.cpp
|_
| Onyx.h
|_Onyx.cpp //Body.move, body.rotate, body.raise
|_Assembly.h To create the body as a combination of assemblies
Onyx as a quadruped looks like this:
ONYX Complete Diagram Example:
EE EE
|| __ ||
| | | |
0__0+__+0__0
_||_
__0+_ _+ <- 0__
0 \/ 0 <-\
| | <- - "Leg" and Body are two attached assemblies inside one complete containing Robot chassis
|| || <-/
EE EE
Should be controlled like:
Onyx.EE1.moveTo(x,y);
or:
Onyx.moveTo(x,y);
Where I could further define gaits and parameters that would allow the robot ro take steps to move it's entire chassis to location (X, Y)
and has definitions for joints, links, and bases as such:
|Joint: Takes X and Y coordinates, rotates Link. ----0----
|__ End Effector: A joint combined with an attached Link. --------EE
|__ Base: A joint created that can be fixed statically through a link to another base joint
| |__ Can be attached actively to a link and a joint
| |__ Can be used as a static reference to an assembly (Such as a leg) and attached to a joint on a different plane
|
|__ Primary Joint: the joint(s) that attach directly to the Body's base(s)
|Link: A length of physical mass between a joint.
|__Segment: two or more attached in-line links (multiple links combined at different angles can specify independent shapes or masses).
Segments are useful for attaching spaced Bases. (Attach.Base(Segment1_2(End)); Segments can be attached either by their additive L1 or L2
I really am frustrated because the project has very quickly become way to complicated for me to even understand. This is why I was looking at creating a template. But it doesn't seem like accessing an object's object's method (Onyx.leg.move) is even possible in C++. Am I wrong?
If you actually read through to the end I want to give you a hand. Any advice you have on areas of study (Or advice to make my question clearer) would be GREATLY valued.
Thank You
Edit:
Okay, I went ahead and created a Class 'Assembly', which has methods to access a private subclass 'assemble' which attaches a "Leg with links n" to the assembly (god I need a different name) with subclass's Base, Link, and End_Effector. I guess I'm going to have to write individual methods and method handlers for each subclass of a subclass. This seems way to ugly and complicated with plenty of room to make errors.
The pseudo-flow as follows:
Assembly Onyx //Creates Robot: Onyx
Onyx.assemble(4, 3, 2); //Adds 4 legs each with 3 joints which includes 2 axis
for(i; 0 ---> 3)
Onyx.numleg_numL_length(i,1,114); //Defines L1 of Leg1 as 114mm
Onyx.numleg_numL_length(i,2,140); //Defines L2 of Leg1 as 114mm
and on and on and on and on.
Please tell me there's a simple trick that allows me to assign multiple variables to a named class instead of this infinite chain of methods functions and subclasses
Related
I have made a LazyRow that i now want to be able to get the scrollposition from. What i understand Scrollablerow has been deprecated. (correct me if im wrong) The thing is that i cant make a scrollablerow so i thought lets make a lazy one then. but i have no clue how to get scrollposition from the lazyrow. i know how to get index but not position if that eaven exists. here is what i have tried.
val scrollState = rememberScrollState()
LazyRow(scrollState = scrollstate){
}
For LazyScrollers, there are separate LazyStates.
I think there's just one, in fact, i.e. rememberLazyListState()
Pass that as the scroll state to the row and then you can access all kinds of info. For example, you could get the index of the first visible item, as well as its offset. There are direct properties for this stuff in the object returned by the above initialisation. You can also perform some more complex operations using the lazyListState.layoutInfo property that you get.
Also, ScrollableRow may be deprecated as a #Composable, but it is just refactored, a bit. Now, you can use the horozontalScroll() and verticalScroll() Modifiers, both of which accept a scrollState parameter, which expects the same object as the one you've created in the question.
Usually, you'd use LazyScrollers since they're not tough to implement and also are super-performant, but the general idea is that they are used with large datasets whereas non-lazy scrollers are okay for small sized lists and stuff. This is because the lazy ones cache only a small fraction of the entire list, making your UI peformant, which is not something regular scrollers do, and not a problem for small datasets.
They're like equivalents of RecyclerView from the View System
A repository pattern is there to abstract away the actual data source and I do see a lot of benefits in that, but a repository should not use IQueryable to prevent leaking DB information and it should always return domain objects, not DTO's or POCO's, and it is this last thing I have trouble with getting my head around.
If a repository pattern always has to return a domain object, doesn't that mean it fetches way too much data most of the times? Lets say it returns an employee domain object with forty properties and in the service and view layers consuming that object only five of those properties are actually used.
It means the database has fetched a lot of unnecessary data a pumped that across the network. Doing that with one object is hardly noticeable, but if millions of records are pushed across that way and a lot of of the data is thrown away every time, is that not considered bad behavior?
Yes, when adding or editing or deleting the object, you will use the entire object, but reading the entire object and pushing it to another layer which uses only a fraction of it is not utilizing the underline database and network in the most optimal way. What am I missing here?
There's nothing preventing you from having a separate read model (which could a separately stored projection of the domain or a query-time projection) and separating out the command and query concerns - CQRS.
If you then put something like GraphQL in front of your read side then the consumer can decide exactly what data they want from the full model down to individual field/property level.
Your commands still interact with the full domain model as before (except where it's a performance no-brainer to use set based operations).
I am currently working on a small project using ECS and DirectX12 and wanted to get some advice on if there is a "preferred" way or alternative ways to solving my issue.
Let me give a very basic layout to an entity which can be rendered
<entity name = "Cube">
<component = Transform ..blah blah>
<component = Mesh = "cube.txt"> // holds data about verts/indicies etc.
<component = Materials = "Mat1"> // holds data about the materials etc.
</entity>
Approach 1
When the entities are loaded in, it would load each component. It gets to the mesh component and would now load in the mesh data and create the buffers needed and store them in the render system (by being able to get the render system from the world).
Say the next entity comes along and also wants the same mesh, it would check with the render system to see if it already exists and therefore would not need to load it in again but simply create a new copy for that entity.
Approach 2
Before loading in entities the render system would have a list of meshes to load in upfront (this means some list which would need updating each time a new mesh wants to be included into the system).
Now when the entities are loaded in they can just have a tag to match the tag on the mesh in the render system.
I am not really sure whats the best approach with this as I started working with approach 1 and find the mesh component handles the loading which does seem a simple and straightforward approach, however I have not done anything like this ECS approach before and wanted to get advice as I may have overlooked a far more preferred approach which is more effective.
The concern I am keeping in mind for work to be done later is the ability to handle batching objects using the same mesh types PSO's etc.
If you find that the first approach works for you right now, I'd say keep going with it until you need to definitively replace it with a system that can handle new functionality.
The second approach does sound like the "proper" way to do it, as in commercial game engines a list of assets is loaded in first on engine launch and most operations thereafter are carried out on the assumption of the mesh assets you need already existing (obviously not including things like procedural generation and so forth).
I found this useful gist that introduced me into Builder Pattern Design.
How would one implement this code to build a "Car" object with required and optional parameters based on configurations without writing dedicated builders?
Scenario 1
Build a car with 3 wheels, no body and no engine.
Scenario 2
Build a car with 2 wheels, with a body and an engine.
Scenario 3
Build a car with 1 wheel, no body and no engine.
Scenrion N
Some other random combination.
And let's imagine the "Car" object requires at least one wheel to be built.
I have stumbled upon a blog post that mentions a state machine approach but it still seems a bit messy to me.
The post: https://blog.jayway.com/2012/02/07/builder-pattern-with-a-twist/
what about following:
inject Configuration Context as an argument into method getCar() in class Director then build appropriate Car object there
comments in gist are self explanatory:
/* Builder is responsible for constructing the smaller parts /
/ Director is responsible for the whole process */
I'm trying to make my own full adder and some other devices as a sub-circuit in "Proteus" and use them several times in a bigger circuit.
The problem is when you copy a sub-circuit you need to rename all of its inner parts, otherwise, the parts with a same name in two sub-circuits would be considered as one, therefore you'd get some errors.
So I'd like to know if there is a way to define a full adder of my own and use it like "74LS183" which is a primitive device, and by primitive I mean it has been defined in the library.
From answer posted here
It's in the Proteus Help file:
SCHEMATIC CAPTURE HELP (F1) -> MULTI-SHEET DESIGNS -> Hierarchical Designs
See the section "Module Components":
Any ordinary component can be made into a module by setting the Attach Hierarchy Module checkbox on the Edit Component dialogue form.
The component's value is taken to be the name for the associated circuit,
and the component's reference serves as the instance name.
after this you can use your new implementation of that component with your new name. for making it available at library see "External Modules" section of proteus help.
The problem with copying is solved in "Proteus 8".not completely but sort of.
I mean you can copy a subcircuit without a need to change it's inner parts, but you must change the subcircuit name and I mean the bigger name above the subcircuit not the little one below it.
so there is no need to define a primitive.