I am working on balancing a leg using LQR. After reading the answers on the following thread I've decided to go about the problem in the same way, i.e. constraining the foot to the ground via pin joint:
How to use an LQR controller with collision geometry
To do this, I import two urdf files, one for the robot and one for the ground which leads to the robot topology as shown in the picture below.
The error occurs when I try to connect foot to the ground. I try to do this with the following piece of code:
builder = DiagramBuilder()
plant, scene_graph = AddMultibodyPlantSceneGraph(builder, time_step=0.0)
leg_instance = Parser(plant).AddModelFromFile("HoppingLeg/leg_v2/urdf/LEG_002_Foot_Hinge.urdf")
ground_instance = Parser(plant).AddModelFromFile("HoppingLeg/leg_v2/urdf/ground.urdf")
frame_foot = plant.GetFrameByName("Link_foot")
frame_ground = plant.GetFrameByName("ground")
joint_ground = RevoluteJoint(name="foot_ground",
frame_on_parent=frame_foot,
frame_on_child=frame_ground,
axis=np.array([1., 0., 0.]),
damping=0.0)
plant.AddJoint(joint_ground)
plant.Finalize()
After which drake tells me that I am forming a closed loop robot.
RuntimeError: This mobilizer is creating a closed loop since the outboard body already has an inboard mobilizer connected to it. If a physical loop is really needed, consider using a constraint instead.
I don't understand why adding this link leads to a closed loop robot as my base_link is not connected to the world or the ground. Additionally, I am not sure whether the direction of the arrows in the diagram generated by drake matter, but in the robot leg urdf, base_link is the parent link to which the other links are connected to. For example this is my join between base_link and Link_rail_y:
<joint
name="rail_y"
type="prismatic">
<origin
xyz="0 0 0"
rpy="0 0 0" />
<parent
link="base_link" />
<child
link="Link_rail_y" />
<axis
xyz="0 1 0" />
<limit
lower="-1.5"
upper="1.5" />
</joint>
The solution is to reverse the parent-child relationship so that the Link_Knee_pitch is a child of the Link_foot, etc. Right now, we only allow each body to have a single parent.
We should do this for you automatically, but haven't supported it yet. See https://github.com/RobotLocomotion/drake/issues/17429
Related
New to Lua scripting, so hopefully I'm using the right terminology to describe this, please forgive if I'm not, I'll get better over time....
I'm writing code for a game using Lua. And I have a function that sets a value. Now I need to "hold" this value for a set period of time after which it gets set to another value.
I'm trying to replicate this behavior:
Imagine a car-start key.
0 = off
1 = ignition on
2 = ignition on + starter -- this fires to get the engine to ignite. In real-life, this "start" position 2 is HELD while the starter does its thing, then once the engine ignites, you'd let go and it springs back to = 1 to keep the ignition on while the engine keeps running.
Now imagine instead, a start button and it can not NOT be pushed in and held in position=2 (like the key) for the time required for the starter to ignite the engine. Instead, once touched, that should cause the starter to runs for a set period of time in position 2 and when it senses a certain =>RPM, the starter stops and goes back to position 1, and leaves the engine running.
Similarly, I have a button that when "touched" fires the starter, but that starter event as expected goes from 0 to 2 and back to 1 in a blink. If I set it to be 2 then it fires forever.
I need to hold its phase 2 position in place for 15 seconds, then it can get back to 1
What I have:
A button that has an animated state. (0 off, 1, 2).
If 0 then 1, if 1 then 2 using phase==2 as the spring step from 2 back to 1
At position == 2, StarterKey = 2
No syntax issues.
The StarterKey variable is triggered to be =2 at position 2 -- BUT not long enough for the engine to ignite. I need StarterKey=2 to stay as a 2 for 15 seconds. Or, do I need to time the entire if phase==2 stage to be held for longer? Not sure.
What should I be looking at please? Here's a relevant snip..
function EngineStart()
if phase == 0 then
if ButtonState == 0 then
ButtonState = 1
StarterKey = 2 -- I tried adding *duration = 15* this event but that does not work
end
end
end
I also have the subsequent elseif phase == 2 part for when the button is in position == 2 so it springs back to 1 -- that all works fine.
How do I, or what do I need to use, to introduce time for my events and functions? I don't want to measure time, but set event time.
Thanks!
Solved this by watching a Lua tutorial video online (taught me how) + discovered that the sim has a timer function that I then used to set the number of seconds ("time") that the starter key-press stayed in its 2 position, which then fired it long enough for the igniters to do their work. (what to use)
QED :)) HA!
I'm trying to use an ESP8266 SoC to read a water flow sensor that is said to produce a square wave as output. I thought it would be a simple matter of using a GPIO port in interrupt mode, to count rising edge transitions -- and in fact that initially seemed to work. Then I upgraded the firmware from 0.96 to 1.5 and it has since ceased to work, I see no transitions when the wheel spins anymore.
However, if I run a wire to the pin [for the GPIO I'm using] and touch it to VCC momentarily, the interrupt routine is called as expected, so I know the sensor is wired to the right pin, and the interrupt routine is registered correctly. My code:
function intCb(level)
SpinCount = SpinCount + 1
local levelString = "up"
if level == gpio.HIGH then
levelString = "down"
end
gpio.trig(pin, levelString, intCb)
end
gpio.write(pin, 0)
gpio.trig(pin, "up", intCb)
gpio.mode(pin, gpio.INT, gpio.FLOAT)
So what am I missing? Do I need more support circuitry to read a square wave as input? If so then how did it work initially?
For anything that involves hardware it's really hard to give a definite answer here on SO. In most cases one bases it on hints (and hunches sometimes). A few ideas:
gpio.FLOAT should probably be gpio.PULLUP instead (unless you have an external pull-up resistor).
Your setup doesn't seem to be fundamentally different from e.g. using a push button or a switch to trigger some event. Hence, you probably want to use some kind of debounce or throttle function.
Since you seem to be interested in both rising and falling edges (as you switch between up and down) you might just as well listen for both, no?
So, assuming I drew the right conclusions something like the following generic skeleton may prove to be useful:
-- inspired by https://github.com/hackhitchin/esp8266-co-uk/blob/master/tutorials/introduction-to-gpio-api.md
-- and http://www.esp8266.com/viewtopic.php?f=24&t=4833&start=5#p29127
local pin = 4 --> GPIO2
function debounce (func)
local last = 0
local delay = 5000
return function (...)
local now = tmr.now()
local delta = now - last
-- if delta < 0 then delta = delta + 2147483647 end; proposed because of delta rolling over
if delta < delay then return end;
last = now
return func(...)
end
end
function onChange ()
print('The pin value has changed to '..gpio.read(pin))
end
gpio.mode(pin, gpio.INT, gpio.PULLUP) -- see https://github.com/hackhitchin/esp8266-co-uk/pull/1
gpio.trig(pin, 'both', debounce(onChange))
I solved this using a 555 timer chip as a schmitt trigger:
How can I define several types of objects a certain object can contact to in SpriteKit? For example: I want to be notified with a SKPhysicsContact if either my hero contacts with an enemy, or with an enemyBullet.
I found ball.physicsBody?.contactTestBitMask = BodyType.gap.rawValue | BodyType.wall.rawValue in this Stackoverflow post. However, if i try so, Compiler tells me: Consecutive Statements on a line must be separated by ";".
I tried: player.physicsBody?.contactTestBitMask = PhysicsCategory.enemy | PhysicsCategory.enemyBullet
Thanks! I am using Swift 2.1 on iOS 9.2
For example, given the Hopfield network pictured in the diagram attached..., where all nodes are originally at 0 (or "off"), is it possible for this network to relax to all 0s (that is, remain in this state)? All 0s are supposed to be a stable state for this diagram, but that doesn't make sense to me, because in this state, the input to each node would actually be dotProduct((0 0.. 0),(input1, input2 ... inputn)) = 0. But 0 >= 0, so that would make each node turn "on"/1, right? Perhaps I just don't understand how Hopfield networks relax to a stable state...
In case anyone else was interested, I found the answer...
Since a Hopfield network is a form of BAM network, it works in this way (rough pseudocode):
if(input dotted with weights > 0) node = "on"
else if(input dotted with weights < 0) node = "off"
else node remains the same
Thus, for this network, each node is receiving an input of 0, so each node will remain off (stay the same as its current state).
Is there any body who has used TREC_EVAL? I need a "Trec_EVAL for dummies".
I'm trying to evaluate a few search engines to compare parameters like Recall-Precision, ranking quality, etc for my thesis work. I can not find how to use TREC_EVAL to send queries to the search engine and get a result file which can be used with TREC_EVAL.
Basically, for trec_eval you need a (human generated) ground truth. That has to be in a special format:
query-number 0 document-id relevance
Given a collection like 101Categories (wikipedia entry) that would be something like
Q1046 0 PNGImages/dolphin/image_0041.png 0
Q1046 0 PNGImages/airplanes/image_0671.png 128
Q1046 0 PNGImages/crab/image_0048.png 0
The query-number identifies therefore a query (e.g. a picture from a certain category to find similiar ones). The results from your search engine has then to be transformed to look like
query-number Q0 document-id rank score Exp
or in reality
Q1046 0 PNGImages/airplanes/image_0671.png 1 1 srfiletop10
Q1046 0 PNGImages/airplanes/image_0489.png 2 0.974935 srfiletop10
Q1046 0 PNGImages/airplanes/image_0686.png 3 0.974023 srfiletop10
as described here. You might have to adjust the path names for the "document-id". Then you can calculate the standard metrics trec_eval groundtrouth.qrel results.
trec_eval --help should give you some ideas to choose the right parameters for using the measurements needed for your thesis.
trec_eval does not send any queries, you have to prepare them yourself. trec_eval does only the analysis given a ground trouth and your results.
Some basic information can be found here and here.