example_tx.cpp => example_tx.cpp.em

example_tx.cpp => example_tx.cpp.em

Initial EmPy template creation, from existing C++ code.

/** \file example_tx.cpp
 *  \brief Example of using ibisami to build a Tx model.
 *
 * Original author: David Banas <br>
 * Original date:   May 8, 2015
 *
 * Copyright (c) 2015 David Banas; all rights reserved World wide.
 */

#define TAP_SCALE 0.047

#include <string>
#include <vector>
#include "include/ami_tx.h"

/// An example device specific Tx model implementation.
class MyTx : public AmiTx {
    typedef AmiTx inherited;

 public:
    MyTx() {}
    ~MyTx() {}
    void init(double *impulse_matrix, const long number_of_rows,
            const long aggressors, const double sample_interval,
            const double bit_time, const std::string& AMI_parameters_in) override {

        // Let our base class do its thing.
        inherited::init(impulse_matrix, number_of_rows, aggressors,
            sample_interval, bit_time, AMI_parameters_in);

        // Grab our parameters and configure things accordingly.
        std::vector<std::string> node_names; node_names.clear();
        int taps[4], tap_units;
        node_names.push_back("tx_tap_units");
        tap_units = get_param_int(node_names, 27);
        node_names.pop_back();
        node_names.push_back("tx_tap_np1");  // pre-tap
        taps[0] = get_param_int(node_names, 0);
        node_names.pop_back();
        node_names.push_back("tx_tap_nm1");  // post-tap1
        taps[2] = get_param_int(node_names, 0);
        node_names.pop_back();
        node_names.push_back("tx_tap_nm2");  // post-tap2
        taps[3] = get_param_int(node_names, 0);
        taps[1] = tap_units - 2 * (taps[0] + taps[2] + taps[3]);

        // Fill in params_.
        std::ostringstream params;
        params << "(example_tx";
        params << " (tap_units " << tap_units << ")";
        params << " (taps[0] " << taps[0] << ")";
        params << " (taps[1] " << taps[1] << ")";
        params << " (taps[2] " << taps[2] << ")";
        params << " (taps[3] " << taps[3] << ")";
        tap_weights_.clear();
        int samples_per_bit = int(bit_time / sample_interval);
        int tap_signs[] = {-1, 1, -1, -1};
        have_preemph_ = true;
        for (auto i = 0; i < 4; i++) {
            tap_weights_.push_back(taps[i] * TAP_SCALE * tap_signs[i]);
            params << " (tap_weights_[" << i << "] " << tap_weights_.back() << ")";
            for (auto j = 1; j < samples_per_bit; j++)
                tap_weights_.push_back(0.0);
        }
        param_str_ = params.str() + "\n";
        msg_ = "Hello, World!";
    }
} my_tx;

AMIModel *ami_model = &my_tx;  ///< The pointer required by the API implementation.

error: pathspec 'example/example_tx.cpp.em' did not match any file(s) known to git


add whitespace to debian control template

Source: @(Package)
Section: misc
Priority: extra
Maintainer: @(Maintainer)
Build-Depends: debhelper (>= 7.0.50~), @(', '.join(BuildDepends))
Homepage: @(Homepage)
Standards-Version: 3.9.2

Package: @(Package)
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}, @(', '.join(Depends))
Description: @(Description)

Source: @(Package)
Section: misc
Priority: extra
Maintainer: @(Maintainer)
Build-Depends: debhelper (>= 7.0.50~), @(','.join(BuildDepends))
Homepage: @(Homepage)
Standards-Version: 3.9.2

Package: @(Package)
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}, @(','.join(Depends))
Description: @(Description)


(misc markup fixes)

(misc markup fixes)

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/GNOME/passepartout.git/'


Add prototype dhcpd.em and test log data.

error: pathspec 'examples/dhcpd.em' did not match any file(s) known to git


change repo url

change repo url

<project>
	<actions/>
	<description>Generated at @ESCAPE(now_str) from template '@ESCAPE(template_name)'</description>
@(SNIPPET(
    'log-rotator',
    days_to_keep=100,
    num_to_keep=100,
))@
	<keepDependencies>false</keepDependencies>
	<properties>
@[if job_priority is not None]@
@(SNIPPET(
    'property_job-priority',
    priority=job_priority,
))@
@[end if]@
	</properties>
@(SNIPPET(
    'scm',
    repo_spec=source_repo_spec,
    path='catkin_workspace/src/%s' % source_repo_spec.name
))@
	<assignedNode>buildslave</assignedNode>
	<canRoam>false</canRoam>
	<disabled>false</disabled>
	<blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
	<blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
	<triggers>
@(SNIPPET(
    'trigger_poll',
    spec='H * * * *',
))@
	</triggers>
	<concurrentBuild>true</concurrentBuild>
	<builders>
@(SNIPPET(
    'builder_shell',
    script='\n'.join([
        'echo "# BEGIN SECTION: Clone custom rosdistro"',
        'rm -fr rosdistro',
        'git clone https://github.com/dirk-thomas/ros-infrastructure_rosdistro.git rosdistro',
        'echo "# END SECTION"',
        '',
        'echo "# BEGIN SECTION: Clone ros_buildfarm"',
        'rm -fr ros_buildfarm',
        'git clone https://github.com/ros-infrastructure/ros_buildfarm.git ros_buildfarm',
        'echo "# END SECTION"',
    ]),
))@
@(SNIPPET(
    'builder_shell',
    script='\n'.join([
        '# generate key files',
        'echo "# BEGIN SECTION: Generate key files"',
    ] + script_generating_key_files + [
        'echo "# END SECTION"',
    ]),
))@
@(SNIPPET(
    'builder_shell',
    script='\n'.join([
        '# generate Dockerfile, build and run it',
        '# generating the Dockerfiles for the actual build tasks',
        'echo "# BEGIN SECTION: Generate Dockerfile 1"',
        'mkdir -p $WORKSPACE/docker_generating_devel_dockers',
        'export PYTHONPATH=$WORKSPACE/ros_buildfarm:$PYTHONPATH',
        '$WORKSPACE/ros_buildfarm/scripts/devel/run_devel_job.py' +
        ' --rosdistro-index-url %s' % rosdistro_index_url +
        ' --rosdistro-name %s' % rosdistro_name +
        ' --source-build-name %s' % source_build_name +
        ' --repo-name %s' % source_repo_spec.name +
        ' --os-name %s' % os_name +
        ' --os-code-name %s' % os_code_name +
        ' --arch %s' % arch +
        ' ' + ' '.join(apt_mirror_args) +
        ' --workspace-root $WORKSPACE/catkin_workspace' +
        ' --dockerfile-dir $WORKSPACE/docker_generating_devel_dockers',
        'echo "# END SECTION"',
        '',
        'echo "# BEGIN SECTION: Build Dockerfile - generating docker tasks"',
        'cd $WORKSPACE/docker_generating_devel_dockers',
        'docker build -t devel .',
        'echo "# END SECTION"',
        '',
        'echo "# BEGIN SECTION: Run Dockerfile - generating docker tasks"',
        'mkdir -p $WORKSPACE/docker_build_and_install',
        'mkdir -p $WORKSPACE/docker_build_and_test',
        'docker run' +
        ' -v $WORKSPACE/ros_buildfarm:/tmp/ros_buildfarm' +
        ' -v $WORKSPACE/catkin_workspace:/tmp/catkin_workspace' +
        ' -v $WORKSPACE/docker_build_and_install:/tmp/docker_build_and_install' +
        ' -v $WORKSPACE/docker_build_and_test:/tmp/docker_build_and_test' +
        ' devel',
        'echo "# END SECTION"',
    ]),
))@
@(SNIPPET(
    'builder_shell',
    script='\n'.join([
        'echo "# BEGIN SECTION: Build Dockerfile - build and install"',
        '# build and run build_and_install Dockerfile',
        'cd $WORKSPACE/docker_build_and_install',
        'docker build -t build_and_install .',
        'echo "# END SECTION"',
        '',
        'echo "# BEGIN SECTION: Run Dockerfile - build and install"',
        'docker run' +
        ' -v $WORKSPACE/ros_buildfarm:/tmp/ros_buildfarm' +
        ' -v $WORKSPACE/catkin_workspace:/tmp/catkin_workspace' +
        ' build_and_install',
        'echo "# END SECTION"',
    ]),
))@
@(SNIPPET(
    'builder_shell',
    script='\n'.join([
        'echo "# BEGIN SECTION: Build Dockerfile - build and test"',
        '# build and run build_and_test Dockerfile',
        'cd $WORKSPACE/docker_build_and_test',
        'docker build -t build_and_test .',
        'echo "# END SECTION"',
        '',
        'echo "# BEGIN SECTION: Run Dockerfile - build and test"',
        'docker run' +
        ' -v $WORKSPACE/ros_buildfarm:/tmp/ros_buildfarm' +
        ' -v $WORKSPACE/catkin_workspace:/tmp/catkin_workspace' +
        ' build_and_test',
        'echo "# END SECTION"',
    ]),
))@
	</builders>
	<publishers>
