Cannot connect plant's state_output_port with WsgController's state_input_port - drake

I was trying to change MakeManipulationStation to adapt my own settings. I didn't the change the part that add Iiwa and Wsg. However, when configuring Wsg (connecting ports), I got an error.
RuntimeError: InputPort::Eval(): required InputPort[0] (u0) of System ::_::wsg1_controller::drake/systems/StateInterpolatorWithDiscreteDerivative#0000562a7a82aa10::drake/systems/Multiplexer#0000562a7aaa90c0 (Multiplexer<double>) is not connected
The function I configure Wsg is:
def ConfigureWsg(builder, plant, wsg, name='wsg', time_step=0.002):
# Add wsg controller
wsg_controller = builder.AddSystem(SchunkWsgPositionController(time_step=time_step))
wsg_controller.set_name(f"{name}_controller")
builder.Connect(wsg_controller.get_generalized_force_output_port(),
plant.get_actuation_input_port(wsg))
builder.Connect(plant.get_state_output_port(wsg),
wsg_controller.get_state_input_port())
builder.ExportInput(wsg_controller.get_desired_position_input_port(),
f"{name}_position")
builder.ExportInput(wsg_controller.get_force_limit_input_port(),
f"{name}_force_limit")
wsg_mbp_state_to_wsg_state = builder.AddSystem(
MakeMultibodyStateToWsgStateSystem())
builder.Connect(plant.get_state_output_port(wsg),
wsg_mbp_state_to_wsg_state.get_input_port())
builder.ExportOutput(wsg_mbp_state_to_wsg_state.get_output_port(),
f"{name}_state_measured")
builder.ExportOutput(wsg_controller.get_grip_force_output_port(),
f"{name}_force_measured")
which I think is the same as how MakeManipulationStation configuring Wsg.
I think this line:
builder.Connect(plant.get_state_output_port(wsg),
wsg_controller.get_state_input_port())
should connect the plant's state_output_port with wsg_controller's state_input_port. I don't understand why I still get this error?

Related

OSRM Configure blocking hours for a specific road

i'm working with OSRM(Open Source Routing Machine) and ran into some problems.
I want configure blocking hours for a specific road(like Grab)
Ex: The street called Cau Giay block taxis from 4.00pm to 7.00pm
code detail:
function restrict(way, result)
-- Check if the way is named contain Cau Giay
local name = way:get_value_by_key('name')
if name and string.find(name, 'Cau Giay') then
-- Add a restriction to the way
result.restriction = '* # (Mo-Fr 16:00-19:00)'
end
end
function way_function(way)
local result = {
-- Other routing rules and restrictions go here
}
restrict(way, result)
return result
end
but nothing changed.
please tell me where the above code is wrong and suggest some ways you have done it!
Thanks and best regards!
https://github.com/Project-OSRM/osrm-backend/issues/33 and
https://github.com/Project-OSRM/osrm-backend/issues/735

How to add a Route53 alias to an existing Route53 entry?

I have a DNS entry already in Route 53. In my CDK stack, I want to set up an alias (effectively a CNAME), so I have a new DNS entry pointing to the existing one. For example, I want to make new.example.com point to existing.example.com, where example.com is hosted in Route 53 and existing is already set up and working.
Through the AWS console I would just create a new A or CNAME record for new.example.com and set it as an alias of existing.example.com and it would be fine, so I am trying to replicate this in CDK.
In the CDK docs, it says I can do this:
declare const zone: route53.HostedZone;
declare const record: route53.ARecord;
new route53.ARecord(this, 'AliasRecord', {
zone,
target: route53.RecordTarget.fromAlias(new targets.Route53RecordTarget(record)),
});
However, the docs don't say how to populate the record variable.
If I look at the route53.ARecord docs, there doesn't appear to be a way to look up an existing record.
The closest I could find is using one of the other RecordSet.fromXXX() functions instead of fromAlias, however there doesn't appear to be one that can look up host names:
...
target: cdkRoute53.RecordTarget.fromValues('target.example.com'), // doesn't work
Unfortunately, RecordTarget.fromValues() only accepts an IP address. If you put a hostname in, it tells you:
Invalid Resource Record: 'FATAL problem: ARRDATAIllegalIPv4Address (Value is not a valid IPv4 address) encountered with 'target.example.com'
So it looks like I can only create the alias if I also created the target records in the same stack - there doesn't appear to be a way to load an existing record, so you can pass it in as the target for the new alias.
What am I missing?
I found a workaround in the meantime thanks to this answer. Since then they added the functionality that was missing, but it looks like they didn't provide lookups so that workaround still applies.
The solution is to provide a bind() function instead that provides the necessary information:
const route53entry = new cdkRoute53.ARecord(this, 'dns', {
recordName: 'new.example.com',
zone: hostedZone,
target: cdkRoute53.RecordTarget.fromAlias({
bind: () => ({
dnsName: 'existing.example.com',
hostedZoneId: hostedZone.hostedZoneId,
}),
}),
});

