I want to enable a gripper to do pick&place an object from a shelf. For this, I am trying to use trajectry optimization using KInematic Trajectory Optimization and I am using this deepnote. But the problem is when I add an object to the plant, also the object is considered in the optimization prog. How can I exclude this object from being considered in the optimization.
I am kinda new to the drake and I kinda don't know how to exclude an object from conraints.
Thanks in advance, I am kinda in rush :)
drake
Short answer: I think you want to create a separate MultibodyPlant to your KinematicTrajectoryOptimization that doesn't have the objects in it.
More generally, it's very common to have multiple plants flowing through your robot + control stack, e.g. one for the "robot model" and another for the "robot + objects in the world" model. (It's reasonable that the physics engine's model of the world would be different than the model in the head of the robot). Currently in Drake, it's more recommended to just load two independent plants, rather than try to add/remove objects from an existing plant.
Related
In the case of Compass Gait Limit Cycle, the system is obtained from 'models/compass_gait_limit_cycle.urdf' and the context is from CreateDefaultContext().
These define the configuration vector q as [x, y, θ_1, θ_2]^T in my recognition.
In the case that URDF model is more complicated(e.g. having several branched structures), I could obtain the system and the context as the same way, but I could not understand which component of q is corresponding to the joint in URDF file.
Are there some way to know the correspondence relationship?
The best way I need is get the index of q from the name of the joint from URDF file.
But anything is ok if I could know the correspondence.
In addition, I want to know the way to rearrange the order of components of q(and also of qd and qdd).
For example, in the case of compass gait, the default order is [x, y, θ_1, θ_2] and the new order is [θ_1, θ_2, x, y] or something like this.
Perhaps, creating context by myself is the best way.
But I do not understand the context perfectly, so I need some instruction to crate it.
I am using pydrake on ubuntu 20.04.
Thank you for your answer.
If you are using MultibodyPlant (loaded from URDF), then MultibodyPlant controls the order of the variables in the context state vector. As you say, it is intended that you access them from the joint accessors. In python, I have a simple method that packs them into a namedview, which is very convenient for working with them: https://github.com/RussTedrake/underactuated/blob/ee7a2041047772f823d0dc0dd32e992196b2a670/underactuated/utils.py#L32-L86
You can see how I use this in a number of examples in the underactuated notes. Perhaps the littledog example shows it best.
If you want to use them in a different order in a different system, then I would recommend adding something like a MatrixGain system that implements a permutation matrix to rearrange them.
I'm trying to use Drake's inverse dyanmics controller on an arm with a floating base, and based on this discussion it seems like the most straightforward way to go about this is to use two separate plants since the controller only supports fully actuated systems.
Following Python bindings error when adding two plants to a scene graph in pyDrake, I attempted to create two plants using the following code:
def register_plant_with_scene_graph(scene_graph, plant):
plant.RegsterAsSourceForSceneGraph(scene_graph)
builder.Connect(
plant.get_geometry_poses_output_port(),
scene_graph.get_source_pose_port(plant.get_source_id()),
)
builder.Connect(
scene_graph.get_query_output_port(),
plant.get_geometry_query_input_port(),
)
builder = DiagramBuilder()
scene_graph = builder.AddSystem(SceneGraph())
plant_1 = builder.AddSystem(MultibodyPlant(time_step=0.0))
register_plant_with_scene_graph(scene_graph, plant_1)
plant_2 = builder.AddSystem(MultibodyPlant(time_step=0.0))
register_plant_with_scene_graph(scene_graph, plant_2)
which produced the error
AttributeError: 'MultibodyPlant_[float]' object has no attribute 'RegsterAsSourceForSceneGraph'
Which seems odd because according to the documentation, the function should exist.
Is this function available in the python bindings for drake? Also, more broadly, is this the correct way to approach using the inverse dynamics controller on a free-floating manipulator?
Inverse dynamics takes desired positions, velocities, and accelerations and computes the required torques. If your robot has a floating base, then you cannot accept arbitrary acceleration commands. For instance the total center of mass of your robot will be falling according to gravity; any acceleration that does not satisfy this requirement will not have a feasible solution to the inverse dynamics. I think there must be something more that we need to understand about your problem formulation.
Often when people ask this question, they are thinking of a robot that is relying on contact forces in addition to generalized force/torques in order to achieve the requested accelerations. In that case, the problem needs to include those contact forces as decision variables, too. Since contact forces have unilateral constraints (e.g. feet cannot pull on the ground), and friction cone constraints, this inverse dynamics problem is almost always formulated as a quadratic program. For instance, as in this paper. We don't currently provide that QP formulation in Drake, but it is not hard to write it against the MathematicalProgram interface. And we do have some older code that was removed from Drake (since it wasn't actively developed) that we can point you to if it helps.
Is there any way to create a weld joint during a simulation in Drake? For context, I am trying to get a robot to assemble furniture, and whenever it attaches two pieces of furniture (ie. a chair leg with its base), I want to weld them together.
I have attempted using LinearBushingRollPitchYaw, with large damping and spring constant values, but I was either not getting "welds" or there would be a segfault.
I have also thought about stopping the simulation, doing the weld, and restarting the simulation, but I was not sure if this was practical.
Is something like this possible in Drake?
Thanks.
Here's some related information:
https://github.com/RobotLocomotion/drake/issues/14200
https://github.com/RobotLocomotion/drake/pull/15137
https://github.com/RobotLocomotion/drake/issues/13291
I'm trying to think of the best way to conduct some sort of analysis between two 3D models of the same object.
The first scan is of the original item and the second scan is after it has been put under some load x.
An example would be trying to find the difference between two types of metal.
I would like to be able to scan the initial metal cylinder, apply a measured load, scan it again, and then finally apply some sort of algorithm to compare the difference.
Is it possible to do this efficiently (maybe using Mablab) over say 50 - 100 items for an object around 5inch^3?
I am assuming I will need to work out some sort of utility function as the total mass should be the same?
Would machine learning be beneficial in this case?
Any suggestions or direction would be amazing.
Thank you :)
EDIT: The scan files are coming through as '.stl'
I am creating a snake game in C#/XNA for fun but it's a good opportunity to practice some good object design.
Snake Object
There's a snake object which is essentially a linked list, each node being a vector with X & Y co-ordinates which relate to the map.
Also a few properties such as whether the snake has just eaten (in which case, the last body node is not removed for this update), direction that the snake is moving in etc.
Map Object
The map (game area) holds its contents inside 2D array of integers - using an array of primitives to store the map should keep down memory consumption and be quicker (and easier) to iterate over than an array of vectors.
Contents are defined inside an enum {Empty, Wall, Snake, Food} which are then stored inside the array at the relevant co-ordinates.
A reference is also kept to the snake object within the map so that every call to render, loops through the nodes that make up the snake and render it into the correct position on the map.
Question!!
My question is... is this coupling too tight, in which case are there any suggestions (i.e. observer pattern) or is it okay for this situation...
I've tried to think of a way to decouple the snake from needing to know the co-ordinate system being used by the map, but can't think of a way to make it work and keep the positions each nodes relative to each-other.
Any answers appreciated, cheers!
"is this coupling too tight?" No, it isn't.
In this case, the code required to decouple it is bigger, more complicated, and harder to maintain than the code required to simply implement it with the coupling.
Furthermore, there is always going to be some level of coupling required. Coupling to "a coordinate system" is usually one of them in game development. You could, in fact, rigorously decouple your map and snake objects (again, not worth the effort), but they still need to share a common coordinate system in order to communicate.
I think you are already hinted the answer yourself. The current design of making the Snake referenced in the map is tight coupling between the two.
You might want to consider creating another Interface such as MapListener that the Snake will implement. The Snake will listen to the event that maps will publish and react to it, effectively making the Snake the subscriber for the event that the Map is publishing (such as rendering in the correct position as you say). You could even have ArrayList of Listeners so you have the flexibility of adding new Object in the map that would react to the event in the maps as your game becoming more complex.
For reference on creating the Listener, see this SO question How can I code a custom listener. While this example is listening for finishing download, you should be able to see the pattern in the accepted answer for creating custom listener for your game. Let me know if you need any clarification and I will adapt the code to fit your case.
Here is simple first thought structure:
create an interface called MapContainable
//marker interface
interface MapContainable {
}
interface MapMovable extends MapContainable {
///map movement specific contract methods here
}
class Snake implements MapMovable {
.....
}
This way, your map need not know if there are concrete objects called snake, food etc. You snake object need not know the existence of a Map. A snake just moves!