@(SNIPPET(
    'publisher_junit',
    test_results='catkin_workspace/build_isolated/**/*.xml',
))@
@(SNIPPET(
    'publisher_mailer',
    recipients=recipients,
    send_to_individuals=True,
))@
	</publishers>
	<buildWrappers>
@[if timeout_minutes is not None]@
@(SNIPPET(
    'build-wrapper_build-timeout',
    timeout_minutes=timeout_minutes,
))@
@[end if]@
	</buildWrappers>
</project>

<project>
	<actions/>
	<description>Generated at @ESCAPE(now_str) from template '@ESCAPE(template_name)'</description>
@(SNIPPET(
    'log-rotator',
    days_to_keep=100,
    num_to_keep=100,
))@
	<keepDependencies>false</keepDependencies>
	<properties>
@[if job_priority is not None]@
@(SNIPPET(
    'property_job-priority',
    priority=job_priority,
))@
@[end if]@
	</properties>
@(SNIPPET(
    'scm',
    repo_spec=source_repo_spec,
    path='catkin_workspace/src/%s' % source_repo_spec.name
))@
	<assignedNode>buildslave</assignedNode>
	<canRoam>false</canRoam>
	<disabled>false</disabled>
	<blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
	<blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
	<triggers>
@(SNIPPET(
    'trigger_poll',
    spec='H * * * *',
))@
	</triggers>
	<concurrentBuild>true</concurrentBuild>
	<builders>
@(SNIPPET(
    'builder_shell',
    script='\n'.join([
        'echo "# BEGIN SECTION: Clone custom rosdistro"',
        'rm -fr rosdistro',
        'git clone https://github.com/dirk-thomas/ros-infrastructure_rosdistro.git rosdistro',
        'echo "# END SECTION"',
        '',
        'echo "# BEGIN SECTION: Clone ros_buildfarm"',
        'rm -fr ros_buildfarm',
        'git clone https://github.com/dirk-thomas/ros_buildfarm.git ros_buildfarm',
        'echo "# END SECTION"',
    ]),
))@
@(SNIPPET(
    'builder_shell',
    script='\n'.join([
        '# generate key files',
        'echo "# BEGIN SECTION: Generate key files"',
    ] + script_generating_key_files + [
        'echo "# END SECTION"',
    ]),
))@
@(SNIPPET(
    'builder_shell',
    script='\n'.join([
        '# generate Dockerfile, build and run it',
        '# generating the Dockerfiles for the actual build tasks',
        'echo "# BEGIN SECTION: Generate Dockerfile 1"',
        'mkdir -p $WORKSPACE/docker_generating_devel_dockers',
        'export PYTHONPATH=$WORKSPACE/ros_buildfarm:$PYTHONPATH',
        '$WORKSPACE/ros_buildfarm/scripts/devel/run_devel_job.py' +
        ' --rosdistro-index-url %s' % rosdistro_index_url +
        ' --rosdistro-name %s' % rosdistro_name +
        ' --source-build-name %s' % source_build_name +
        ' --repo-name %s' % source_repo_spec.name +
        ' --os-name %s' % os_name +
        ' --os-code-name %s' % os_code_name +
        ' --arch %s' % arch +
        ' ' + ' '.join(apt_mirror_args) +
        ' --workspace-root $WORKSPACE/catkin_workspace' +
        ' --dockerfile-dir $WORKSPACE/docker_generating_devel_dockers',
        'echo "# END SECTION"',
        '',
        'echo "# BEGIN SECTION: Build Dockerfile - generating docker tasks"',
        'cd $WORKSPACE/docker_generating_devel_dockers',
        'docker build -t devel .',
        'echo "# END SECTION"',
        '',
        'echo "# BEGIN SECTION: Run Dockerfile - generating docker tasks"',
        'mkdir -p $WORKSPACE/docker_build_and_install',
        'mkdir -p $WORKSPACE/docker_build_and_test',
        'docker run' +
        ' -v $WORKSPACE/ros_buildfarm:/tmp/ros_buildfarm' +
        ' -v $WORKSPACE/catkin_workspace:/tmp/catkin_workspace' +
        ' -v $WORKSPACE/docker_build_and_install:/tmp/docker_build_and_install' +
        ' -v $WORKSPACE/docker_build_and_test:/tmp/docker_build_and_test' +
        ' devel',
        'echo "# END SECTION"',
    ]),
))@
@(SNIPPET(
    'builder_shell',
    script='\n'.join([
        'echo "# BEGIN SECTION: Build Dockerfile - build and install"',
        '# build and run build_and_install Dockerfile',
        'cd $WORKSPACE/docker_build_and_install',
        'docker build -t build_and_install .',
        'echo "# END SECTION"',
        '',
        'echo "# BEGIN SECTION: Run Dockerfile - build and install"',
        'docker run' +
        ' -v $WORKSPACE/ros_buildfarm:/tmp/ros_buildfarm' +
        ' -v $WORKSPACE/catkin_workspace:/tmp/catkin_workspace' +
        ' build_and_install',
        'echo "# END SECTION"',
    ]),
))@
@(SNIPPET(
    'builder_shell',
    script='\n'.join([
        'echo "# BEGIN SECTION: Build Dockerfile - build and test"',
        '# build and run build_and_test Dockerfile',
        'cd $WORKSPACE/docker_build_and_test',
        'docker build -t build_and_test .',
        'echo "# END SECTION"',
        '',
        'echo "# BEGIN SECTION: Run Dockerfile - build and test"',
        'docker run' +
        ' -v $WORKSPACE/ros_buildfarm:/tmp/ros_buildfarm' +
        ' -v $WORKSPACE/catkin_workspace:/tmp/catkin_workspace' +
        ' build_and_test',
        'echo "# END SECTION"',
    ]),
))@
	</builders>
	<publishers>
@(SNIPPET(
    'publisher_junit',
    test_results='catkin_workspace/build_isolated/**/*.xml',
))@
@(SNIPPET(
    'publisher_mailer',
    recipients=recipients,
    send_to_individuals=True,
))@
	</publishers>
	<buildWrappers>
@[if timeout_minutes is not None]@
@(SNIPPET(
    'build-wrapper_build-timeout',
    timeout_minutes=timeout_minutes,
))@
@[end if]@
	</buildWrappers>
</project>


Adds a default object script that creates entities whenever receive a touch message.

system.require('std/default.em');

/**
 Whenever someone sends a touch message to me, I create a new entity next to me.
 */
var DEFAULT_ENTITY_DIST_FROM_ME = <5,0,0>;
var DEFAULT_ENTITY_MESH        = "meerkat:///test/multimtl.dae/original/0/multimtl.dae";
var DEFAULT_ENTITY_SOLID_ANGLE = 100;
var DEFAULT_ENTITY_SCALE       = 1;

function birthEntity()
{
    function newEntityScript()
    {
        system.require('std/default.em');
    }
    system.createEntityScript(system.self.getPosition() + DEFAULT_ENTITY_DIST_FROM_ME,
                              newEntityScript,
                              null,
                              DEFAULT_ENTITY_SOLID_ANGLE,
                              DEFAULT_ENTITY_MESH,
                              DEFAULT_ENTITY_SCALE
                             );
}

birthEntity << { 'action': 'touch':};

error: pathspec 'liboh/plugins/js/scripts/test/testBirthingTower.em' did not match any file(s) known to git


Forgot to add in the new birds file.

Forgot to add in the new birds file.

//register handlers for a getLocation command
function getLocationCallback(object,sender)
{
    system.print("\n\n\nInside of getLocationCallback\n\n");
    var locMessage = new Object();
    locMessage.command = "locationResponse";
    locMessage.positionX = 32;
    //    locMessage.position = system.presences[0].getPosition();
    // locMessage.velocity = system.presences[0].getVelocity();
    // locMessage.orientation = system.presences[0].getOrientation();
    // locMessage.senderer = system.Self;

//    object.senderer.sendMessage(locMessage);
    sender.sendMessage(locMessage);
}

var getLocationPattern = new system.Pattern("command","getLocation");
var getLocationHandler = system.registerHandler(getLocationPattern,null,getLocationCallback,null);

function requestAllLocations()
{
    var locRequest = new Object();
    locRequest.command = "getLocation";
    locRequest.senderer = system.Self;
    system.__broadcast(locRequest);
}