freeradius 3 mac auth user group (for configuration simplicity)

I have implemented Radius MAC authentication with Unifi AP and freeradius. I am using Radius primarily to set the vlan that the device should sent to allowing a consolidated SSID to handle multiple vlans. (This is a home network, not an enterprise so I am not concerned with the mac spoofing situation). Any MAC connecting will get a vlan (but non-radius users will go to a guest vlan by default)
The freeradius question is how I can go about assigning a group value to each MAC user definition and then post-auth use that group name to define the specific attributes such as Tunnel-Type, Tunnel-Medium-Type, and Tunnel-Private-Group-Id. I simply want to do this to avoid having to repeat all these tunnel values for each device.
Example (not sure if syntax is right)
authorize file
AABBCCDDEEFFGG Group := "iot", Cleartext-Password := "AABBCCDDEEFFGG"
site-enabled/default (I think it might go here)
if (group == "iot) { #update reply, set Tunnel-* values }
Any guidance someone could provide would be great. All the examples I have found seem to be using the mysql backend and I don't have a need for the additional complexity.
I was able to figure this out using control variables. Here is the solution.
Create a custom attribute in the dictionary file.
ATTRIBUTE VLAN-Group-Name 3000 string
Add users to the authorize file like so
AA-BB-CC-DD-EE-FF Cleartext-Password := "AA-BB-CC-DD-EE-FF", VLAN-Group-Name := "iot"
In your virtual server, in my case it was sites-enabled/default, look for the post-auth section and add code similar to this. You will replace the group-id XXX with your vlan # you want sent back to the AP to be assigned. I placed the code right above the -sql portion.
switch "&control:VLAN-Group-Name" {
case "iot" {
update reply {
Tunnel-Type = 13,
Tunnel-Medium-Type = 6,
Tunnel-Private-Group-Id = XXX
}
}
case "general" {
update reply {
Tunnel-Type = 13,
Tunnel-Medium-Type = 6,
Tunnel-Private-Group-Id = XXX
}
}
}
This allows you to keep the authorize file clean with just users and assign them a group and keep the group values simplified in the post-auth. If you ever needed to change the vlan # of any group just one update and restart.
Cheers!

Is it possible to call an URL passing website parameters?

I am writing code for a custom SAP program regarding some Vendor information. In my program flow, there is a possibility of me trying to use a Vendor VAT Number that belongs to an unknown Vendor. There is a Web site (EU Based - https://ec.europa.eu/taxation_customs/vies/) for such purposes that requires a country key and the specified VAT Number in order for it to provide an answer with the available Company information (only works for company VAT numbers of course). My problem is that I cannot seem to find any way to pass those parameters dynamically to the Web site without needing the user to interfere during this process. Manually, the process would be to select a country key, type in a VAT number and press 'Verify'.
Is there any way for me to call this specific Web site URL and "bypass" this process to only display the result page? For now, I'm using the following Function Module to just call the specified URL, in lack of any better choices.
call function 'CALL_INTERNET_ADRESS'
exporting
pi_adress = 'https://ec.europa.eu/taxation_customs/vies/'
exceptions
no_input_data = 1
others = 2.
You can use CL_HTTP_CLIENT class or HTTP_POST/HTPP_GET FM.
You need to install given web page SSL root certificate to your system with STRUST t-code.
Example usage of CL_HTTP_CLIENT below.
DATA: lv_url TYPE string VALUE 'http://mkysoft.com/ip.php'.
DATA: o_client TYPE REF TO if_http_client.
DATA: lv_http_rc TYPE i.
DATA: lv_reason TYPE string.
DATA: lt_fields TYPE tihttpnvp.
TRY.
cl_http_client=>create_by_url( EXPORTING
url = lv_url
IMPORTING
client = o_client
EXCEPTIONS
OTHERS = 0 ).
o_client->request->get_header_fields( CHANGING fields = lt_fields ).
o_client->request->set_header_field( name = '~request_uri' value = '/ip.php' ).
o_client->request->set_header_field( name = '~host' value = 'mkysoft.com' ).
o_client->request->set_method( if_http_request=>co_request_method_get ).
o_client->send( ).
o_client->receive( ).
o_client->response->get_status( IMPORTING
code = lv_http_rc
reason = lv_reason ).
* Error check
IF lv_http_rc = 200.
DATA(lv_xml) = o_client->response->get_cdata( ).
* Handle error
ELSE.
WRITE: / 'Fehler: ', lv_http_rc.
ENDIF.
o_client->close( ).
CATCH cx_root INTO DATA(e_txt).
WRITE: / e_txt->get_text( ).
ENDTRY.
EU Commission has a SOAP service for vat numbers.
See the info page
https://ec.europa.eu/taxation_customs/vies/technicalInformation.html
and that it even supports http
http://ec.europa.eu/taxation_customs/vies/checkVatTestService.wsdl
You have a non screen scrape method, proper interface you should look at.
On the other point of Avoiding SSL.
Make a basic guide for customers to add the European commission cert to their SAP system. If someone is complaining about that, then they are a serious user of the internet. Every sap on premise user, that needs to call the internet adds certs.
Http is dead....

Several questions about this Varnish VCL

I'm setting up varnish-devicedetect VCL in Varnish 4.0.2:
https://github.com/varnish/varnish-devicedetect/blob/master/INSTALL.rst
I'm following the directions for method #1: "Send HTTP header to backend"
I've read through this readme and have Googled for quite some time now and still quite a few concepts are escaping me.
Here's my code (excerpts):
default.vcl
include "devicedetect.vcl";
sub vcl_recv {
call devicedetect;
# ... snip ...
}
sub vcl_backend_response {
# device detect
if (bereq.http.X-UA-Device) {
if (!beresp.http.Vary) { # no Vary at all
set beresp.http.Vary = "X-UA-Device";
} elseif (beresp.http.Vary !~ "X-UA-Device") { # add to existing Vary
set beresp.http.Vary = beresp.http.Vary + ", X-UA-Device";
}
}
# ... snip ...
}
sub vcl_deliver {
# device detect
if ((req.http.X-UA-Device) && (resp.http.Vary)) {
set resp.http.Vary = regsub(resp.http.Vary, "X-UA-Device", "User-Agent");
}
# ... snip ...
}
Here's my questions.
When I inspect the response in Chrome Dev Tools, why is the Vary header set to User-Agent. Isn't the whole approach of method #1 NOT to use user agent, and instead use X-UA-Device?
Based on other guides I read... it seems this will hit the origin for EACH type of mobile (if you look in device detect, its split up into... mobile-iphone, mobile-android, mobile-smartphone, etc). Is this true in my code above? I definitely DONT want to hit the origin server more than twice for any given URL (desktop, and mobile ... I don't want all the mobile-* cached separately).
Can someone describe what the 3 code blocks above actually do? In somewhat laymen's terms. About the only one I truly understand is the first code block. call devicedetect just looks at the User-Agent and then sets X-UA-Device header with the appropriate grouping on the request to the backend. I'm a bit confused what the other 2 code blocks do though.
Can I delete the bit with X-UA-Device-force if I don't intend to allow the user to 'use desktop site'?
The guide mentions that I should be setting something in the backend in my app code. Right now this is all I have (rails). I'm not changing headers or changing anything about the response. I'm only changing the way the HTML looks (for the mobile version of the site). Should I be changing a header or something? This is what I have so far:
Rails:
def detect_device
if request.headers['X-UA-Device'] =~ /^mobile/
#device = 'mobile'
prepend_view_path Rails.root + 'app' + 'views_mobile'
else
#device = 'desktop'
end
end
As to point 1, your X-UA-Device is a custom header for internal consumption, ie by default not exposed to the external world. To ensure the external caches/proxies understand you are considering the device/user-agent in the response, you have to update the Vary with a header which reflect this. this is where the user-agent comes in, as thats where you have derived the X-UA-Device from.
note the comment within the link you indicate
to keep any caches in the wild from serving wrong content to client #2 behind them, we need to transform the Vary on the way out.

Resources