//register handlers for a locationResponse message
function locationResponseCallback(object,sender)
{
    system.print("\n\n\nGot inside of the location response callback\n\n");
    system.print(object.positionX);
    system.print("\n\n\n");
    //printVec3(object.position);
}

var locationResponsePattern = new system.Pattern("command","locationResponse");
var locationResponseHandler = system.registerHandler(locationResponsePattern,null,locationResponseCallback,null);

function printVec3(vec,stringToPrint)
{
    system.print(stringToPrint);
    system.print("x: ");
    system.print(vec.x);
    system.print("y: ");
    system.print(vec.y);
    system.print("z: ");
    system.print(vec.z);
    system.print("\n\n");
}

function addQuat(a,b)
{
    var returner = system.Quaternion(a.x+b.x,a.y+b.y,a.z+b.z, a.w+b.w);
    return returner;
}

function printQuat(quat,stringToPrint)
{
    system.print(stringToPrint);
    system.print("x: ");
    system.print(quat.x);
    system.print("y: ");
    system.print(quat.y);
    system.print("z: ");
    system.print(quat.z);
    system.print("w: ");
    system.print(quat.w);
    system.print("\n\n");
}

error: pathspec 'build/cmake/importFiles/birds.em' did not match any file(s) known to git


duplicate template before modifying it to track history

Signed-off-by: Dirk Thomas <19795c8185177e940eedd30ceb2b716a54a3d5dc@users.noreply.github.com>

// generated from ros1_bridge/resource/pkg_factories.cpp.em

@###############################################
@#
@# Factory template specializations based on
@# message types of a single ROS 2 package
@#
@# EmPy template for generating <pkgname>_factories.cpp
@#
@###############################################
@# Start of Template
@#
@# Context:
@#  - ros2_package_name (str)
@#    The ROS 2 package name of this file
@#  - mappings (list of ros1_bridge.Mapping)
@#    Mapping between messages as well as their fields
@###############################################
@
@{
from ros1_bridge import camel_case_to_lower_case_underscore
}@
#include "rclcpp/rclcpp.hpp"
#include "@(ros2_package_name)_factories.hpp"

// include builtin interfaces
#include <ros1_bridge/convert_builtin_interfaces.hpp>

// include ROS 1 services
@[for service in services]@
#include <@(service["ros1_package"])/@(service["ros1_name"]).h>
@[end for]@

// include ROS 2 services
@[for service in services]@
#include <@(service["ros2_package"])/srv/@(camel_case_to_lower_case_underscore(service["ros2_name"])).hpp>
@[end for]@

namespace ros1_bridge
{

std::shared_ptr<FactoryInterface>
get_factory_@(ros2_package_name)(const std::string & ros1_type_name, const std::string & ros2_type_name)
{
@[if not mappings]@
  (void)ros1_type_name;
  (void)ros2_type_name;
@[end if]@
  // mapping from string to specialized template
@[for m in mappings]@
  if (
    (ros1_type_name == "@(m.ros1_msg.package_name)/@(m.ros1_msg.message_name)" ||
     ros1_type_name == "") &&
    ros2_type_name == "@(m.ros2_msg.package_name)/@(m.ros2_msg.message_name)")
  {
    return std::make_shared<
      Factory<
        @(m.ros1_msg.package_name)::@(m.ros1_msg.message_name),
        @(m.ros2_msg.package_name)::msg::@(m.ros2_msg.message_name)
      >
    >("@(m.ros1_msg.package_name)/@(m.ros1_msg.message_name)", ros2_type_name);
  }
@[end for]@
  return std::shared_ptr<FactoryInterface>();
}

// conversion functions for available interfaces
@[for m in mappings]@

template<>
void
Factory<
  @(m.ros1_msg.package_name)::@(m.ros1_msg.message_name),
  @(m.ros2_msg.package_name)::msg::@(m.ros2_msg.message_name)
>::convert_1_to_2(
  const @(m.ros1_msg.package_name)::@(m.ros1_msg.message_name) & ros1_msg,
  @(m.ros2_msg.package_name)::msg::@(m.ros2_msg.message_name) & ros2_msg)
{
@[  if not m.fields_1_to_2]@
  (void)ros1_msg;
  (void)ros2_msg;
@[  end if]@
@[  for ros1_field, ros2_field in m.fields_1_to_2.items()]@
@[    if not ros2_field.type.is_array]@
  // convert non-array field
@[      if not ros2_field.type.pkg_name]@
  // convert primitive field
  ros2_msg.@(ros2_field.name) = ros1_msg.@(ros1_field.name);
@[      elif ros2_field.type.pkg_name == 'builtin_interfaces']@
  // convert builtin field
  ros1_bridge::convert_1_to_2(ros1_msg.@(ros1_field.name), ros2_msg.@(ros2_field.name));
@[      else]@
  // convert sub message field
  Factory<
    @(ros1_field.pkg_name)::@(ros1_field.msg_name),
    @(ros2_field.type.pkg_name)::msg::@(ros2_field.type.type)
  >::convert_1_to_2(
    ros1_msg.@(ros1_field.name), ros2_msg.@(ros2_field.name));
@[      end if]@
@[    else]@
  // convert array field
@[      if not ros2_field.type.array_size or ros2_field.type.is_upper_bound]@
  // ensure array size
@[        if ros2_field.type.is_upper_bound]@
  // check boundary
  assert(ros1_msg.@(ros1_field.name).size() <= @(ros2_field.type.array_size));
@[        end if]@
  // dynamic arrays must be resized
  ros2_msg.@(ros2_field.name).resize(ros1_msg.@(ros1_field.name).size());
@[      end if]@
@[      if not ros2_field.type.pkg_name]@
  // convert primitive array elements
  std::copy(
    ros1_msg.@(ros1_field.name).begin(),
    ros1_msg.@(ros1_field.name).end(),
    ros2_msg.@(ros2_field.name).begin());
@[      else]@
  // copy element wise since the type is different
  {
    auto ros1_it = ros1_msg.@(ros1_field.name).begin();
    auto ros2_it = ros2_msg.@(ros2_field.name).begin();
    for (
      ;
      ros1_it != ros1_msg.@(ros1_field.name).end() &&
      ros2_it != ros2_msg.@(ros2_field.name).end();
      ++ros1_it, ++ros2_it
    )
    {
      // convert sub message element
@[        if ros2_field.type.pkg_name == 'builtin_interfaces']@
      ros1_bridge::convert_1_to_2(*ros1_it, *ros2_it);
@[        else]@
      Factory<
        @(ros1_field.pkg_name)::@(ros1_field.msg_name),
        @(ros2_field.type.pkg_name)::msg::@(ros2_field.type.type)
      >::convert_1_to_2(
        *ros1_it, *ros2_it);
@[        end if]@
    }
  }
@[      end if]@
@[    end if]@
@[  end for]@
}

template<>
void
Factory<
  @(m.ros1_msg.package_name)::@(m.ros1_msg.message_name),
  @(m.ros2_msg.package_name)::msg::@(m.ros2_msg.message_name)
>::convert_2_to_1(
  const @(m.ros2_msg.package_name)::msg::@(m.ros2_msg.message_name) & ros2_msg,
  @(m.ros1_msg.package_name)::@(m.ros1_msg.message_name) & ros1_msg)
{
@[  if not m.fields_2_to_1]@
  (void)ros2_msg;
  (void)ros1_msg;
@[  end if]@
@[  for ros2_field, ros1_field in m.fields_2_to_1.items()]@
@[    if not ros2_field.type.is_array]@
  // convert non-array field
@[      if not ros2_field.type.pkg_name]@
  // convert primitive field
  ros1_msg.@(ros1_field.name) = ros2_msg.@(ros2_field.name);
@[      elif ros2_field.type.pkg_name == 'builtin_interfaces']@
  // convert builtin field
  ros1_bridge::convert_2_to_1(ros2_msg.@(ros2_field.name), ros1_msg.@(ros1_field.name));
@[      else]@
  // convert sub message field
  Factory<
    @(ros1_field.pkg_name)::@(ros1_field.msg_name),
    @(ros2_field.type.pkg_name)::msg::@(ros2_field.type.type)
  >::convert_2_to_1(
    ros2_msg.@(ros2_field.name), ros1_msg.@(ros1_field.name));
@[      end if]@
@[    else]@
  // convert array field
@[      if not ros2_field.type.array_size or ros2_field.type.is_upper_bound]@
  // ensure array size
  // dynamic arrays must be resized
  ros1_msg.@(ros1_field.name).resize(ros2_msg.@(ros2_field.name).size());
@[      end if]@
@[      if not ros2_field.type.pkg_name]@
  // convert primitive array elements
  std::copy(
    ros2_msg.@(ros2_field.name).begin(),
    ros2_msg.@(ros2_field.name).end(),
    ros1_msg.@(ros1_field.name).begin());
@[      else]@
  // copy element wise since the type is different
  {
    auto ros2_it = ros2_msg.@(ros2_field.name).begin();
    auto ros1_it = ros1_msg.@(ros1_field.name).begin();
    for (
      ;
      ros2_it != ros2_msg.@(ros2_field.name).end() &&
      ros1_it != ros1_msg.@(ros1_field.name).end();
      ++ros2_it, ++ros1_it
    )
    {
      // convert sub message element
@[        if ros2_field.type.pkg_name == 'builtin_interfaces']@
      ros1_bridge::convert_2_to_1(*ros2_it, *ros1_it);
@[        else]@
      Factory<
        @(ros1_field.pkg_name)::@(ros1_field.msg_name),
        @(ros2_field.type.pkg_name)::msg::@(ros2_field.type.type)
      >::convert_2_to_1(
        *ros2_it, *ros1_it);
@[        end if]@
    }
  }
@[      end if]@
@[    end if]@
@[  end for]@
}

@[end for]@

@[for service in services]@
@[  for frm, to in [("1", "2"), ("2", "1")]]@
@[    for type in ["Request", "Response"]]@
template <>
void ServiceFactory<
  @(service["ros1_package"])::@(service["ros1_name"]),
  @(service["ros2_package"])::srv::@(service["ros2_name"])
>::translate_@(frm)_to_@(to)(
@[      if frm == "1"]@
  const @(service["ros1_package"])::@(service["ros1_name"])::@(type)& req1,
  @(service["ros2_package"])::srv::@(service["ros2_name"])::@(type)& req2
@[      else]@
  const @(service["ros2_package"])::srv::@(service["ros2_name"])::@(type)& req2,
  @(service["ros1_package"])::@(service["ros1_name"])::@(type)& req1
@[      end if]@
) {
@[      for field in service["fields"][type.lower()]]@
@[        if field["array"]]@
  req@(to).@(field["ros" + to]["name"]).resize(req@(frm).@(field["ros" + frm]["name"]).size());
  auto @(field["ros1"]["name"])1_it = req1.@(field["ros1"]["name"]).begin();
  auto @(field["ros2"]["name"])2_it = req2.@(field["ros2"]["name"]).begin();
  while (
    @(field["ros1"]["name"])1_it != req1.@(field["ros1"]["name"]).end() &&
    @(field["ros2"]["name"])2_it != req2.@(field["ros2"]["name"]).end()
  ) {
    auto & @(field["ros1"]["name"])1 = *(@(field["ros1"]["name"])1_it++);
    auto & @(field["ros2"]["name"])2 = *(@(field["ros2"]["name"])2_it++);
@[      else]@
  auto & @(field["ros1"]["name"])1 = req1.@(field["ros1"]["name"]);
  auto & @(field["ros2"]["name"])2 = req2.@(field["ros2"]["name"]);
@[        end if]@
@[        if field["basic"]]@
  @(field["ros2"]["name"])@(to) = @(field["ros1"]["name"])@(frm);
@[        else]@
  Factory<@(field["ros1"]["cpptype"]),@(field["ros2"]["cpptype"])>::convert_@(frm)_to_@(to)(@
@(field["ros2"]["name"])@(frm), @(field["ros1"]["name"])@(to));
@[        end if]@
@[        if field["array"]]@
  }
@[        end if]@
@[      end for]@
}

@[    end for]@
@[  end for]@
@[end for]@

std::unique_ptr<ServiceFactoryInterface>
get_service_factory_@(ros2_package_name)(const std::string & ros_id, const std::string & package_name, const std::string & service_name)
{
@[if not services]@
  (void)ros_id;
  (void)package_name;
  (void)service_name;
@[end if]@
@[for service in services]@
  if (
    (
      ros_id == "ros1" &&
      package_name == "@(service["ros1_package"])" &&
      service_name == "@(service["ros1_name"])"
    ) || (
      ros_id == "ros2" &&
      package_name == "@(service["ros2_package"])" &&
      service_name == "@(service["ros2_name"])"
    )
  ) {
    return std::unique_ptr<ServiceFactoryInterface>(new ServiceFactory<
      @(service["ros1_package"])::@(service["ros1_name"]),
      @(service["ros2_package"])::srv::@(service["ros2_name"])
    >);
  }
@[end for]@
  return nullptr;
}
}  // namespace ros1_bridge

error: pathspec 'resource/interface_factories.cpp.em' did not match any file(s) known to git


A longer sample document (actual emissionen article from 1997).


sdxo#2781: Adding mising file.

sdxo#2781: Adding mising file.

${
import math

def my_floor(num):
    return int(math.floor(num))

def my_ceil(num):
    return int(math.ceil(num))

# Should we set the line width in the engine to 2.25, and draw non pixel aligned lines?
# Are these already the correct sizes for the XO?

# These sizes need to be sanity checked ...
if scaling == "100":
    xo = True
    icon_base = 11
else: # About 72% of the XO size, adjusted so that eg. toolbuttons work
    xo = False
    icon_base = 8               # 7.92

}
${
icon_small = icon_base * 3
icon_large = icon_base * 5

small_icons = [ "gtk-menu", "gtk-dnd", "gtk-small-toolbar", "gtk-button" ]
large_icons = [ "gtk-large-toolbar" ]

icon_sizes = []
for icon in small_icons:
    icon_sizes += [icon + "=" + str(icon_small) + ',' + str(icon_small)]
for icon in large_icons:
    icon_sizes += [icon + "=" + str(icon_large) + ',' + str(icon_large)]

icon_sizes = ":".join(icon_sizes)

}
gtk-icon-sizes="$icon_sizes"

style "default"
{
  engine "hcengine" {
    edge_thickness = 2
  }

  xthickness = 2
  ythickness = 2

# For Java Desktop System
  PanelMenu::stripe-gradient-top = "#000033"
  PanelMenu::stripe-gradient-bottom = "#000033"

  GtkWidget::interior-focus = 1
  GtkWidget::wide-separators = 0
  GtkWidget::separator-height = 2
  GtkWidget::separator-width = 2
  GtkRange::activate-slider = 1
  GtkArrow::arrow-size = 1.0
  GtkToolbar::shadow-type = GTK_SHADOW_NONE
  GtkToolbar::space-size = 30
  GtkProgressBar::min-horizontal-bar-height = 15
  GtkProgressBar::min-vertical-bar-width = 15

  GtkWidget::link-color = "#FFFFFF"
  GtkWidget::visited-link-color = "#FFCCFF"
  GtkWidget::focus-line-pattern = "\4\2"
  GtkWidget::focus-line-width = 5
  GtkHSV::focus-line-pattern = "\0"
  GtkWidget::interior_focus = 1
  GtkWidget::focus-padding = 0
  GtkEntry::cursor_color    = "#FF0000"
  GtkTextView::cursor_color    = "#FF0000"
  EelEditableLabel::cursor_color    = "#FF0000"
  GtkTextView::cursor_aspect_ratio = 0.3
  GtkEntry::cursor_aspect_ratio = 0.3
  EelEditableLabel::cursor_aspect_ratio = 0.3
  NautilusIconContainer::frame_text = 1
  GtkTreeView::expander-size = 32
  GtkRange::stepper-size = 20

  GtkCheckButton::indicator-size = 25

  fg[NORMAL]      = "#FFFFFF"
  text[NORMAL]    = "#FFFFFF"
  bg[NORMAL]      = "#000033"
  base[NORMAL]    = "#000033"

  fg[INSENSITIVE]      = "#999999"
  bg[INSENSITIVE]      = "#333333"
  text[INSENSITIVE]      = "#999999"
  base[INSENSITIVE]      = "#333333"

  fg[PRELIGHT]    = "#000000"
  text[PRELIGHT]    = "#003333"
  bg[PRELIGHT] = "#CCCC00"
  base[PRELIGHT]    = "#FFFFFF"

  fg[ACTIVE]      = "#FFFFFF"
  text[ACTIVE] = "#000000"
  bg[ACTIVE]      = "#666699"
  base[ACTIVE]      = "#CCCC00"

  fg[SELECTED]    = "#000033"
  text[SELECTED]    = "#000033"
  bg[SELECTED]    = "#FFFFFF"
  base[SELECTED]    = "#CCCC00"

}

class "GtkWidget" style "default"

style "panel-icons"
{

}
class "GtkWidget" style "panel-icons"
style "media-icons"
{

}
class "GtkWidget" style "media-icons"

###########widget - details

style "window"
{

}

style "window-child"
{

}

style "white-bg"
{

}

style "white-bg-child"
{

}

style "black-bg"
{

}

style "black-bg-child"
{

}

style "groupbox-panel"
{

}

style "groupbox-panel-child"
{

}

style "groupbox-palette"
{

}

style "groupbox-palette-child"
{

}

style "menu"
{
    bg[PRELIGHT] = "#000033"

    GtkMenu::scroll-arrow-vlength = 25
    GtkMenu::horizontal-padding = 2
    GtkMenu::vertical-padding   = 2
    # This means the outline of the submenu overlaps with a palette.
    # However in the case of two normal menus, they are next to each other.
    # It is not possible to be smarter about this, because the style comes from
    # the submenu.
    GtkMenu::horizontal-offset  = 0
    GtkMenu::vertical-offset    = 0

    xthickness = 0
    ythickness = 0
}

style "palette-menu" = "menu"
{
    GtkMenu::horizontal-padding = 0
    GtkMenu::vertical-padding   = 0

    xthickness = 0
    ythickness = 15

    fg[NORMAL]="#FFFFFF"
}

# Can this all be moved in the menuitem style?
style "menu-child"
{
    fg[NORMAL]="#FFFFFF"
    base[NORMAL] = "#FFFFFF"

}

#########################################################
#########################################################

style "textview"
{
    text[NORMAL]="#000000"
    base[NORMAL]="#FFFFFF"

    GtkTextView::interior-focus = 1
}

style "scrollbar"
{
    fg[NORMAL]="#FFFFFF"
    fg[ACTIVE]="#FFFFFF"
    base[NORMAL]="#FFFFFF"
    base[ACTIVE]="#FFFFFF"
}

# hints for the trough padding hacks
# We cannot go trough GTK+, as we don't want a padding on all sides, but only one
# If we wanted padding on all sides, trough-border would work great.
style "hscrollbar" = "scrollbar"
{

}

style "vscrollbar" = "scrollbar"
{

}

style "hscrollbar-scrolled-window"
{

}

style "vscrollbar-scrolled-window"
{

}

style "scale"
{
    GtkWidget::focus-line-width = 0

    fg[NORMAL]="#FFFFFF"
    fg[ACTIVE]="#FFFFFF"

    # "square" slider (really round of course)
    # Same as indicator-size?
    GtkRange::slider-width = 32
    GtkScale::slider-length = 32
    GtkRange::trough-border = 0
    GtkRange::stepper-spacing = 0
    GtkRange::trough-side-details = 1
}

# hints for the trough sizing hacks
style "hscale" = "scale"
{

}

style "vscale" = "scale"
{

}

style "spinbutton"
{
    xthickness = 15
    ythickness = 7
    GtkWidget::focus-line-width = 0
}

style "frame"
{

}

style "notebook-tab"
{
    fg[NORMAL] = "#FFFFFF"
}

style "notebook-panel"
{
   fg[NORMAL] = "#FFFFFF"
}

style "toolbox-notebook"
{
   fg[NORMAL] = "#FFFFFF"
}

style "toolbutton"
{
   fg[NORMAL] = "#FFFFFF"
}

style "separatortoolbutton"
{
    fg[NORMAL] = "#FFFFFF"
}

style "toolbar"
{

}

style "toolbox"
{
   fg[NORMAL] = "#000033"
}

style "panel"
{

}

style "entry"
{
    fg[NORMAL] = "#000000"
    base[NORMAL] = "#FFFFFF"
    text[NORMAL] = "#000000"
}

style "button"
{
    fg[NORMAL] = "#FFFFFF"
}

style "combobox"
{
    base[NORMAL] = "#FFFFFF"
}

style "comboboxentry"
{
    fg[NORMAL]="#FFFFFF"
}

style "checkbutton"
{
   fg[NORMAL] = "#FFFFFF"
}

style "progressbar"
{

}

style "menuitem"
{
    GtkMenuItem::horizontal-padding = 0
    GtkMenuItem::arrow-spacing = 15
    GtkMenuItem::toggle-spacing = 15

    fg[NORMAL] = "#FFFFFF"

    xthickness = 15
    ythickness = 10
}

style "checkmenuitem"
{
    GtkCheckMenuItem::indicator-size = 26
    GtkMenuItem::toggle-spacing = 10
}

style "imagemenuitem"
{

}

style "separatormenuitem"
{
   fg[NORMAL] = "#FFFFFF"

   GtkWidget::wide-separators = 1
   GtkWidget::separator-height = 30

   ythickness = 0
   xthickness = 0
}

style "trayicon"
{

}

style "parent-bg"
{
    fg[NORMAL]="#FFFFFF"
    engine "sugar" {
        bg[NORMAL] = parent_bg_color
        bg[INSENSITIVE] = parent_bg_color
    }
}

style "label"{
	fg[NORMAL]="#FFFFFF"
}
style "hseparator"{
	fg[NORMAL]="#FFFFFF"
}
style "white_treeview"{
	fg[NORMAL]="#000000"
	/* base[NORMAL]="#000000" */
	text[NORMAL]="#000000"
	/* bg[NORMAL]="#000000" */
}

####################################################################
# Default style, setting some generic options and style properties
####################################################################
class "GtkWidget" style "default"

####################################################################
# Styles that apply the different background (and foreground) colors
####################################################################

# This one should probably be the default (ie. no window-child style)
widget_class "<GtkWindow>"               style "window"
widget_class "<GtkWindow>*"              style "window-child"

widget_class "*<SugarAlert>"               style "black-bg"
widget_class "*<SugarAlert>*"              style "black-bg-child"

widget_class "*<SugarSectionView>"       style "white-bg"
widget_class "*<SugarSectionView>*"      style "white-bg-child"

# The notebook is very high, so that everything is overriden
# Only the color of the tab labels needs to be modified inside the
# notebooks in this style (and the widget itself).
# Assume that there is either just a normal label in the notebook tab, or
# it is inside a GtkBox (H- or VBox) together with eg. a close button.
widget_class "*<GtkNotebook>"                        style "notebook-tab"
widget_class "*<GtkNotebook>.<GtkLabel>"             style "notebook-tab"
widget_class "*<GtkNotebook>.<GtkBox>.<GtkLabel>"    style "notebook-tab"

# SugarPalette and Menu
widget_class "*<GtkMenu>"               style "menu"
widget_class "<SugarPalette>"           style "menu"
widget_class "<SugarPalette>.*"         style "menu-child"
widget_class "<SugarPalette>*<GtkMenu>" style "palette-menu"
widget_class "*<GtkMenuShell>.*"        style "menu-child"

# SugarFrameWindow
widget_class "*<SugarFrameWindow>*"    style "frame"

# SugarPanel
widget_class "*<SugarPanel>*"          style "panel"

# GroupBoxes (don't set bg[NORMAL] on the widget itself)
widget_class "<GtkWindow>*<SugarGroupBox>*"   style "groupbox-panel-child"

widget_class "<GtkWindow>*<GtkNotebook>*"   style "groupbox-panel-child"
widget_class "<GtkWindow>*<GtkNotebook>"    style "notebook-panel"

widget_class "<SugarPalette>*<SugarGroupBox>*"   style "groupbox-palette-child"

# SugarToolbox
#widget_class "*<SugarToolbox>" style "toolbox"
#widget_class "*<SugarToolbox>*" style "toolbox-child"
#widget_class "*<SugarToolbox>*<GtkEventBox>" style "toolbox"
#widget_class "*<SugarToolbox>*<GtkLayout>"   style "toolbox"
widget_class "*<SugarToolbox>*"        style "toolbox"
widget_class "*<GtkToolbar>*"          style "toolbox"
widget_class "*<SugarToolbox>.<GtkNotebook>" style "toolbox-notebook"

####################################################################
# Normal widget styles, using the above things
####################################################################
# The following only uses widget_class matches to get the priority
# right. An alternative would be to lower the priority of the
# background matches (which need widget_class) to eg. "application"

widget_class "*<GtkMenuItem>*"            style "menuitem"
widget_class "*<GtkCheckMenuItem>"        style "checkmenuitem"
widget_class "*<GtkImageMenuItem>"        style "imagemenuitem"
widget_class "*<GtkSeparatorMenuItem>*"   style "separatormenuitem"

# Buttons and Combos
widget_class "*<GtkButton>*"           style "button"
widget_class "*<GtkCheckButton>*"      style "checkbutton"
widget_class "*<GtkComboBox>*"         style "combobox"
widget_class "*<GtkComboBoxEntry>*"    style "comboboxentry"
widget_class "*<GtkCombo>*"            style "comboboxentry"

# Entries
widget_class "*<GtkEntry>"       style "entry"
widget_class "*<GtkSpinButton>"  style "spinbutton"
widget_class "*<GtkTextView>"    style "textview"

# Misc widgets
widget_class "*<GtkHScrollbar>"  style "hscrollbar"
widget_class "*<GtkVScrollbar>"  style "vscrollbar"
widget_class "*<GtkHScale>"      style "hscale"
widget_class "*<GtkVScale>"      style "vscale"
widget_class "*<GtkProgressBar>" style "progressbar"

# Scrolled window scrollbars
widget_class "*<GtkScrolledWindow>.<GtkVScrollbar>" style "vscrollbar-scrolled-window"
widget_class "*<GtkScrolledWindow>.<GtkHScrollbar>" style "hscrollbar-scrolled-window"

# Toolbar
widget_class "*<GtkToolButton>*"          style "toolbutton"
widget_class "*<GtkSeparatorToolItem>*"   style "separatortoolbutton"
widget_class "*<GtkToolbar>"              style "toolbar"

# Tray
widget_class "*<SugarTrayIcon>*" style "trayicon"

# Widgets that should get the background color from the parent
widget_class "*<GtkEventBox>"        style "parent-bg"
widget_class "*<GtkLayout>"          style "parent-bg"
widget_class "*<GtkViewport>"        style "parent-bg"
widget_class "*<GtkDrawingArea>"     style "parent-bg"
widget_class "*<GtkScrolledWindow>"  style "parent-bg"

widget_class "*<GtkLabel>*"	     style "label"
widget_class "*<GtkHSeparator>*"      style "hseparator"

widget_class "*<JournalTreeView>*" style "white_treeview"
widget_class "*<SugarActivitiesTreeView>*" style "white_treeview"

error: pathspec 'gtk3/theme/gtk-contrast-widgets.css.em' did not match any file(s) known to git


First version of boid tests where objects drift to center (not actually working yet)

function testSetPosition()
{
    var initialPosition = system.presences[0].getPosition();
    printVec3(initialPosition,"\n\n\nInitial position\n");
    var displacement = system.Vec3(1,1,1);

    system.presences[0].setPosition(addVec3(initialPosition,displacement));

}

function testSetOrientation()
{
    var initialPosition = system.presences[0].getOrientation();
    printQuat(initialPosition,"\n\n\nInitial orientation\n");
    var displacement = system.Quaternion(1,1,1,1);

    system.presences[0].setOrientation(addQuat(initialPosition,displacement));
}

function testSetVisual()
{
    var testMesh = "meerkat:///lily/milktruck.dae"
    //    var testMesh = "meerkat:///danielrh/cube.dae"

    system.print("\n\nChanging mesh\n\n");
    system.presences[0].setMesh(testMesh);

}

function testGetVisual()
{

    var visualMeshUri = system.presences[0].getMesh();
    system.print("\n\n\nMesh:");
    system.print(visualMeshUri);
    system.print("\n\n\n");
}

function getLocationCallback(object,sender) {
   sender.sendMessage({command:"locationResponse",position:system.presences[0].getPosition(),
                                                  velocity:system.presences[0].getVelocity(),
                                                  orientation:system.presences[0].getOrientation()});
}
function getPositionCallback(object,sender) {
   sender.sendMessage({command:"positionResponse",position:system.presences[0].getPosition()});
}
function getOrientationCallback(object,sender) {
   sender.sendMessage({command:"orientationResponse":orientation:system.presences[0].getOrientation()});
}
function getVelocityCallback(object,sender) {
   sender.sendMessage({command:"velocityResponse",velocity:system.presences[0].getVelocity()});
}

//requires message to have field m with value o.
var positionPattern = new system.Pattern("command","getPosition");
var velocityPattern = new system.Pattern("command","getVelocity");
var orientationPattern = new system.Pattern("command","getOrientation");
var locationPattern = new system.Pattern("command","getLocation");

var posHandler = system.registerHandler(positionPattern,null,getPositionCallback,null);
var velHandler = system.registerHandler(velocityPattern,null,getVelocityCallback,null);
var orientHandler = system.registerHandler(orientationPattern,null,getOrientationCallBack,null);
var locHandler = system.registerHandler(locationPattern,null,getLocationCallback,null);

var remoteLocations={};

function requestLocation(sender) {
   sender.sendMessage({command:"getLocation"});
}

function locationResponseCallback(object,sender) {
   delete object.command;
   remoteLocations[sender]=object;
}

function positionPoller() {
   system.__broadcast({command:"getLocation"});
/*
   for (var i=0; i<system.addressable.length();++i) {
       system.addressable[i].sendMessage();
   }
*/
}

function boidPoller() {
   var centroid = new system.Vec3(0,0,0);
   var numAve=0;
   for (i in remoteLocations) {
     centroid[i] = addVec3(centroid,remoteLocations[i].position);
     ++numAve;
   }
   centroid=scaleVector(centroid,1/numAve);
   centroid.y/=numAve;
   centroid.z/=numAve;
   system.presences[0].setPosition(addVector(scaleVector(centroid,.1),scaleVector(system.presences[0].getPosition(),.9)));
}

var locationResponsePattern = new system.Pattern("command","getLocationResponse");
var locResponseHandler = system.registerHandler(locationResponsePattern,null,locationResponseCallback,null);
system.registerTimer(".1s",positionPoller);

system.registerTimer(".1s",boidPoller);

function testSetHandler()
{
    var returnerCallBack = function()
    {
        system.print("\n\n\nI got into returner callback\n\n");
    };

    //requires message to have field m with value o.
    var mPattern = new system.Pattern("m","o");

    var handler = system.registerHandler(mPattern,null,returnerCallBack,null);
}

//this function sends a message to every single message-able entity with a message that will trigger the handler set in the previous function
function testForceHandler()
{
    var objectMessage = new Object();
    objectMessage.m = "o";

    for (var s=0; s < system.addressable.length; ++s)
    {
        system.addressable[s].sendMessage(objectMessage);
    }
}

function addVec3(a,b)
{
    var returner = system.Vec3(a.x+b.x,a.y+b.y,a.z+b.z);
    return returner;
}
function scaleVec3(a,b)
{
    var returner = system.Vec3(a.x/b,a.y/b,a.z/b);
    return returner;
}

function printVec3(vec,stringToPrint)
{
    system.print(stringToPrint);
    system.print("x: ");
    system.print(vec.x);
    system.print("y: ");
    system.print(vec.y);
    system.print("z: ");
    system.print(vec.z);
    system.print("\n\n");
}

function addQuat(a,b)
{
    var returner = system.Quaternion(a.x+b.x,a.y+b.y,a.z+b.z, a.w+b.w);
    return returner;
}

function printQuat(quat,stringToPrint)
{
    system.print(stringToPrint);
    system.print("x: ");
    system.print(quat.x);
    system.print("y: ");
    system.print(quat.y);
    system.print("z: ");
    system.print(quat.z);
    system.print("w: ");
    system.print(quat.w);
    system.print("\n\n");
}

error: pathspec 'build/cmake/importFiles/boids.em' did not match any file(s) known to git


Lite småfixar.

Lite småfixar.


documentation

documentation

/*  Sirikata
 *  bind.js
 *
 *  Copyright (c) 2011, Ewen Cheslack-Postava
 *  All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are
 *  met:
 *  * Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *  * Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 *  * Neither the name of Sirikata nor the names of its contributors may
 *    be used to endorse or promote products derived from this software
 *    without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

if (typeof(std) === "undefined") /** @namespace */ std = {};
if (typeof(std.core) === "undefined") /** @namespace */ std.core = {};

/** @function
 *  Returns a function that binds the passed function to an object.
 *  Useful for all cases where you need to pass a function argument, but
 *  you expect 'this' to be correctly set.
 *
 *  @param {function(this:Object,...[*])} func  A function object to bind.
 *  @param {Object} object  Instance of some class to become 'this'.
 *  @return {function(...[*])}  A new function that wraps func.apply()
 */
std.core.bind = function(func, object) {
    if (typeof(func) === "undefined")
        throw new TypeError("Tried to bind undefined function.");
    if (arguments.length==2) {
        delete arguments;
        return function() {
            return func.apply(object, arguments);
        };
    } else {
        var args = new Array(arguments.length-2);
        for (var i = 2; i < arguments.length; ++i) {
            args[i-2]=arguments[i];
        }
        delete arguments;
        return function () {
            var argLen = arguments.length;
            var newarglist = new Array(argLen);
            for (var i = 0; i < argLen; ++i) {
                newarglist[i]=arguments[i];
            }
            return func.apply(object,args.concat(newarglist));
        };
    }
};

error: pathspec 'liboh/plugins/js/scripts/std/core/bind.em' did not match any file(s) known to git


debian: use upstream-tag in gbp.conf

debian: use upstream-tag in gbp.conf


adding 5 second delay to allow peripherals a little more time to come up and initialize before starting the system

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/StanleyInnovation/vector_v1.git/'


Setup environment for the install step

Setup environment for the install step

#!/usr/bin/make -f
# -*- makefile -*-
# Sample debian/rules that uses debhelper.
# This file was originally written by Joey Hess and Craig Small.
# As a special exception, when this file is copied by dh-make into a
# dh-make output file, you may use that output file without restriction.
# This special exception was added by Craig Small in version 0.37 of dh-make.

# Uncomment this to turn on verbose mode.
export DH_VERBOSE=1
export DH_OPTIONS=-v --buildsystem=cmake
# TODO: remove the LDFLAGS override.  It's here to avoid esoteric problems
# of this sort:
#  https://code.ros.org/trac/ros/ticket/2977
#  https://code.ros.org/trac/ros/ticket/3842
export LDFLAGS=
export PKG_CONFIG_PATH=@(InstallationPrefix)/lib/pkgconfig

%:
	dh  $@@

override_dh_auto_configure:
	# In case we're installing to a non-standard location, look for a setup.sh
	# in the install tree that was dropped by catkin, and source it.  It will
	# set things like CMAKE_PREFIX_PATH, PKG_CONFIG_PATH, and PYTHONPATH.
	if [ -f "@(InstallationPrefix)/setup.sh" ]; then . "@(InstallationPrefix)/setup.sh"; fi && \
	dh_auto_configure -- \
		-DCATKIN_BUILD_BINARY_PACKAGE="1" \
		-DCMAKE_INSTALL_PREFIX="@(InstallationPrefix)" \
		-DCMAKE_PREFIX_PATH="@(InstallationPrefix)"

override_dh_auto_build:
	# In case we're installing to a non-standard location, look for a setup.sh
	# in the install tree that was dropped by catkin, and source it.  It will
	# set things like CMAKE_PREFIX_PATH, PKG_CONFIG_PATH, and PYTHONPATH.
	if [ -f "@(InstallationPrefix)/setup.sh" ]; then . "@(InstallationPrefix)/setup.sh"; fi && \
	dh_auto_build

override_dh_auto_test:
	# In case we're installing to a non-standard location, look for a setup.sh
	# in the install tree that was dropped by catkin, and source it.  It will
	# set things like CMAKE_PREFIX_PATH, PKG_CONFIG_PATH, and PYTHONPATH.
	echo -- Running tests. Even if one of them fails the build is not canceled.
	if [ -f "@(InstallationPrefix)/setup.sh" ]; then . "@(InstallationPrefix)/setup.sh"; fi && \
	dh_auto_test || true

override_dh_shlibdeps:
	# In case we're installing to a non-standard location, look for a setup.sh
	# in the install tree that was dropped by catkin, and source it.  It will
	# set things like CMAKE_PREFIX_PATH, PKG_CONFIG_PATH, and PYTHONPATH.
	if [ -f "@(InstallationPrefix)/setup.sh" ]; then . "@(InstallationPrefix)/setup.sh"; fi && \
	dh_shlibdeps -l$(CURDIR)/debian/@(Package)/@(InstallationPrefix)/lib/

override_dh_auto_install:
        # In case we're installing to a non-standard location, look for a setup.sh
        # in the install tree that was dropped by catkin, and source it.  It will
        # set things like CMAKE_PREFIX_PATH, PKG_CONFIG_PATH, and PYTHONPATH.
        if [ -f "@(InstallationPrefix)/setup.sh" ]; then . "@(InstallationPrefix)/setup.sh"; fi && \
        dh_auto_install


add map data structure in emerson

add map data structure in emerson

if (typeof(std) === "undefined") /** @namespace */ std = {};

/* Map data structure
 * Constructor:
 *   e.g. X = new std.map('mapTest');
 *
 * APIs:
 *   set(key,value)      : Write element to memory
 *   copy(map)           : Write all elements in given map to this map (in memory)
 *                           e.g. M = {'a':'x','b':'y'};  X.copy(M);
 *   get(key)            : Read element with given key from memory, return the value
 *   get(key,cb)         : Read element with given key from memory first, if not exists, read
 *                         from backend storage then. Callback: cb(success, value)
 *   erase(key)          : Erase element from memory
 *   clear()             : Clear content in memory
 *   flush(cb)           : Flush changes in memory to backend storage. Callback: cb(success)
 *   retrieve(keys,cb)   : Retrieve elements with given list of keys from backend to memory
 *                         Callback: cb(success)
 *   restore(cb)         : Restore all elements from backend to memory. Callback: cb(success)
 *   reset(cb)           : Clear content in both memory and backend. Callback: cb(success)
 *   name()              : Return name of the map
 *   data()              : Return all elements in memory, as format: {'a':'x','b':'y'}
 *   keys()              : Return all keys in both memory and backend, as an array.
 *   size()              : Return number of elements in memory and backend
 *   empty()             : Return true if map is emty
 */

std.map = function(name)
{
    this._type = 'map';
    this._name = name;
    this._mapName = keyName(this._type,this._name);
    this._dirtyKeys = {};
    this._data = {};
    this._keys = {};
    this._keys_list = {};
    this._init(function(success){});
};

std.map.prototype._init = function(cb)
{
    system.storageRead(this._mapName, std.core.bind(this._initCommit, this, cb));
};

std.map.prototype._initCommit = function(cb, success, val)
{
    if (!success)
        system.print('This is a new map')
    else {
        this._keys = StringtoKeys(val[this._mapName]);
        this._keys_list = this._keys;
        system.print('Map exist, restore keys')
    }
    cb(success);
};

std.map.prototype.set = function(key,value)
{
    this._data[key]=value;
    this._dirtyKeys[key] = 1;
    this._keys[key] = 1;
};

std.map.prototype.copy = function(map)
{
    for(key in map)
        this.set(key, map[key]);
}

std.map.prototype.get = function()
{
    if (arguments.length == 1) {
        key = arguments[0];
        return this._data[key];
    }
    else if (arguments.length == 2) {
        key = arguments[0];
        cb = arguments[1];
        if(key in this._data)
            cb(true, this._data[key]);
        else
            system.storageRead(keyName(this._mapName, key), std.core.bind(this._getCommit, this, key, cb));
    }
    else {
        system.print('API *get* usage: get(key) or get(key, cb)');
        return false;
    }
};

std.map.prototype._getCommit = function(key, cb, success, val)
{
    if(!success)
        system.print('key does not exist');
    else
        this._data[key]=val[keyName(this._mapName, key)];
    cb(success, this._data[key]);
};

std.map.prototype.erase = function(key)
{
    delete this._data[key];
    delete this._keys[key];
    if (key in this._keys_list)
        this._dirtyKeys[key] = 0;
    else
        delete this._dirtyKeys[key];
};

std.map.prototype.clear = function()
{
    for (key in this._data)
        this.erase(key);
};

std.map.prototype.flush = function(cb)
{
    system.storageBeginTransaction();
    for (key in this._dirtyKeys) {
        if(this._dirtyKeys[key]==1)
            system.storageWrite(keyName(this._mapName, key), this._data[key]);
        if(this._dirtyKeys[key]==0)
            system.storageErase(keyName(this._mapName, key));
    }
    system.storageWrite(this._mapName, KeystoString(this._keys));
    system.storageCommit(std.core.bind(this._flushCommit, this, cb));
};

std.map.prototype._flushCommit = function(cb, success)
{
    if (!success)
        system.print('Flush fails');
    else {
        this._dirtyKeys={};
        this._keys_list = this._keys;
    }
    cb(success);
};

std.map.prototype.retrieve = function(keys, cb)
{
    system.storageBeginTransaction();
    for(i=0; i<keys.length; i++)
        system.storageRead(keyName(this._mapName, keys[i]));
    system.storageCommit(std.core.bind(this._retrieveCommit, this, keys, cb));
};

std.map.prototype._retrieveCommit = function(keys, cb, success, val)
{
    if(!success)
        system.print('Retrieve fails');
    else
        for (i=0; i<keys.length; i++)
            this._data[keys[i]] = val[keyName(this._mapName, keys[i])];
    cb(success);
};

std.map.prototype.restore = function(cb)
{
    system.storageRead(this._mapName, std.core.bind(this._restore, this, cb));
};

std.map.prototype._restore = function(cb, success, val)
{
    if (!success) {
        system.print('Map does not exist');
        cb(success);
    }
    else {
        this._keys = {};
        list = val[this._mapName].split(',');
        if(list.length>0) {
            system.storageBeginTransaction();
            for (i=0; i<list.length; i++) {
                system.storageRead(keyName(this._mapName, list[i]));
                this._keys[list[i]] = 1;
            }
            system.storageCommit(std.core.bind(this._restoreCommit, this, cb));
        }
        else {
            system.print('Map is empty');
            cb(success)
        }
    }
};

std.map.prototype._restoreCommit = function(cb, success, val)
{
    if (!success)
        system.print('Restore fails');
    else {
        for (key in val)
            this._data[key.split(':')[2]]=val[key];
        this._dirtyKeys = {};
        this._keys_list = this._keys;
    }
    cb(success);
};

std.map.prototype.reset = function(cb)
{
    system.storageBeginTransaction();
    system.storageErase(this._mapName);
    for(key in this._keys)
        system.storageErase(keyName(this._mapName, key));
    for(key in this._dirtyKeys)
        if(this._dirtyKeys[key]==0)
            system.storageErase(keyName(this._mapName, key));
    system.storageCommit(std.core.bind(this._resetCommit, this, cb));
};

std.map.prototype._resetCommit = function(cb, success)
{
    if (!success)
        system.print('reset fails');
    else {
        this._data = {};
        this._keys = {};
        this._dirtyKeys = {};
        this._keys_list = {};
        system.print('map reset');
    }
    cb(success);
};

std.map.prototype.type = function ()
{
    return this._type;
};

std.map.prototype.name = function()
{
    return this._name;
};

std.map.prototype.data = function()
{
    return this._data;
};

std.map.prototype.dirtyKeys = function()
{
    return KeystoList(this._dirtyKeys);
};

std.map.prototype.keys = function()
{
    return KeystoList(this._keys);
};

std.map.prototype.size = function()
{
    size = 0;
    for (key in this._keys)
        size++;
    return size;
};

std.map.prototype.empty = function()
{
    for (key in this._keys)
        return false;
    return true;
}

var keyName = function(name, subname) {
    return name + ':' + subname;
};

var KeystoString = function(keys) {
    str='';
    for (key in keys)
        str = str+','+key;
    return str.substr(1);
};

var KeystoList = function(keys) {
    list = [];
    for (key in keys)
        list.push(key);
    return list;
};

var StringtoKeys = function(str) {
    list = str.split(',');
    keys = {};
    for (i=0; i<list.length; i++)
        keys[list[i]] = 1;
    return keys;
};

error: pathspec 'liboh/plugins/js/scripts/std/type/map.em' did not match any file(s) known to git


Adding snippet for importing vcs repos eg syntax: ``` yaml vcs:     ros2:         repos: https://raw.githubusercontent.com/ros2/ros2/master/ros2.repos     other_project:         repos: https://other_project.com/my_project.repos ```

@[if 'vcs' in locals()]@
@[if vcs]@
WORKDIR @(ws)
@[for i, (imports_name, imports) in enumerate(vcs.items())]@
RUN wget @(imports['repos']) \
    && vcs import @(ws) < @(imports_name).repos
@[end for]@
@[end if]@
@[end if]@

error: pathspec 'docker_templates/templates/snippet/vcs_import.Dockerfile.em' did not match any file(s) known to git


Add collision responses, courtesy of Will Monroe.

/* collision.em
 *
 * A library of standard collision functions for the generic Collision motion
 * controller
 *
 * Author: Will Monroe
 *
 * The typical usage of the Collision motion controller is
 *      new motion.Collision(presence, test, response);
 * test and response are functions called by Collision's machinery.  These two
 * callback functions will frequently fall into a few different general
 * categories that are implemented here to avoid code duplication.
 *
 * The coll module contains "metafunctions" -- themselves functions, but which
 * should not be passed directly into Collision; rather, when called with
 * certain arguments, they return a function that can be passed to Collision.
 * These arguments are used to customize the functions to meet different
 * requirements of the client.  For example:
 *      new motion.Collision(presence, coll.TestSpheres(otherVisibles),
 *              coll.Bounce(.8));
 * Be careful to always call the metafunctions, even when using all defaults
 * (when sometimes no parameters are necessary):
 *      new motion.Collision(presence, coll.TestSpheres(otherVisibles),
 *              coll.Bounce()); // not just ...coll.Bounce); !
 */

if(typeof(coll) === 'undefined')
    coll = {};

coll._mass = function(p) {
    if(typeof(p) === 'string')
        p = system.createVisible(p);

    if('mass' in p)
        return p.mass;
    else if('physics' in p && 'mass' in p.physics)
        return p.physics.mass;
    else
        return 1;
}

/* Standard test metafunctions
 * ---------------------------
 * Every test metafunction takes in some extra arguments and returns a
 * function that can be used in a Collision motion controller.  The function
 * that is returned takes one parameter, the presence to test, and returns a
 * collision object.  Collision objects contain these fields:
 *      self - the id of the presence that was being tested for collisions
 *      other - the id of the visible that self recently collided with
 *      normal - a vector pointing outwards from other, perpendicular to the
 *          surface of the collision
 *      impact - the difference in the velocities of the two bodies before
 *          collision (self.velocity - other.velocity)
 *      position - the (approximate) contact point of the two colliding bodies
 */

/**
 * @function TestSpheres(visibles)
 * @param visibles All other visibles to detect collisions against
 * @return A collision test function that tests the colliding presence (passed
 *      to the Collision motion controller) against the visibles listed in the
 *      parameter visibles using bounding spheres obtained from the scale
 *      field.  Collision normals, etc. are reported as if the presence and
 *      all visibles are spherical.
 */
coll.TestSpheres = function(visibles) {
    return function(presence) {
        for(v in visibles) {
            if(visibles[v].toString() === presence.toString())
                continue;

            var approach = presence.scale + visibles[v].scale;
            var disp = presence.position - visibles[v].position;
            if(disp.lengthSquared() < approach * approach &&
                    disp.dot(presence.velocity) <= 0) {
                var impact = approach - disp.length();
                var collision = {
                    self: {
                        id: presence.toString(),
                        velocity: presence.velocity,
                        mass: coll._mass(presence)
                    },
                    other: {
                        id: visibles[v].toString(),
                        velocity: visibles[v].velocity,
                        mass: coll._mass(visibles[v])
                    },
                    normal: disp.normal(),
                    position: presence.position + disp.scale(presence.scale - impact / 2)
                };
                return collision;
            }
        }
    };
};

coll.TestSphereToPlanes = function(planes) {
    return function(presence) {
        for(p in planes) {
            var disp = presence.position - planes[p].anchor;
            var distance = disp.dot(planes[p].normal);
            if(distance < presence.scale &&
                    planes[p].normal.dot(presence.velocity) <= 0) {
                var collision = {
                    self: {
                        id: presence.toString(),
                        velocity: presence.velocity,
                        mass: coll._mass(presence)
                    },
                    other: {
                        plane: planes[p],
                        velocity: <0, 0, 0>,
                        mass: 0
                    },
                    normal: planes[p].normal,
                    position: presence.position - planes[p].normal.scale(distance)
                };
                return collision;
            }
        }
    };
};

coll.TestBounds = function(upper, lower) {
    return coll.TestSphereToPlanes([
        {anchor: upper, normal: <-1, 0, 0>},
        {anchor: upper, normal: <0, -1, 0>},
        {anchor: upper, normal: <0, 0, -1>},
        {anchor: lower, normal: <1, 0, 0>},
        {anchor: lower, normal: <0, 1, 0>},
        {anchor: lower, normal: <0, 0, 1>}
    ]);
};

/* Standard callback metafunctions
 * -------------------------------
 * Callback metafunctions return functions that can be used as callbacks for
 * the Collision motion controller.  The metafunctions take arguments used
 * to customize the callback function that is returned, which in turn takes a
 * collision object (as defined above in "test metafunctions").
 */

/**
 * @function Stop()
 * @return A collision response function that stops the colliding presence at
 *      the point of collision.
 */
coll.Stop = function() {
    return function(presence, collision) {
        presence.velocity = <0, 0, 0>;
        presence.position = presence.position +
                collision.normal.scale(collision.self.velocity -
                collision.other.velocity);
    };
};

/**
 * @function Bounce(elast)
 * @param elast The elasticity of collisions.  For normal results, this should
 *      be a number between 0 and 1, inclusive.
 * @return A collision response function that bounces the colliding object off
 *      the other object at an equal angle, multiplying its velocity by the
 *      given elasticity.
 */
coll.Bounce = function(elast) {
    if(typeof(elast) === 'undefined')
        elast = 1;

    return function(presence, collision) {
        if(collision.normal.dot(presence.velocity -
                collision.other.velocity) >= 0 || collision.self.mass == 0)
            return;

        if(collision.other.mass == 0)
            var massFactor = 1;
        else
            var massFactor = collision.other.mass / (collision.self.mass +
                    collision.other.mass);

        var dv = collision.normal.scale((1 + elast) * massFactor *
                collision.normal.dot(presence.velocity -
                collision.other.velocity))

        presence.velocity = presence.velocity - dv;
    };
};

error: pathspec 'liboh/plugins/js/scripts/std/movement/collision.em' did not match any file(s) known to git